From 5f4efeaa720ee085dd0e2198faba371971aa293d Mon Sep 17 00:00:00 2001 From: Zhao Shuaihua Date: Mon, 18 Sep 2023 03:54:11 +0000 Subject: [PATCH] 玩手机增加车辆朝向及雨棚过滤 --- src/ai_engine_module/motocycle_refit_phone_process.cpp | 413 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ai_engine_module/motocycle_refit_phone_process.h | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ai_platform/MultiSourceProcess.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--------- src/ai_platform/MultiSourceProcess.h | 8 ++++++-- src/demo/demo.cpp | 9 ++++----- 5 files changed, 584 insertions(+), 16 deletions(-) create mode 100644 src/ai_engine_module/motocycle_refit_phone_process.cpp create mode 100644 src/ai_engine_module/motocycle_refit_phone_process.h diff --git a/src/ai_engine_module/motocycle_refit_phone_process.cpp b/src/ai_engine_module/motocycle_refit_phone_process.cpp new file mode 100644 index 0000000..8806d64 --- /dev/null +++ b/src/ai_engine_module/motocycle_refit_phone_process.cpp @@ -0,0 +1,413 @@ +#include +#include "./motocycle_refit_phone_process.h" +#include +#include "../decoder/interface/DeviceMemory.hpp" +#include "../common/logger.hpp" +#include "../ai_platform/mvpt_process_assist.h" + + +namespace ai_engine_module +{ + namespace motocycle_refit_phone_process + { + static std::set algor_type_list_ = { + algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE, + algorithm_type_t::NONMOTOR_VEHICLE_REFIT, + }; + + inline bool is_valid_label(const label_t &label) { + return ((label == label_t::usephone) || + (label == label_t::call)); + } + + std::set task_id_to_algorithm_type_seq(const task_id_t &task_id, + task_param_manager *const task_param) { + std::set seq; + auto &&algor_map = task_param->get_task_other_param(task_id); + if (algor_map) { + // LOG_TRACE("task id is {} size algor type {}", task_id, algor_map->size()); + for (auto iter = algor_map->begin(); iter != algor_map->end(); ++iter) { + if (algor_type_list_.count(iter->first) > 0) + seq.emplace(iter->first); + } + } + return seq; // N(RVO) + } + + bool is_valid_box(const int top, const int left, const int right, const int bottom, const float score, + const algorithm_type_t &algor_type, + const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { + if (!params_ptr) + return false; + + if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, left, top, right, bottom)) + return false; + + if (params_ptr->algor_param == nullptr) + return false; + + + const unsigned width = right - left; + const unsigned height = bottom - top; + + if (width == 0 || height == 0) + return false; + + //! TODO: use switch to replace. + using data_t = algor_config_param_manned_incident; + data_t *algor_params_ptr = (data_t *) (params_ptr->algor_param); + + if ((width < algor_params_ptr->obj_min_width || height < algor_params_ptr->obj_min_height || score < algor_params_ptr->obj_confidence_threshold)) + return false; + + return true; + } + + + MotorRefitPhoneProcess::MotorRefitPhoneProcess() + : task_param_manager_(nullptr) + { + + } + + MotorRefitPhoneProcess::~MotorRefitPhoneProcess() + { + if (phone_tools_) { + motor_phone_release(&phone_tools_); + phone_tools_ = nullptr; + } + if (hcp_tools_) { + motor_phone_release(&hcp_tools_); + hcp_tools_ = nullptr; + } + if (m_algorthim_ctx) { + aclrtDestroyContext(m_algorthim_ctx); + } + } + + bool MotorRefitPhoneProcess::init(int gpu_id, string models_dir) + { + init_ = false; + + string model_phone_path = models_dir + "/models/village/motor_phone_310p.om" ; + string model_hcp_path = models_dir + "/models/village/hcp211008_310p.om" ; + LOG_INFO("motor_phone 版本:{} 模型路径:{} hcp 版本:{} 模型路径:{}", motor_phone_getversion(), model_phone_path, hcp_get_version(), model_hcp_path); + + motor_phone_param phone_param; + char phone_modelNames[100]; + strcpy(phone_modelNames, model_phone_path.c_str()); + phone_param.modelNames = phone_modelNames; + phone_param.thresld = 0.35; + phone_param.devId = gpu_id; + + hcp_param hcp_param; + char hcp_modelNames[100]; + strcpy(hcp_modelNames, model_hcp_path.c_str()); + hcp_param.modelNames = hcp_modelNames; + hcp_param.devId = gpu_id; + + m_devId = gpu_id; + ACL_CALL(aclrtSetDevice(m_devId), ACL_SUCCESS, -1); + ACL_CALL(aclrtCreateContext(&m_algorthim_ctx, m_devId), ACL_SUCCESS, -1); + + int status; + if (!(init_ = (0 == (status = hcp_init(&hcp_tools_, hcp_param))))) + LOG_ERROR("Init MotorRefitProcessSdk failed error code is {}", status); + else if (!(init_ = (0 == (status = motor_phone_init(&phone_tools_, phone_param))))) + LOG_ERROR("Init MotorRefitPhoneProcessSdk failed error code is {}", status); + else + if (!task_param_manager_) + task_param_manager_ = task_param_manager::getInstance(); + return init_; + } + + + bool MotorRefitPhoneProcess::check_initied() + { + if (!init_) + LOG_ERROR("[%s:%d] call init function please.", __FILE__, __LINE__); + return init_; + } + + + void MotorRefitPhoneProcess::force_release_result(const task_id_t& task_id) { + for (auto iter = id_to_result_.begin(); iter != id_to_result_.end();) { + const auto& key = iter->first; + if (key.task_id == task_id) { + auto& value = iter->second; + if (value.origin_img_desc != nullptr) { + VPCUtil::vpc_pic_desc_release(value.origin_img_desc); + } + + if (value.roi_img_desc != nullptr) { + VPCUtil::vpc_pic_desc_release(value.roi_img_desc); + } + iter = id_to_result_.erase(iter); + } + else { + ++iter; + } + + } + } + + std::shared_ptr MotorRefitPhoneProcess::get_result_by_objectid(const id_t& id, bool do_erase) + { + auto it = id_to_result_.find(id); + if (it == id_to_result_.end()) + return std::shared_ptr(nullptr); + std::shared_ptr res = std::make_shared(it->second); + if (do_erase) + id_to_result_.erase(id); + return res; + } + + bool MotorRefitPhoneProcess::update_mstreams(const std::vector& taskIds, vector vec_det_input_images, const std::vector &det_results) + { + if (!check_initied()) + return false; + + if (det_results.empty()) + { + LOG_DEBUG("detection result is empty."); + return false; + } + + struct stream_idx_and_algor_seq_t { + unsigned stream_idx; + std::set algors; + }; + + int n_images = det_results.size(); // or n_stream + + unsigned flattened_idx = 0; + std::map flattened_idx_to_batch_idx; + //! 记录每个box对应的算法以及流id. + std::map flattened_idx_to_algor_seq; + + /* 1. Crop & keep some interest class. */ + auto taskId_iter = taskIds.begin(); + std::vector flattened_imgs(0); + std::vector flattened_vpc_imgs(0); + std::vector flattened_interest_data(0); // + VPCUtil* pVpcUtil = VPCUtil::getInstance(); + for (int n = 0; n < n_images; ++n) + { + int n_interest_obj = 0; + auto& src_img = vec_det_input_images[n]; + int src_img_w = src_img->getWidth(); + int src_img_h = src_img->getHeight(); + + auto& boxes_of_one_image = det_results[n].obj; + for (int i = 0; i < det_results[n].obj_count; ++i) + { + auto& box = boxes_of_one_image[i]; + if (static_cast(box.index) == det_class_label_t::MOTOCYCLE) + { + auto& taskId = *taskId_iter; + input_data_wrap_t data; + int top = std::max(int(box.top - (IMAGE_CROP_EXPAND_RATIO * box.top)), 0); + int left = std::max(int(box.left - (IMAGE_CROP_EXPAND_RATIO * box.left)), 0); + int right = std::min(int(box.right + (IMAGE_CROP_EXPAND_RATIO * box.right)), src_img_w); + int bottom = std::min(int(box.bottom + (IMAGE_CROP_EXPAND_RATIO * box.bottom)), src_img_h); + + //! loop per algor from set. + stream_idx_and_algor_seq_t stream_idx_and_algor_seq{n, {}}; + std::set algorithm_type_seq = task_id_to_algorithm_type_seq(taskId, + task_param_manager_); // N(RVO). + + for (auto algor_iter = algorithm_type_seq.begin();algor_iter != algorithm_type_seq.end(); ++algor_iter) { + const algorithm_type_t algor_type = *algor_iter; + auto &&algor_param_wrap = task_param_manager_->get_task_other_param(taskId, algor_type); + if (!algor_param_wrap) { + LOG_ERROR("{} is nullptr when get algor param from task_param", taskId.c_str()); + continue; + } + + if (!is_valid_box(top, left, right, bottom, box.confidence, algor_type, algor_param_wrap)) + continue; + + stream_idx_and_algor_seq.algors.emplace(algor_type); + } + + if (stream_idx_and_algor_seq.algors.empty()) + continue; + + int width = right - left; + int height = bottom - top; + + data.box.top = top; + data.box.left = left; + data.box.right = right; + data.box.bottom = bottom; + data.box.score = box.confidence; + data.taskId = taskId; + data.objId = box.id; + + // 抠图 + video_object_info obj; + strcpy(obj.task_id, taskId.c_str()); + obj.object_id = box.id; + obj.left = left; obj.top = top; + obj.right = right; obj.bottom = bottom; + + vpc_img_info img_info = pVpcUtil->crop(src_img, obj); + + sy_img img; + img.w_ = width; + img.h_ = height; + img.c_ = src_img->getChannel(); + + if (img_info.pic_desc != nullptr) { + void *outputDataDev = acldvppGetPicDescData(img_info.pic_desc); + img.data_ = reinterpret_cast(outputDataDev); + } + else { + LOG_ERROR("Crop image NPU failed wh is [{}, {}] ltrb is [{} {} {} {}]", + src_img_w, src_img_h, data.box.left, data.box.top, data.box.right, data.box.bottom); + continue; + } + + flattened_imgs.emplace_back(std::move(img)); + flattened_vpc_imgs.emplace_back(std::move(img_info)); + flattened_interest_data.emplace_back(std::move(data)); + flattened_idx_to_algor_seq[flattened_idx] = std::move(stream_idx_and_algor_seq); + flattened_idx_to_batch_idx[flattened_idx++] = n; + } + } + ++taskId_iter; + } + + int ret = aclrtSetCurrentContext(m_algorthim_ctx); + if (ACL_SUCCESS != ret) { + return false; + } + /* 2. collection result. */ + int n_input_image = flattened_imgs.size(); + hcp_analysis_result model_results[n_input_image]; + // motor_phone_result model_results[n_input_image]; + { + int steps = (n_input_image + MAX_BATCH - 1) / MAX_BATCH; + for (int step = 0; step < steps; ++step) + { + int offset = step * MAX_BATCH; + int batch_size = (step == steps - 1) ? n_input_image - offset : MAX_BATCH; + hcp_batch(hcp_tools_, flattened_imgs.data() + offset, batch_size, model_results + offset); + // motor_phone_process_batch(phone_tools_, flattened_imgs.data() + offset, batch_size, model_results + offset); + } + } + + /* 3. postprocess. */ + { + for (int n = 0; n < n_input_image; ++n) + { + auto& det_result = flattened_interest_data[n]; + auto& objId = det_result.objId; + auto& task_id = det_result.taskId; + + auto &stream_idx_and_algor_seq = flattened_idx_to_algor_seq[n]; + auto &algors = stream_idx_and_algor_seq.algors; + // auto &steram_idx = stream_idx_and_algor_seq.stream_idx; + + const auto& src_img = vec_det_input_images[flattened_idx_to_batch_idx[n]]; + auto &model_result = model_results[n]; + auto &orient_pred = model_result.res_objs[11]; // 211008模型索引11对应车辆朝向 0–(正面),1-(背面),2-(侧面) + auto &refit_pred = model_result.res_objs[12]; // 211008模型索引12对应是否有雨棚 0–(无),1-(有) + + + for (auto algor_type_iter = algors.begin();algor_type_iter != algors.end(); ++algor_type_iter) { + const algorithm_type_t algor_type = *algor_type_iter; + + auto &&algor_param_wrap = task_param_manager_->get_task_other_param(task_id, algor_type); + if (!algor_param_wrap) { + LOG_ERROR("{} is nullptr when get algor param from task_param", task_id); + continue; + } + auto algor_param = ((algor_param_type)algor_param_wrap->algor_param); + + id_t obj_key = obj_key_t{ objId, task_id, algor_type}; + if (id_to_result_.find(obj_key) != id_to_result_.end()) + continue; + + // LOG_TRACE("task id is {} algor type is {} obj_id {}", task_id, int(algor_type), objId); + + auto& e = id_to_mn_[obj_key]; + ++e.m_frame; + + if (algor_type == algorithm_type_t::NONMOTOR_VEHICLE_REFIT && refit_pred.res_index != 1) + continue; + + // 数量小于设定阈值不报警 + if (algor_type == algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE) { + if (refit_pred.res_index != 0 || orient_pred.res_index != 0) continue; //有雨棚或不是正面则不判手机 + motor_phone_result phone_results[1]; + motor_phone_process_batch(phone_tools_, flattened_imgs.data() + n, 1, phone_results); + int phone_cnt = 0; //统计玩手机/打电话的检测目标个数 + for (unsigned i = 0; i < phone_results[0].objcount; ++i) { + auto &box = phone_results[0].objinfo[i]; + const label_t label = static_cast(box.index); + if (!is_valid_label(label)) + continue; + LOG_TRACE("task id is {} obj_id {} label {} index {} score {}", task_id, objId, label, box.index, box.confidence); + phone_cnt ++; + } + if (phone_cnt < 1) continue; + } + + + { + if (++e.n_frame == algor_param->n) + { + results_data_t result; + { + result.box = det_result.box; + result.taskId = det_result.taskId; + result.objId = det_result.objId; + result.algor_type = algor_type; + // 原图 + vpc_img_info src_img_info = VPCUtil::vpc_devMem2vpcImg(src_img); + result.origin_img_desc = src_img_info.pic_desc; + // 抠图--拷贝后赋值 + void *outputDataDev = acldvppGetPicDescData(flattened_vpc_imgs[n].pic_desc); + int nBufferSize = acldvppGetPicDescSize(flattened_vpc_imgs[n].pic_desc); + + void *devBuffer = nullptr; + auto ret = acldvppMalloc(&devBuffer, nBufferSize); + if (ret != ACL_SUCCESS) { + LOG_ERROR("acldvppMalloc failed, size = %u, errorCode = %d.", nBufferSize, static_cast(ret)); + return false; + } + aclrtMemcpy(devBuffer, nBufferSize, outputDataDev, nBufferSize, ACL_MEMCPY_DEVICE_TO_DEVICE); + + acldvppPicDesc *vpcInputDesc_= acldvppCreatePicDesc(); + acldvppSetPicDescData(vpcInputDesc_, devBuffer); + acldvppSetPicDescFormat(vpcInputDesc_, PIXEL_FORMAT_YUV_SEMIPLANAR_420); + acldvppSetPicDescWidth(vpcInputDesc_, acldvppGetPicDescWidth(flattened_vpc_imgs[n].pic_desc)); + acldvppSetPicDescHeight(vpcInputDesc_, acldvppGetPicDescHeight(flattened_vpc_imgs[n].pic_desc)); + acldvppSetPicDescWidthStride(vpcInputDesc_, acldvppGetPicDescWidthStride(flattened_vpc_imgs[n].pic_desc)); + acldvppSetPicDescHeightStride(vpcInputDesc_, acldvppGetPicDescHeightStride(flattened_vpc_imgs[n].pic_desc)); + acldvppSetPicDescSize(vpcInputDesc_, nBufferSize); + + result.roi_img_desc = vpcInputDesc_; //需复制 + } + id_to_result_.emplace(obj_key, std::move(result)); + } + } + + if (e.m_frame == algor_param->m) + e.reset(); + + } + + VPCUtil::vpc_img_release(flattened_vpc_imgs[n]); //flattened_imgs[n].data_ + + } + } + + return true; + } + + } // namespace motocycle_refit_phone_process + +} // namespace ai_engine_module + diff --git a/src/ai_engine_module/motocycle_refit_phone_process.h b/src/ai_engine_module/motocycle_refit_phone_process.h new file mode 100644 index 0000000..ff6895b --- /dev/null +++ b/src/ai_engine_module/motocycle_refit_phone_process.h @@ -0,0 +1,113 @@ +#pragma once +#include +#include +#include +#include +#include "../util/vpc_util.h" +#include "../ai_platform/task_param_manager.h" +#include "../ai_platform/macro_definition.h" +#include "ai_engine_header.h" +#include "human_car_parsing.h" +#include "motor_phone_det.h" +#include "acl/acl.h" +#include "acl/ops/acl_dvpp.h" + +#define MAX_BATCH 20 +#define IMAGE_CROP_EXPAND_RATIO 0 +#define MAX_OBJ_BOX_COUNT 100 + +namespace ai_engine_module +{ + namespace motocycle_refit_phone_process + { + // typedef long id_t; + using id_t = obj_key_t; + using task_id_t = std::string; + using algor_param_type = algor_config_param_manned_incident*; + + enum class label_t { + PLACEHOLDER = -1, + smoke = 0, //抽烟 + usephone = 1, //玩手机 + call = 2, //接打电话 + food = 3, // + handrail = 4, //手握在车把上 + hand = 5, //手悬空 + }; + + typedef struct input_data_wrap_t + { + id_t id; + long objId; + std::string taskId; + box_t box; + } input_data_wrap_t; + + + typedef struct mn_frame_t + { + uint m_frame; + uint n_frame; + + // explicit + mn_frame_t(uint m = 0, uint n = 0) + : m_frame(m) + , n_frame(n) + {} + + void reset() + { + m_frame = 0; + n_frame = 0; + } + + } mn_frame_t; + + + typedef struct results_data_t + { + box_t box; + acldvppPicDesc* origin_img_desc{nullptr}; + acldvppPicDesc* roi_img_desc{nullptr}; + id_t id; + long objId; + std::string taskId; + algorithm_type_t algor_type; + } results_data_t; + + class MotorRefitPhoneProcess + { + /** + * @brief + * 1. move able + */ + public: + MotorRefitPhoneProcess(); + + ~MotorRefitPhoneProcess(); + + bool check_initied(); + bool init(int gpu_id, string models_dir); + bool update_mstreams(const std::vector& taskIds, vector vec_det_input_images, const std::vector &det_results); + std::shared_ptr get_result_by_objectid(const id_t& id, bool do_erase = true); + + void force_release_result(const task_id_t& task_id); + + MotorRefitPhoneProcess(const MotorRefitPhoneProcess&) = delete; + MotorRefitPhoneProcess& operator=(const MotorRefitPhoneProcess&) = delete; + + private: + static algorithm_type_t algor_type_; + int m_devId; + aclrtContext m_algorthim_ctx; + + bool init_; + void* phone_tools_; + void* hcp_tools_; + task_param_manager* task_param_manager_; + std::map id_to_mn_; + std::map id_to_result_; + }; + } // namespace motocycle_refit_phone_process +} // namespace ai_engine_module + diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index 21e30a2..daf008a 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -178,6 +178,13 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ LOG_FATAL("Init motor_hs failed"); return -1; } + + //二轮车使用手机及加雨棚 + if (!motor_refit_phoneprocess_.init(vptParam.gpuid, models_dir)) { + LOG_FATAL("Init motor_phone failed"); + return -1; + } + /* //二轮车使用手机检测 if (!motor_phoneprocess_.init(vptParam.gpuid, models_dir)) { LOG_FATAL("Init motor_phone failed"); @@ -187,7 +194,7 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ if (!motor_refitprocess_.init(vptParam.gpuid, models_dir)) { LOG_FATAL("Init motor_refit failed"); return -1; - } + }*/ #endif #ifdef WITH_FACE_DET_SS @@ -701,8 +708,9 @@ bool CMultiSourceProcess::finish_task(const string taskID, const bool delete_sna tricycle_manned_.force_release_result(taskID); truck_manned_.force_release_result(taskID); motor_hsprocess_.force_release_result(taskID); - motor_phoneprocess_.force_release_result(taskID); - motor_refitprocess_.force_release_result(taskID); + motor_refit_phoneprocess_.force_release_result(taskID); + // motor_phoneprocess_.force_release_result(taskID); + // motor_refitprocess_.force_release_result(taskID); m_task_param_manager->delete_task_param(taskID); #endif @@ -891,10 +899,12 @@ int CMultiSourceProcess::algorthim_vpt(vector vec_gpuMem){ algorithm_truck_manned(vpt_interest_task_id, vec_vptMem, vptResult); // 二轮车超员/未戴盔 algorithm_motor_hs_process(vpt_interest_task_id, vec_vptMem, vptResult); - // 二轮车驾乘人员使用手机 + // 二轮车驾乘人员使用手机及加雨棚 + algorithm_motor_refit_phone_process(vpt_interest_task_id, vec_vptMem, vptResult); + /*// 二轮车驾乘人员使用手机 algorithm_motor_phone_process(vpt_interest_task_id, vec_vptMem, vptResult); // 电动车改装(加雨棚) - algorithm_motor_refit_process(vpt_interest_task_id, vec_vptMem, vptResult); + algorithm_motor_refit_process(vpt_interest_task_id, vec_vptMem, vptResult);*/ village_snapshot(vpt_interest_task_id, vec_vptMem, deleteObjectID); #endif @@ -1347,7 +1357,34 @@ void CMultiSourceProcess::algorithm_motor_hs_process(vector& vpt_interes } } -// 二轮车驾乘人员使用手机 +// 二轮车驾乘人员使用手机及加雨棚 +void CMultiSourceProcess::algorithm_motor_refit_phone_process(vector& vpt_interest_task_id, vector vpt_interest_imgs, + vector& vptResult) { + + vector interest_task_id; + vector interest_vpt_result; + vector interest_imgs; + + int _idx = 0; + for (auto _task_id_iter = vpt_interest_task_id.begin(); _task_id_iter != vpt_interest_task_id.end(); + ++_task_id_iter, ++_idx) // loop task_id; + { + auto task_id = *_task_id_iter; + auto algor_map = m_task_param_manager->get_task_other_param(task_id); + + if (algor_map->find(algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE) != algor_map->end() || + algor_map->find(algorithm_type_t::NONMOTOR_VEHICLE_REFIT) != algor_map->end()) { + interest_task_id.emplace_back(task_id); + interest_imgs.emplace_back(vpt_interest_imgs[_idx]); + interest_vpt_result.emplace_back(vptResult[_idx]); + } + } + + if (!interest_imgs.empty()){ + motor_refit_phoneprocess_.update_mstreams(interest_task_id, interest_imgs, interest_vpt_result); + } +} +/*// 二轮车驾乘人员使用手机 void CMultiSourceProcess::algorithm_motor_phone_process(vector& vpt_interest_task_id, vector vpt_interest_imgs, vector& vptResult) { @@ -1399,7 +1436,7 @@ void CMultiSourceProcess::algorithm_motor_refit_process(vector& vpt_inte if (!interest_imgs.empty()){ motor_refitprocess_.update_mstreams(interest_task_id, interest_imgs, interest_vpt_result); } -} +}*/ // for snapshot algorithm. 轨迹结束目标 做最后的结果返回(当前返回算法结果+快照保存路径) void CMultiSourceProcess::village_snapshot(vector& vpt_interest_task_id, vector vec_vptMem, vector> deleteObjectID) { @@ -1517,7 +1554,8 @@ void CMultiSourceProcess::village_snapshot(vector& vpt_interest_task_id, const auto &algor_other_params = task_other_params->find(algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE); const algor_basic_config_param_t *basic_param = algor_other_params->second->basic_param; - auto result = motor_phoneprocess_.get_result_by_objectid(ai_engine_module::obj_key_t{obj_key.obj_id, obj_key.video_id, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE}); + // auto result = motor_phoneprocess_.get_result_by_objectid(ai_engine_module::obj_key_t{obj_key.obj_id, obj_key.video_id, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE}); + auto result = motor_refit_phoneprocess_.get_result_by_objectid(ai_engine_module::obj_key_t{obj_key.obj_id, obj_key.video_id, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE}); if (result.get()) { village_alarm = true; algorithm_types.push_back((int)algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE); @@ -1541,7 +1579,8 @@ void CMultiSourceProcess::village_snapshot(vector& vpt_interest_task_id, const auto &algor_other_params = task_other_params->find(algorithm_type_t::NONMOTOR_VEHICLE_REFIT); const algor_basic_config_param_t *basic_param = algor_other_params->second->basic_param; - auto result = motor_refitprocess_.get_result_by_objectid(ai_engine_module::obj_key_t{obj_key.obj_id, obj_key.video_id, algorithm_type_t::NONMOTOR_VEHICLE_REFIT}); + // auto result = motor_refitprocess_.get_result_by_objectid(ai_engine_module::obj_key_t{obj_key.obj_id, obj_key.video_id, algorithm_type_t::NONMOTOR_VEHICLE_REFIT}); + auto result = motor_refit_phoneprocess_.get_result_by_objectid(ai_engine_module::obj_key_t{obj_key.obj_id, obj_key.video_id, algorithm_type_t::NONMOTOR_VEHICLE_REFIT}); if (result.get()) { village_alarm = true; algorithm_types.push_back((int)algorithm_type_t::NONMOTOR_VEHICLE_REFIT); diff --git a/src/ai_platform/MultiSourceProcess.h b/src/ai_platform/MultiSourceProcess.h index eda4cc5..9439c5c 100755 --- a/src/ai_platform/MultiSourceProcess.h +++ b/src/ai_platform/MultiSourceProcess.h @@ -19,6 +19,7 @@ #include "../ai_engine_module/tricycle_manned_process.h" #include "../ai_engine_module/truck_manned_process.h" #include "../ai_engine_module/motocycle_hs_process.h" +#include "../ai_engine_module/motocycle_refit_phone_process.h" #include "../ai_engine_module/motocycle_phone_process.h" #include "../ai_engine_module/motocycle_refit_process.h" #include "../util/JpegUtil.h" @@ -77,6 +78,8 @@ private: void algorithm_truck_manned(vector& vpt_interest_task_id, vector vpt_interest_imgs, vector& vptResult); // 二轮车超员及未戴盔 void algorithm_motor_hs_process(vector& vpt_interest_task_id, vector vpt_interest_imgs, vector& vptResult); + // 电动车改装(加雨棚)及二轮车驾乘人员使用手机 + void algorithm_motor_refit_phone_process(vector& vpt_interest_task_id, vector vpt_interest_imgs, vector& vptResult); // 二轮车驾乘人员使用手机 void algorithm_motor_phone_process(vector& vpt_interest_task_id, vector vpt_interest_imgs, vector& vptResult); // 电动车改装(加雨棚) @@ -146,8 +149,9 @@ private: ai_engine_module::tricycle_manned_process::TricycleMannedProcess tricycle_manned_; ai_engine_module::truck_manned_process::TruckMannedProcess truck_manned_; ai_engine_module::motocycle_hs_process::MotorHsProcess motor_hsprocess_; - ai_engine_module::motocycle_phone_process::MotorPhoneProcess motor_phoneprocess_; - ai_engine_module::motocycle_refit_process::MotorRefitProcess motor_refitprocess_; + ai_engine_module::motocycle_refit_phone_process::MotorRefitPhoneProcess motor_refit_phoneprocess_; + // ai_engine_module::motocycle_phone_process::MotorPhoneProcess motor_phoneprocess_; + // ai_engine_module::motocycle_refit_process::MotorRefitProcess motor_refitprocess_; face_det_ai_engine m_face_det_ai_engine; // 人脸检测 diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index 98e3001..ae23911 100755 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -705,7 +705,7 @@ string createTask(void *handle, std::vector algor_vec, int gi, // tparam.ipc_url = "rtsp://122.97.218.170:8604/openUrl/V5nXRHa?params=eyJwcm90b2NhbCI6InJ0c3AiLCJjbGllbnRUeXBlIjoib3Blbl9hcGkiLCJleHByaWVUaW1lIjotMSwicHJvdG9jb2wiOiJydHNwIiwiZXhwaXJlVGltZSI6MzAwLCJlbmFibGVNR0MiOnRydWUsImV4cGFuZCI6InN0YW5kYXJkPXJ0c3Amc3RyZWFtZm9ybT1ydHAiLCJhIjoiMTBjZjM4N2JjY2Y5NDg3YzhjNWYzNjE2M2ViMWUyNTJ8MXwwfDEiLCJ0IjoxfQ=="; break; case 4: - tparam.ipc_url = "/opt/share/data/Street.uvf"; + tparam.ipc_url = "/data/share/data/Street.uvf"; break; case 5: tparam.ipc_url = "/data/share/data/公安局老桥头_CVR15F89410_1465819864_1B.mp4"; @@ -714,7 +714,7 @@ string createTask(void *handle, std::vector algor_vec, int gi, tparam.ipc_url = "/data/share/data/不带头盔2.mp4"; break; case 7: - tparam.ipc_url = "/opt/share/data/caishenkezhan.mp4"; + tparam.ipc_url = "/data/share/data/hczr1.mp4"; break; case 8: tparam.ipc_url = "/opt/share/data/1-00000001d9.mp4"; @@ -840,7 +840,6 @@ void test_gpu(int gpuID){ std::vector algor_vec2 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE, algorithm_type_t::NONMOTOR_VEHICLE_REFIT}; - // std::vector algor_vec2 = {algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED}; std::vector algor_vec3 = {algorithm_type_t::FACE_SNAPSHOT}; /* @@ -863,10 +862,10 @@ void test_gpu(int gpuID){ // createTask(handle, algor_vec, 1); // createTask(handle, algor_vec, 2); // createTask(handle, algor_vec, 3); - // createTask(handle, algor_vec, 4); + createTask(handle, algor_vec2, 4); createTask(handle, algor_vec2, 5); createTask(handle, algor_vec2, 6); - // createTask(handle, algor_vec, 7); + createTask(handle, algor_vec2, 7); // createTask(handle, algor_vec, 8); // createTask(handle, algor_vec, 9); // createTask(handle, algor_vec, 10); -- libgit2 0.21.4