fight_fall_cls.hpp 3.28 KB
/*
 * @Author: yangzilong
 * @Date: 2021-12-02 14:22:31
 * @Last Modified by: yangzilong
 * @Last Modified time: Do not edit
 * @Email: yangzilong@objecteye.com
 * @Description:
 */

#pragma once
#include <vector>
#include <unordered_map>

#include "include.h"
#include "fight_det.h"

namespace ai_engine_module
{
    namespace fight_fall_cls
    {



        typedef algor_config_param_pedestrian_fight* fight_algor_param_type;
        typedef algor_config_param_pedestrian_fall* fall_algor_param_type;

        #define DEFAULT_MIN_WIDTH 100
        #define DEFAULT_MIN_HEIGHT 100
        #define DEFAULT_PTHRESHOLD 0.8

        #define FIGHT_IOU_THRESH 0.1
        #define MAX_BATCH 20
        #define IMAGE_CROP_EXPAND_RATIO 0

        enum class category_t
        {
            FIGHT = 1,
            fall = 2,
        };

        typedef long id_t;
        typedef std::string taskid_t;

        typedef struct input_data_wrap_t
        {
            // about id.
            id_t objId;
            std::string taskId;

            // about gpu/cpu image data
            // sy_img img;

            // about box.
            box_t box;
        } input_data_wrap_t;


        typedef struct result_fight_data_t
        {
            box_t box;
            sy_img ori_img;
            sy_img roi_img;
            taskid_t taskid;
            std::set<id_t> objectids;
            long long id;
        } result_fight_data_t;

        typedef struct result_fall_data_t
        {
            sy_img ori_img;
            sy_img roi_img;
            id_t objectid;
            taskid_t taskid;
            box_t box;
            long long id;
        } result_fall_data_t;

        typedef struct result_data_t
        {
            std::vector<result_fight_data_t> fight_data;
            std::vector<result_fall_data_t> fall_data;
        } result_data_t;

        class FightfallCls
        {
            /**
             * @brief
             *  1. moveonly
             */
        public:

            FightfallCls();
            ~FightfallCls();

            bool init(int gpu_id, char *trt_serialize_file = "serialize_file/");

            /**
             * @brief taskIds and det_input_images must be orderly.
             *
             * @param taskIds
             * @param det_input_images
             * @param det_result
             * @param results
             * @return true
             * @return false
             */
            bool process_mstreams(const std::set<taskid_t> &taskIds, const sy_img *det_input_images, const std::vector<onelevel_det_result> &det_result,
                                  std::vector<result_data_t> &results);

            bool process_mstreams2(const std::vector<taskid_t> &taskIds, const sy_img *det_input_images, const std::vector<onelevel_det_result> &det_result,
                                  std::vector<result_data_t> &results);

            FightfallCls(const FightfallCls&) = delete;
            FightfallCls& operator=(const FightfallCls&) = delete;

        private:
            bool check_initied();

            bool init_;
            void *tools_;
            static algorithm_type_t fight_algor_type_, fall_algor_type_;
            static long long gid_;
            task_param_manager* task_param_manager_;
        };
    }  // namespace fight_fall_cls
} // namespace ai_engine_module