save_snapshot_reprocessing.h 1.32 KB
/*
 * @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 <queue>
#include <mutex>
#include <condition_variable>
#include <thread>

#include "../ai_platform/det_obj_header.h"
#include "../util/JpegUtil.h"
#include "../util/vpc_util.h"

#ifdef POST_USE_RABBITMQ
#include "post_reprocessing.hpp"
#include <memory>
#endif // #ifdef POST_USE_RABBITMQ

using namespace std;

class DeviceMemory;

struct ImgSaveInfo{
	string file_path {""};
	vpc_img_info img_info;
	string json_str {""};
	sy_rect obj_rect;
};

class save_snapshot_reprocessing
{
public:
	save_snapshot_reprocessing(int devId);
	~save_snapshot_reprocessing();
	void save_snapshot_reprocessing_release();

#ifdef POST_USE_RABBITMQ
	void set_callback(callback_t cb);
#endif

	void reprocessing_process_wo_locus_async(ImgSaveInfo saveInfo);

public:
	void save_img_process();

private:

	queue<ImgSaveInfo> waitforsave_img_queue;
	mutable std::mutex waitforsave_img_queue_mutex;
	std::thread m_save_img_thread;

	bool bFinish = false;
	int m_devId;

	JpegUtil jpegUtil;

#ifdef POST_USE_RABBITMQ
	callback_t callback_;
	std::shared_ptr<mq::post_rabbitmq_reprocessing> rbmq_handler_;
#endif
};