RegionLeave.h 1.37 KB
#ifndef __REGION_LEAVE_H__
#define __REGION_LEAVE_H__

#include <deque>
#include <map>
#include <vector>

#include "opencv2/highgui/highgui.hpp"

#include "ai_engine_header.h"
#include "../ai_platform/task_param_manager.h"
#include "../decoder/interface/DeviceMemory.hpp"
#include "../reprocessing_module/save_snapshot_reprocessing.h"


class RegionLeave {
public:
  RegionLeave();
  ~RegionLeave();

  void init(int devId, algorithm_type_t eType);

  bool add_task(const string &task_id, const int width, const int height);

  void process(std::vector<DeviceMemory*>& vec_gpuMem, const std::vector<onelevel_det_result> &det_result, const vector<vector<int>> &delete_objs);

  void release_task(string task_id);

#ifdef POST_USE_RABBITMQ
	typedef std::function<bool(const char *msg)> callback_t;
	void set_callback(callback_t cb);
#endif

private:
  bool in_rect_analysis(string task_id, const box_t &cur_bos);

  bool is_valid_box(string task_id, const box_t &box, const algorithm_type_t &algor_type);

private:
  task_param_manager *m_task_param_manager{nullptr};
  std::map<OBJ_KEY, box_t> obj_to_position_; // 保存物体上一帧的位置,基于非法闯入判断逻辑,上一帧在框外,下一帧闯入禁区
  std::map<std::string, cv::Mat> region_map;

  int m_devId{0};
  algorithm_type_t m_eType;

  save_snapshot_reprocessing *m_save_util{nullptr};
};


#endif    // __REGION_LEAVE_H__