Blame view

tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h 2.29 KB
85cc8cb9   Hu Chunming   原版代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  /*
   * @Author: yangzilong
   * @Date: 2021-12-14 17:51:04
   * @Last Modified by: yangzilong
   * @Email: yangzilong@objecteye.com
   * @Description:
   */
  #pragma once
  #include "opencv2/opencv.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include <string.h>
  #include "base_reprocessing_unit.h"
  #include <queue>
  #include <mutex>
  
  #ifdef POST_USE_RABBITMQ
  #include "post_reprocessing.hpp"
  #include <memory>
  #endif // #ifdef POST_USE_RABBITMQ
  
  using namespace std;
  // using namespace std;
  using std::string;
  using std::queue;
  
  #include <condition_variable>
  
  
  struct SNAPSHOT_IMAGE_UNIT {
  	cv::Mat image;
  	cv::Mat ori_image;
  
  	string file_name;
  	string ori_file_name;
  	OBJ_KEY obj_key;
  	algorithm_type_t _algor;
  	sy_rect obj_rect;
  
  #ifdef POST_USE_RABBITMQ
  	string json_str;
  #endif
  	SNAPSHOT_IMAGE_UNIT(int height, int width, int type, float* data) :image(height, width, type, data)  {}
  	SNAPSHOT_IMAGE_UNIT(int height, int width, int type, unsigned char* data) :image(height, width, type, data) {}
  	SNAPSHOT_IMAGE_UNIT(int height, int width, int type, unsigned char* data, int ori_height, int ori_width, int ori_type, unsigned char* ori_data,  algorithm_type_t algor)
  	: image(height, width, type, data)
  	, ori_image(ori_height, ori_width, ori_type, ori_data)
  	, _algor(algor) {}
  
  	SNAPSHOT_IMAGE_UNIT()
  	: _algor(algorithm_type_t::UNKNOWN)
  	{}
  };
  
  class save_snapshot_reprocessing : public base_reprocessing_unit
  {
  public:
  	save_snapshot_reprocessing();
  	void save_snapshot_reprocessing_release();
  
  	void add_newtask(const string taskid);
  	void delete_finishtask(const string taskid);
  
  #ifdef POST_USE_RABBITMQ
  	void set_callback(callback_t cb);
  #endif
  
  
  	void reprocessing_process(const OBJ_KEY &obj_key);
      void reprocessing_process_face(const OBJ_KEY &obj_key); //人脸快照后处理函数
  
  	void reprocessing_process_wo_locus(const OBJ_KEY &obj_key, const multi_image_t &m_image, bool enable_async
  #ifdef POST_USE_RABBITMQ
  									   , const std::string &json_str
  #endif
  	);
  
  public:
  	queue<SNAPSHOT_IMAGE_UNIT> waitforsave_image_queue;
  	mutable std::mutex waitforsave_image_queue_mutex;
  
  	set<string> task_on_play;
  	// map<OBJ_KEY, int> save_snapshot_info_count; // debug by zsh
  	mutable std::mutex waitforchange_taskid_mutex;
  
  #ifdef POST_USE_RABBITMQ
  	callback_t callback_;
  	std::shared_ptr<mq::post_rabbitmq_reprocessing> rbmq_handler_;
  #endif
  };