snapshot_reprocessing.h 3.72 KB
/*
 * @Author: yangzilong
 * @Date: 2021-12-17 20:27:57
 * @Last Modified by: yangzilong
 * @Email: yangzilong@objecteye.com
 * @Description:
 */
#pragma once

#include "utools.h"
#include "stl_aiplatform_header.h"
#include <vector>
#include <set>
#include <string>
#include <map>
#include <bitset>
#include "task_param_manager.h"
#include "mvpt_process_assist.h"
#include "../helpers/cuda_helper.h"
// #define EXPANSION_PROPORTION 0.1
#define EXPANSION_PROPORTION 0.25 
#define FACE_EXPANSION_PROPORTION 0.5
#define IMG_CHANNELS 3



// using namespace std;
using std::vector;
using std::map;
using std::set;

class snapshot_reprocessing
{
public:
	//更新最优快照
	static snapshot_reprocessing* getInstance()
	{
		static snapshot_reprocessing snapshot_reprocessing_instance;
		return &snapshot_reprocessing_instance;
	}

	/**
	* @brief
	*
	* @param taskin_play_id [in]:
	* @param images [in]:
	* @param ol_det_result [in]:
	* @param delete_object_id [in]: nothing ???
	* @return int
	*/
	int update_bestsnapshot(set<string>& task_in_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result, vector<vector<int>>& delete_object_id);
	int update_face_bestsnapshot(set<string>& task_in_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result, vector<vector<int>>& delete_object_id);

	int update_bestsnapshot2(vector<string>& task_in_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result, vector<vector<int>>& delete_object_id);
	int update_face_bestsnapshot2(vector<string>& task_in_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result, vector<vector<int>>& delete_object_id);

	void snapshot_reprocessing_release();

private:
	snapshot_reprocessing();

	// 用于记录每张大图抠小图需要的信息
	unsigned char* snapshot_image_data[MAX_OBJ_COUNT]{};
	int snapshot_left[MAX_OBJ_COUNT]{};
	int snapshot_right[MAX_OBJ_COUNT]{};
	int snapshot_top[MAX_OBJ_COUNT]{};
	int snapshot_bottom[MAX_OBJ_COUNT]{};
	int snapshot_dst_width[MAX_OBJ_COUNT]{};
	int snapshot_dst_height[MAX_OBJ_COUNT]{};

	map<OBJ_KEY, OBJ_VALUE> total_snapshot_info;
	map<OBJ_KEY, OBJ_VALUE> total_face_snapshot_info; //保存的人脸快照map


	map<string, set<int>> algor_index_table;
	task_param_manager *m_task_param_manager;

public:
	map<OBJ_KEY, OBJ_VALUE> *get_total_snapshot_info();
	map<OBJ_KEY, OBJ_VALUE> *get_total_face_snapshot_info(); //返回保存的人脸快照map

	void screen_effective_snapshot(const set<string> &taskid_inplay, vector<onelevel_det_result> &_onelevel_det_result);
	void screen_effective_snapshot2(const vector<string> &taskid_inplay, vector<onelevel_det_result> &_onelevel_det_result);

	bool snapshot_judge_algor(int index, int width, int height);
	bool best_snapshot_judge_algor(const OBJ_KEY& obj_key, const OBJ_VALUE& obj_value, int left, int top, int width, int height, int image_width, int image_height);
	bool best_face_snapshot_judge_algor(const OBJ_KEY& obj_key, const OBJ_VALUE& obj_value, int left, int top, int width, int height, int image_width, int image_height);
	bool best_face_snapshot_judge_algor_v2(const OBJ_KEY& obj_key, const OBJ_VALUE& obj_value, int left, int top, int width, int height, int image_width, int image_height, float roll, float yaw, float pitch); //added by zsh 220719
	void delete_finishtask_snapshot(const string taskid, const int objid = -1);   //-1为删除该路所有任务的快照图
	/*
	bool snapshot_legal_inarea(int width, int height);
	bool snapshot_legal_minarea(int index, int width, int height);
	bool snapshot_algor_open_config(const OBJ_KEY& obj_key);
	bool snapshot_legal_pos(bitset<EDGESIZE> flags, int left, int top, int right, int bottom, int image_width, int image_height);
	bool snapshot_legal_area(int max_area, int last_area, int left, int top, int right, int bottom);*/

};