#ifndef _VIDEOPIPE_H_ #define _VIDEOPIPE_H_ #include #include #include #include #include namespace libvideopipe { #define WM_AI_VIDEO_FOOD_PIPE_MARK_EMPTY 0x10020001 // 输入temp为空 #define WM_AI_VIDEO_FOOD_PIPE_INPUT_FRAME_EMPTY 0x10020002 // 输入input数据为空 #define WM_AI_VIDEO_FOOD_PIPE_INPUT_FRAME_SIZE_SMALLER_THAN_MARK 0x10020003 // 输入input数据尺寸比mark小 #define WM_AI_VIDEO_MOTION_PIPE_INPUT_FRAME_EMPTY 0x10020004 #define WM_AI_VIDEO_DEPTH_PIPE_INPUT_FRAME_EMPTY 0x10020005 #define WM_AI_VIDEO_DEPTH_PIPE_INPUT_PARAM_ERROR 0x10020006 // 视频流回调函数申明 typedef void (*VideoPipeCallback)(const char* data, int len, void* user); //***************************************** //food //***************************************** struct FOOD_VIDEOPIPE_INPUT { unsigned int pts; // 时间戳 cv::Mat img; // 输入的该帧图片(roi之后) bool debug_mode; // 是否debug模式 }; enum FOOD_REALTIME_SERVICE_PLATE_STATUS_TYPES { STATIC_EMPTY = 0, // 静止的空盘 MOVING_EMPTY = 1, // 运动的空盘 STATIC_FULL = 2, // 静止的餐盘 MOVING_FULL = 3, // 运动的餐盘 MOVING_2_STATIC = 4, // 运动->静止 STATIC_EMPTY_2_MOVING = 5, // 静止空->运动 STATIC_FULL_2_MOVING = 6, // 静止餐->运动 }; struct DEBUG_INFO //此部分为调试信息 { cv::Mat back, fore, shadow; float movement_area; float match; }; enum FOOD_OUTPUT_TYPES // 输出的类型 { NORMAL = 0, // 正常输出 CHANGED = 1, // 经过更改后的输出 }; struct FOOD_VIDEOPIPE_OUTPUT { int index; // 图像索引,目前该字段无效 bool has_best_obj; // 是否具有目标,如果有则需要后续的AI识别 unsigned int output_pts; // 时间戳(与输入时的时间戳一致) cv::Mat best_img; // 最佳的用于识别的图像帧 bool debug_mode; // 是否debug模式 FOOD_OUTPUT_TYPES output_types; // 输出的类型 FOOD_REALTIME_SERVICE_PLATE_STATUS_TYPES service_plate_status; DEBUG_INFO debug_info; // debug信息 int error_code; // 错误码 }; class FoodVideoPipe { public: FoodVideoPipe(); ~FoodVideoPipe(); public: // 目前该函数无效 void SetROI(cv::Rect roi); // 设置标志物的图像 void SetMarkMat(cv::Mat temp); // 返回标志物的图像 cv::Mat GetMarkMat(); // 设置标志物的阈值,这个阈值范围是0~1(建议0.95~0.99调调看); // 如果值设越大,越容易“把空盘当餐盘”回调出来,这样调用AI识别次数会变多。 void SetMarkThreshold(float threshold); // 获取标志物的阈值 float GetMarkThreshold(); // 设置运动程度的阈值,这个阈值范围是0~1(建议0.1~0.2调调看); // 值设得越小,检测运动越灵敏 void SetMovementThreshold(float threshold); float GetMovementThreshold(); // 设置运动面积的阈值; // 值设得越小,检测运动越灵敏 void SetAreaThreshold(float threshold); float GetAreaThreshold(); // 开始追踪判断目标 int Trace(FOOD_VIDEOPIPE_INPUT input); // 设置回调函数 void SetResultCallback(VideoPipeCallback cb, void* user); private: void trace_out(FOOD_VIDEOPIPE_INPUT input); bool movement_detect(FOOD_VIDEOPIPE_INPUT input); bool mark_detect(FOOD_VIDEOPIPE_INPUT input); void resize(cv::Mat src, cv::Mat& dst, float scale); private: // roi cv::Rect roi_; // call back VideoPipeCallback cb_function_; void* cb_param_; // video track handle void* video_handle_; }; //***************************************** //motion //***************************************** struct MOTION_VIDEOPIPE_INPUT { unsigned int pts; // 时间戳 cv::Mat img; // 输入的该帧图片(roi之后) std::vector obj_points; }; struct MOTION_VIDEOPIPE_OUTPUT { int index; // 图像索引,目前该字段无效 unsigned int output_pts; // 时间戳(与输入时的时间戳一致) cv::Mat best_img; // 最佳的用于识别的图像帧 bool debug_mode; // 是否debug模式 int error_code; // 错误码 }; class MotionVideoPipe { public: MotionVideoPipe(); ~MotionVideoPipe(); public: void SetROI(cv::Rect roi); // 喂数据 int FeedFrame(MOTION_VIDEOPIPE_INPUT input); // 设置回调函数 void SetResultCallback(VideoPipeCallback cb, void* user); private: void trace_out(MOTION_VIDEOPIPE_INPUT input); private: // roi cv::Rect roi_; // call back VideoPipeCallback cb_function_; void* cb_param_; // void* video_handle_; }; //***************************************** //depth //***************************************** enum DEPTH_VIDEOPIPE_STATUS // 输出的类型 { DEPTH_IN = 0, // 进入 DEPTH_OUT = 1, // 出去 }; struct DEPTH_VIDEOPIPE_INPUT { unsigned int pts; // 时间戳 cv::Mat img; // 输入的该帧图片(roi之后) bool debug_mode; // 是否debug模式 }; struct DEPTH_VIDEOPIPE_OUTPUT { int index; // 图像索引,目前该字段无效 unsigned int output_pts; // 时间戳(与输入时的时间戳一致) DEPTH_VIDEOPIPE_STATUS status; //状态 cv::Mat best_img; // 最佳的用于识别的图像帧 bool debug_mode; // 是否debug模式 int error_code; // 错误码 }; class DepthVideoPipe { public: DepthVideoPipe(); ~DepthVideoPipe(); public: void SetROI(cv::Rect roi); // 喂数据 int FeedFrame(DEPTH_VIDEOPIPE_INPUT input); // 设置回调函数 void SetResultCallback(VideoPipeCallback cb, void* user); // 设置运动程度的阈值,这个阈值范围是0~1(建议0.1~0.2调调看); // 值设得越小,检测运动越灵敏 void SetAreaThreshold(float threshold); float GetAreaThreshold(); // 设置有效深度信息检测范围,这个阈值范围; int SetVaildDepthRange(float* valid_depth_range); int GetVaildDepthRange(float* valid_depth_range); private: void trace_out(DEPTH_VIDEOPIPE_STATUS status); bool detect_obj(DEPTH_VIDEOPIPE_INPUT input); private: // roi cv::Rect roi_; // call back VideoPipeCallback cb_function_; void* cb_param_; // void* video_handle_; }; } #endif