#ifndef LIBAPI_2D3D_H #define LIBAPI_2D3D_H #include #include #include #include #include #define CAL_2D3D_BASE 2000 #define CAL_OK 0 #define CAL_READFILE_FAILED 1 - CAL_2D3D_BASE #define CAL_WRITEFILE_FAILED 2 - CAL_2D3D_BASE #define CAL_NONE_PTR 3 - CAL_2D3D_BASE #define CAL_PRAMA_EMPUTY 4 - CAL_2D3D_BASE #define CAL_READIM_FAILED 5 - CAL_2D3D_BASE #define CAL_NPU_LOAD_DATASET_FAILED 6 - CAL_2D3D_BASE #define CAL_NPU_MODEL_EXE_FAILED 7 - CAL_2D3D_BASE #define CAL_NPU_GET_RESULT_FAILED 8 - CAL_2D3D_BASE #define CAL_NPU_UNLOAD_DATASET_FAILED 9 - CAL_2D3D_BASE #define CAL_YOLO_DETECT_NO_ROI 10 - CAL_2D3D_BASE #define CAL_ROIS_PUSH_TREAD_FAILED 11 - CAL_2D3D_BASE #define CAL_H_FAILED 12 - CAL_2D3D_BASE #define CAL_3D_COONERS_FAILED 13 - CAL_2D3D_BASE #define CAL_INNER_COONERS_ISNOT_4 14 - CAL_2D3D_BASE #define CAL_3D_PROJECT_POINTS_IS_0 15 - CAL_2D3D_BASE #define CAL_3D_CLOUD_POINTS_IS_0 16 - CAL_2D3D_BASE #define CAL_HAS_NO_GOOD_CONNER 17 - CAL_2D3D_BASE #define CAL_2D_ROI_DETECTIION_IS_0 18 - CAL_2D3D_BASE #define CAL_2D_CAP_IMAGE_FAILED 19 - CAL_2D3D_BASE class CalUtils { public: static int LibapiGenRandomId(long& id) { auto now = std::chrono::system_clock::now(); auto duration = now.time_since_epoch(); auto seconds = std::chrono::duration_cast(duration).count(); id = std::hash{}(static_cast(seconds)); return CAL_OK; }; }; class CSubRoi; class CMeasureInfo // 设计为单例模式 { public: static CMeasureInfo* Get(); static CMeasureInfo* Clear(); static CMeasureInfo* Init(long id, std::string info); public: CMeasureInfo(); CMeasureInfo(long id, std::string info); ~CMeasureInfo(); long GetID(); std::string GetInfo(); std::shared_ptr GetIm(); void SetIm(std::shared_ptr& imptr); std::shared_ptr& GetIm2D3D(); void SetIm2D3D(std::shared_ptr& imim2D3Dptr); std::vector>& GetSubRois(); std::vector> GetAllRoiConners(); private: static CMeasureInfo* m_instance; private: private: // 该区域ID long mId; // 该区域信息 std::string mInfo; // 该区域的图像指针 std::shared_ptr mImPtr; // 该区域的图像指针 std::shared_ptr mIm2D3DPtr; // 该区域的子图像指针 std::vector> subRois; }; class CSubRoi { public: CSubRoi(); CSubRoi(long parentId, long id, std::string info); ~CSubRoi(); public: // 该区域父图像的ID long mPparentId; // 该区域ID long mId; bool isGood; // 该区域信息 std::string mInfo; // 区域与原图的偏移量 cv::Point2f vpOffset; // 该区域的坐标(ROI的4个坐标点) * 4 std::vector mRoiPoints; // 该区域的角点的2D信息 * 4 std::vector mInnerConners; // 该区域的角点的3D信息 * 4 std::vector mInnerConners3D; // for test cal * 10000+ std::vector mVc2D; std::vector mVc3D; cv::Mat H; }; #endif