diff --git a/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/demo/main.cpp b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/demo/main.cpp new file mode 100644 index 0000000..1abc2d6 --- /dev/null +++ b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/demo/main.cpp @@ -0,0 +1,52 @@ +// +// Created by Administrator on 2021-12-29. +// + +#include +#include +#include +#include +#include "../src/atlas_licence.h" + +int main() { + + for (int i = 0; i <10 ; ++i) { + const char *token_password = "shiyu2018"; + std::string guid = std::string("ae454e83af41ac8eff3e9f6f")+std::to_string(i); + void *skt_handle = NULL; + atlas_licence_param param; + memset(¶m, 0, sizeof(atlas_licence_param)); + sprintf(param.product_id, "%s", "68B0B0EBB33C4359BE226543F2DBB653"); + sprintf(param.guid, "%s",guid.c_str()); + sprintf(param.token_pwd, "%s", token_password); + param.channel_num = 2; + atlas_licence_token param_token; + memset(¶m_token, 0, sizeof(atlas_licence_token)); + + int result = atlas_licence_connect(&skt_handle, param, ¶m_token); + printf("result:%d,code:%d,msg:%s \n", result, param_token.code, param_token.msg); + printf("token:%s\n", param_token.token); + std::string recv_token = std::string(param_token.token); + + atlas_licence_check_result check_result; + memset(&check_result, 0, sizeof(atlas_licence_check_result)); + + atlas_licence_check_param check_param; + memset(&check_param, 0, sizeof(atlas_licence_check_param)); + sprintf(check_param.token_pwd, "%s", token_password); + sprintf(check_param.time, "%s", "2022-01-10 20:00:00"); + sprintf(check_param.token, "%s", recv_token.c_str()); + check_param.consume = 2; + atlas_licence_check(skt_handle, check_param, &check_result); + std::cout << "code:" << check_result.code << ",msg:" << check_result.msg << std::endl; + + atlas_licence_close(&skt_handle); + + usleep(1000*1000); + } + + + + return 0; +} + diff --git a/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/include/atlas_licence.h b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/include/atlas_licence.h new file mode 100644 index 0000000..7aac8ca --- /dev/null +++ b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/include/atlas_licence.h @@ -0,0 +1,92 @@ +#ifndef ATLASLIC_ATLAS_LICENCE_H +#define ATLASLIC_ATLAS_LICENCE_H + + +#ifdef _MSC_VER +#ifdef ATLAS_LICENCE_EXPORTS +#define ATLAS_LICENCE_API __declspec(dllexport) +#else +#define ATLAS_LICENCE_API __declspec(dllimport) +#endif +#else +#define ATLAS_LICENCE_API __attribute__ ((visibility ("default"))) +#endif + +#define STATUS_SUCCESS 0 /* Success */ +#define STATUS_ERROR -1 /* Generic error */ + +#ifndef __ATLAS_LICENCE_PARAM__ +#define __ATLAS_LICENCE_PARAM__ +#define MAX_LENGTH 128 + +typedef struct atlas_licence_param { + char product_id[MAX_LENGTH]; + char guid[MAX_LENGTH]; + char token_pwd[MAX_LENGTH]; + int channel_num; +} atlas_licence_param; + +typedef struct atlas_licence_token { + int code; + char msg[MAX_LENGTH]; + char token[2048]; +} atlas_licence_token; + + +typedef struct atlas_licence_check_param { + char token[2048]; + char token_pwd[MAX_LENGTH]; + char time[MAX_LENGTH]; + int consume; +} atlas_licence_check_param; + +typedef struct atlas_licence_check_result{ + int code; + char msg[MAX_LENGTH]; +}atlas_licence_check_result; + + +#endif + +extern "C" +{ +/************************************************************************* +* FUNCTION: atlas_licence_init +* PURPOSE: 打开连接 +* PARAM: +[out] skt_handle - 句柄 +[in] param - 初始化参数 +* RETURN: +[out] int - 初始化是否成功0表示成功,-1表示失败 +* NOTES: +*************************************************************************/ +ATLAS_LICENCE_API int atlas_licence_connect(void **skt_handle, atlas_licence_param param, atlas_licence_token *param_token); + +/************************************************************************* +* FUNCTION: atlas_licence_check +* PURPOSE: 验证 +* PARAM: +[in] skt_handle - 句柄 +[in] token - token +[in] time - 时间 +[in] consume - 消费数 +[out] result - 校验结果 +* RETURN: +[out] int - 是否成功0表示成功,-1表示失败 +* NOTES: +*************************************************************************/ +ATLAS_LICENCE_API int atlas_licence_check(void *skt_handle, atlas_licence_check_param check_param, atlas_licence_check_result *result); + +/************************************************************************* +* FUNCTION: atlas_licence_close +* PURPOSE: 关闭连接 +* PARAM: +[in] skt_handle - 句柄 +* RETURN: +[out] int - 是否成功0表示成功,-1表示失败 +* NOTES: +*************************************************************************/ +ATLAS_LICENCE_API int atlas_licence_close(void **skt_handle); +} + +#endif //ATLASLIC_ATLAS_LICENCE_H diff --git a/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/lib/libatlaslic.so b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/lib/libatlaslic.so new file mode 100644 index 0000000..a2a4168 --- /dev/null +++ b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/lib/libatlaslic.so diff --git a/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/lib/libatlaslic_static.a b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/lib/libatlaslic_static.a new file mode 100644 index 0000000..4a157f6 --- /dev/null +++ b/3rdparty/atlas_lic-aarch64-20220112/atlas_lic/lib/libatlaslic_static.a diff --git a/3rdparty/spdlog-1.9.2/CMakeLists.txt b/3rdparty/spdlog-1.9.2/CMakeLists.txt index fe996b9..c89bf4b 100755 --- a/3rdparty/spdlog-1.9.2/CMakeLists.txt +++ b/3rdparty/spdlog-1.9.2/CMakeLists.txt @@ -48,7 +48,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS") set(CMAKE_CXX_EXTENSIONS ON) endif() -add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) +add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) # --------------------------------------------------------------------------------------- # Set SPDLOG_MASTER_PROJECT to ON if we are building spdlog # --------------------------------------------------------------------------------------- diff --git a/bin/libSYTSLSystemInfoNativeJNI.so b/bin/libSYTSLSystemInfoNativeJNI.so index a3dbf02..213aded 100755 --- a/bin/libSYTSLSystemInfoNativeJNI.so +++ b/bin/libSYTSLSystemInfoNativeJNI.so diff --git a/bin/libatlaslic.so b/bin/libatlaslic.so new file mode 100644 index 0000000..a2a4168 --- /dev/null +++ b/bin/libatlaslic.so diff --git a/src/Makefile b/src/Makefile index c1d5889..7764b39 100755 --- a/src/Makefile +++ b/src/Makefile @@ -14,8 +14,10 @@ OPENCV_ROOT = $(THIRDPARTY_ROOT)/opencv_4_1 JSON_ROOT = $(THIRDPARTY_ROOT)/jsoncpp-1.9.5/release FFMPEG_ROOT = $(THIRDPARTY_ROOT)/ffmpeg-4.4.4/release RABBITMQ_CLIENT_ROOT = $(THIRDPARTY_ROOT)/rabbitmq-c-0.11.0/release +AUTHORITY_DIR = $(THIRDPARTY_ROOT)/atlas_lic-aarch64-20220112/atlas_lic DEFS = -DENABLE_DVPP_INTERFACE -DWITH_FACE_DET_SS -DPOST_USE_RABBITMQ -DUSE_VILLAGE +# DEFS = -DENABLE_DVPP_INTERFACE -DWITH_FACE_DET_SS -DPOST_USE_RABBITMQ include_dir=-I/usr/local/Ascend/ascend-toolkit/6.3.RC1/aarch64-linux/include \ -I $(SPDLOG_ROOT)/include \ @@ -24,6 +26,7 @@ include_dir=-I/usr/local/Ascend/ascend-toolkit/6.3.RC1/aarch64-linux/include \ -I $(JSON_ROOT)/include \ -I $(FFMPEG_ROOT)/include \ -I $(RABBITMQ_CLIENT_ROOT)/include \ + -I $(AUTHORITY_DIR)/include \ lib_dir=-L/usr/local/Ascend/ascend-toolkit/6.3.RC1/runtime/lib64 \ -L/usr/local/Ascend/ascend-toolkit/latest/lib64 \ @@ -40,6 +43,7 @@ LIBS= -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \ -L $(JSON_ROOT)/lib -ljsoncpp \ -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ -L $(RABBITMQ_CLIENT_ROOT)/lib/aarch64-linux-gnu -lrabbitmq \ + -L $(AUTHORITY_DIR)/lib -latlaslic \ CXXFLAGS= -g -O0 -fPIC $(include_dir) $(lib_dir) $(lib) $(LIBS) $(DEFS) -lpthread -lrt -lz -fexceptions -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fvisibility=hidden -Wall -Wno-deprecated -Wdeprecated-declarations -Wl,-Bsymbolic -ldl diff --git a/src/ai_engine_module/pedestrian_vehicle_retrograde.cpp b/src/ai_engine_module/pedestrian_vehicle_retrograde.cpp index d2956b7..3b698d9 100755 --- a/src/ai_engine_module/pedestrian_vehicle_retrograde.cpp +++ b/src/ai_engine_module/pedestrian_vehicle_retrograde.cpp @@ -395,4 +395,4 @@ bool PedestrianVehicleRetrograde::update_mstreams(const std::vector & } } // namespace pedestrian_vehicle_retrograde -} // namespace ai_engine_module +} // namespace ai_engine_module \ No newline at end of file diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index 6f9d897..2febdf7 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -26,6 +26,8 @@ #define WITH_FACE_DET_SS +#define productSN "51C4B28135604F649671727185949A91" //linux 通途抓拍引擎产品序列号 + using namespace std; map index_to_algo_type = {{0, algorithm_type_t::HUMAN_SNAPSHOT}, @@ -82,10 +84,59 @@ CMultiSourceProcess::~CMultiSourceProcess(){ } int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ +#ifdef USE_VILLAGE if (!CheckTime()) { + std::cout << "sy_licence_check failed." << std::endl; return AUTHOR_ERROR; } - +#else + //授权相关------------------------------------ + //授权init----------- + const char *token_password = "Capture_atlas_arm_2023"; + std::string guid = std::string("Capture_atlas_arm")+std::to_string(vptParam.gpuid); + atlas_licence_param lic_param; + memset(&lic_param, 0, sizeof(atlas_licence_param)); + sprintf(lic_param.product_id, "%s", productSN); + sprintf(lic_param.guid, "%s",guid.c_str()); + sprintf(lic_param.token_pwd, "%s", token_password); + lic_param.channel_num = 1; + atlas_licence_token param_token; + memset(¶m_token, 0, sizeof(atlas_licence_token)); + + int result = atlas_licence_connect(&(skt_handle), lic_param, ¶m_token); + //printf("result:%d,code:%d,msg:%s \n", result, param_token.code, param_token.msg); + //printf("token:%s\n", param_token.token); + std::string recv_token = std::string(param_token.token); + + //atlas_licence_check_param check_param; + memset(&(check_param), 0, sizeof(atlas_licence_check_param)); + sprintf(check_param.token_pwd, "%s", token_password); + sprintf(check_param.time, "%s", "2023-01-10 20:00:00"); + sprintf(check_param.token, "%s", recv_token .c_str()); + check_param.consume = 2; + + //授权check------------ + check_label = -1;//初始值 + std::cout << "sy_licence_check start." << std::endl; + atlas_licence_check_result check_result; + memset(&check_result, 0, sizeof(atlas_licence_check_result)); + check_result.code = -1; + + int res = atlas_licence_check(skt_handle, check_param, &check_result); + if(res!=0) { + std::cout << "sy_licence_check failed." << std::endl; + return AUTHOR_ERROR; + } + //std::cout << "code:" << check_result.code << ",msg:" << check_result.msg << std::endl; + if(check_result.code!=0) { + std::cout << "code:" << check_result.code << ",msg:" << check_result.msg << std::endl; + return AUTHOR_ERROR; + } + std::cout << "sy_licence_check end." << std::endl; + + check_label = 0;//授权成功 + //授权相关------------------------------------ +#endif set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); @@ -111,23 +162,23 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ return ret; } +#ifdef USE_VILLAGE //三轮车头肩检测 if (!tricycle_manned_.init(vptParam.gpuid, models_dir)) { LOG_FATAL("Init tricycle_hs failed"); return -1; } - //货车头肩检测 if (!truck_manned_.init(vptParam.gpuid, models_dir)) { LOG_FATAL("Init truck_hs failed"); return -1; } - //二轮车头肩检测 if (!motor_hsprocess_.init(vptParam.gpuid, models_dir)) { LOG_FATAL("Init motor_hs failed"); return -1; } +#endif #ifdef WITH_FACE_DET_SS // 人脸检测初始化 @@ -190,7 +241,6 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ } , this); - m_timing_snapshot_thread = new std::thread( [](void* arg) { @@ -457,7 +507,17 @@ bool CMultiSourceProcess::RestartTask(const string taskID){ bool CMultiSourceProcess::FinishTask(const string taskID){ DecoderManager* pDecManager = DecoderManager::getInstance(); - return pDecManager->closeDecoderByName(taskID); + // return pDecManager->closeDecoderByName(taskID); + + // 记录主动结束的任务 + bool flag = pDecManager->closeDecoderByName(taskID); +#ifdef POST_USE_RABBITMQ + if (flag) { + std::lock_guard l1(m_ActiveFinishedTaskMtx); + m_ActiveFinishedTaskMap[taskID] = true; + } +#endif + return flag; } int CMultiSourceProcess::snapshot_task(std::string& uri_or_name, const std::string& file_name, bool bInTask) { @@ -539,7 +599,7 @@ int CMultiSourceProcess::SnapShot(task_param _cur_task_param) { void CMultiSourceProcess::CloseAllTask(){ m_bfinish = true; - + atlas_licence_close(&(skt_handle)); //授权 DecoderManager* pDecManager = DecoderManager::getInstance(); pDecManager->closeAllDecoder(); @@ -601,7 +661,7 @@ void CMultiSourceProcess::clear_finished_task(){// 清理已经结束的任务 } ++ iter_finished; - } + } } bool CMultiSourceProcess::finish_task(const string taskID, const bool delete_snapshot){ @@ -609,20 +669,31 @@ bool CMultiSourceProcess::finish_task(const string taskID, const bool delete_sna // 任务结束,关闭跟踪 if (!vpt_process.finishTaskTracker(taskID)) LOG_ERROR("Finish VPT Tracker failed, task_id: {}", taskID); - + #ifdef POST_USE_RABBITMQ - auto json_str = helpers::gen_json::gen_office_task_heart_beat_json({taskID}); - mq_manager_->publish(mq_type_t::HEART_BEAT_MQ, json_str.c_str(), true); + { + // 外部主动结束的任务不推送mq + std::lock_guard mlock(m_ActiveFinishedTaskMtx); + if (!(m_ActiveFinishedTaskMap.count(taskID) && m_ActiveFinishedTaskMap[taskID])) { + auto json_str = helpers::gen_json::gen_office_task_heart_beat_json({taskID}); + mq_manager_->publish(mq_type_t::HEART_BEAT_MQ, json_str.c_str(), true); + } + if (m_ActiveFinishedTaskMap.count(taskID)) m_ActiveFinishedTaskMap.erase(taskID); + } #endif // #ifdef WITH_SECOND_PROCESS pedestrian_vehicle_retrograde_.force_release_result(taskID); //221024 byzsh // #endif +#ifdef USE_VILLAGE tricycle_manned_.force_release_result(taskID); truck_manned_.force_release_result(taskID); motor_hsprocess_.force_release_result(taskID); m_task_param_manager->delete_task_param(taskID); +#endif + m_snapshot_reprocessing->release_finished_locus_snapshot(taskID); + m_snapshot_reprocessing->release_village_finished_locus_snapshot(taskID); return true; } @@ -635,19 +706,62 @@ int CMultiSourceProcess::algorthim_process_thread(){ ACL_CALL(aclrtCreateContext(&ctx, m_devId), ACL_ERROR_NONE, 1); while (true){ +#ifdef USE_VILLAGE if (!CheckTime()) { LOG_FATAL("authority failed!"); break; } - +#else + //授权相关------------------------------------ + if(check_label == -1) { + printf("sy_atlas_licence_check failed.\n"); + break; + } + //获取系统时间,每个月1号check一次授权 + struct tm* info; + int nYear, nMonth, nDay; + time_t raw; + time(&raw); + info = localtime(&raw); + //nYear = info->tm_year + 1900; + //nMonth = info->tm_mon + 1; + nDay = info->tm_mday; + if(nDay==1) { + if(check_label ==0) { + std::cout << "atlas_licence_check start." << std::endl; + atlas_licence_check_result check_result; + memset(&check_result, 0, sizeof(atlas_licence_check_result)); + check_result.code = -1; + + int res = atlas_licence_check(skt_handle, check_param, &check_result); + if(res!=0) { + std::cout << "sy_licence_check failed." << std::endl; + break; + } + //std::cout << "code:" << check_result.code << ",msg:" << check_result.msg << std::endl; + if(check_result.code!=0) { + check_label = -1; + std::cout << "code:" << check_result.code << ",msg:" << check_result.msg << std::endl; + break; + } + std::cout << "atlas_licence_check end." << std::endl; + check_label =1; + } + } + else { + check_label =0; + } + //授权相关------------------------------------ +#endif if(m_bfinish){ break; } - clear_finished_task(); + clear_finished_task(); vector vec_gpuMem; m_DataListMtx.lock(); + while (!m_RgbDataList.empty()){ DeviceMemory* gpuMem = m_RgbDataList.front(); if(gpuMem->getMem() == nullptr){ @@ -664,14 +778,14 @@ int CMultiSourceProcess::algorthim_process_thread(){ } } m_DataListMtx.unlock(); - - if(vec_gpuMem.size() <= 0){ + + if(vec_gpuMem.size() <= 0){ std::this_thread::sleep_for(std::chrono::milliseconds(3)); continue; } aclrtSetCurrentContext(ctx); - algorthim_vpt(vec_gpuMem); + algorthim_vpt(vec_gpuMem); #ifdef WITH_FACE_DET_SS algorthim_face_detect(vec_gpuMem); @@ -761,8 +875,8 @@ 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); - manned_snapshot(vpt_interest_task_id, vec_vptMem, deleteObjectID); + algorithm_motor_hs_process(vpt_interest_task_id, vec_vptMem, vptResult); + manned_snapshot(vpt_interest_task_id, vec_vptMem, deleteObjectID); #endif // if(vptResult.size() > 0){ @@ -1387,10 +1501,11 @@ void CMultiSourceProcess::manned_snapshot(vector& vpt_interest_task_id, string json_str = ""; std::vector algo_results; for (int sp_idx = 0; sp_idx < 3; sp_idx ++) { + int num = sp_idx + 1; // 原图 LOG_DEBUG("原图"); std::string fpath_origin = result_folder + helpers::os::sep + obj_key.video_id + "_" + - std::to_string(obj_key.obj_id) + "_" + cur_timestamp_ms + "_picnum_" + std::to_string(sp_idx) + ".jpg"; + std::to_string(obj_key.obj_id) + "_" + cur_timestamp_ms + "_picnum_" + std::to_string(num) + ".jpg"; ImgSaveInfo origin_save_info; origin_save_info.file_path = fpath_origin; @@ -1402,7 +1517,7 @@ void CMultiSourceProcess::manned_snapshot(vector& vpt_interest_task_id, LOG_DEBUG("抠图"); // 抠图 string object_file_name = result_folder_little + helpers::os::sep + obj_key.video_id + "_" + - std::to_string(obj_key.obj_id) + "_" + cur_timestamp_ms + "_picnum_" + std::to_string(sp_idx) + ".jpg"; + std::to_string(obj_key.obj_id) + "_" + cur_timestamp_ms + "_picnum_" + std::to_string(num) + ".jpg"; ImgSaveInfo obj_save_info; obj_save_info.file_path = object_file_name; obj_save_info.img_info = obj_value.snapShots[sp_idx].snapShotLittle; @@ -1737,4 +1852,4 @@ bool CMultiSourceProcess::CheckTime() { { return false; } -} \ No newline at end of file +} diff --git a/src/ai_platform/MultiSourceProcess.h b/src/ai_platform/MultiSourceProcess.h index b41e4e5..01eb344 100755 --- a/src/ai_platform/MultiSourceProcess.h +++ b/src/ai_platform/MultiSourceProcess.h @@ -20,7 +20,7 @@ #include "../ai_engine_module/truck_manned_process.h" #include "../ai_engine_module/motocycle_hs_process.h" #include "../util/JpegUtil.h" - +#include "atlas_licence.h"//授权文件 #ifdef POST_USE_RABBITMQ #include "../reprocessing_module/mq_manager.hpp" @@ -119,6 +119,9 @@ private: mutex m_FinishedTaskMtx; map m_FinishedTaskMap; + mutex m_ActiveFinishedTaskMtx ; + map m_ActiveFinishedTaskMap; // 记录主动结束的任务,不发送mq + thread* m_pAlgorthimThread; bool m_bfinish{false}; @@ -144,5 +147,9 @@ private: mutex m_recoderinfo_queue_mtx; thread* m_recode_thread {nullptr}; + void *skt_handle = nullptr;//授权 + atlas_licence_check_param check_param;//授权 + int check_label = -1;//授权 -1=未授权 0=授权 1=授权check日已经check成功(每月一次check) + }; \ No newline at end of file diff --git a/src/decoder/Makefile_decoder b/src/decoder/Makefile_decoder old mode 100755 new mode 100644 index adae0ec..1da7a0b --- a/src/decoder/Makefile_decoder +++ b/src/decoder/Makefile_decoder @@ -60,4 +60,4 @@ $(TARGET):$(OBJS) $(XX) $(CXXFLAGS) -c $< clean: - rm -f *.o $(TARGET) \ No newline at end of file + rm -f *.o $(TARGET) diff --git a/src/demo/Makefile b/src/demo/Makefile index 8aff7b1..3d88ac7 100755 --- a/src/demo/Makefile +++ b/src/demo/Makefile @@ -33,7 +33,7 @@ lib_dir=-L/usr/local/Ascend/ascend-toolkit/6.3.RC1/runtime/lib64 \ lib=-lacl_dvpp -lascendcl -lacl_dvpp_mpi -lruntime -lascendalog -lc_sec -lmsprofiler -lgert -lmmpa -lascend_hal -lexe_graph -lge_executor -lgraph -lprofapi -lascend_protobuf -lerror_manager -lhybrid_executor -lregister -ldavinci_executor -lge_common -lge_common_base \ -lplatform -lgraph_base -lqos_manager -LIBS= -L $(DEPEND_DIR) -lvpt_det_vdec -lsycheck -lface_det_vdec -lhs_tri_process -lhs_truck_process -lhs_motor_process -lvpt_ascend\ +LIBS= -L $(DEPEND_DIR) -lvpt_det_vdec -lsycheck -lface_det_vdec -lhs_tri_process -lhs_truck_process -lhs_motor_process -latlaslic -lvpt_ascend\ -L $(OPENCV_ROOT)/lib -lopencv_world\ -L $(JSON_ROOT)/lib -ljsoncpp \ -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index b76109a..a67bcd6 100755 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -3,31 +3,32 @@ #include #include #include +#include using namespace std; #ifdef POST_USE_RABBITMQ void init_mq_conn(void *handle) { - for (auto key : {mq_type_t::ALARM_MQ}) { + for (auto key : {mq_type_t::ALARM_MQ, mq_type_t::GET_TASK_MQ, mq_type_t::HEART_BEAT_MQ, mq_type_t::SCREENSHORT_TASK_MQ, mq_type_t::TIMING_SCREENSHORT_TASK_MQ}) { rabbitmq_conn_params_t mq_conn_params; - // mq_conn_params.port = 5672; - - // strcpy(mq_conn_params.ip, "192.168.10.189"); - // strcpy(mq_conn_params.uname, "admin"); - // strcpy(mq_conn_params.passwd, "shiyu2021"); - // strcpy(mq_conn_params.vhost, "/"); - // strcpy(mq_conn_params.exchange, "tsl.test.topic"); - // strcpy(mq_conn_params.exchange_type, "topic"); - mq_conn_params.port = 5673; - strcpy(mq_conn_params.ip, "192.168.10.187"); - strcpy(mq_conn_params.uname, "admin"); - strcpy(mq_conn_params.passwd, "admin123456"); + + strcpy(mq_conn_params.ip, "192.168.10.8"); + strcpy(mq_conn_params.uname, "guest"); + strcpy(mq_conn_params.passwd, "guest"); strcpy(mq_conn_params.vhost, "/"); strcpy(mq_conn_params.exchange, "topExchange"); strcpy(mq_conn_params.exchange_type, "topic"); + // mq_conn_params.port = 5673; + // strcpy(mq_conn_params.ip, "192.168.10.187"); + // strcpy(mq_conn_params.uname, "admin"); + // strcpy(mq_conn_params.passwd, "admin123456"); + // strcpy(mq_conn_params.vhost, "/"); + // strcpy(mq_conn_params.exchange, "topExchange"); + // strcpy(mq_conn_params.exchange_type, "topic"); + switch (key) { case mq_type_t::ALARM_MQ: { strcpy(mq_conn_params.queue, "topic.queue.alarm"); @@ -650,7 +651,9 @@ string createTask(void *handle, std::vector algor_vec, int gi, tparam.ipc_url = "rtsp://admin:ad123456@192.168.10.166:554/cam/realmonitor?channel=1&subtype=0"; break; case 3: - tparam.ipc_url = "/opt/share/data/bayue.mp4"; + tparam.ipc_url = "rtsp://122.97.218.170:8604/openUrl/LBBYTra?params=eyJwcm90b2NhbCI6InJ0c3AiLCJjbGllbnRUeXBlIjoib3Blbl9hcGkiLCJleHByaWVUaW1lIjotMSwicHJvdG9jb2wiOiJydHNwIiwiZXhwaXJlVGltZSI6MzAwLCJlbmFibGVNR0MiOnRydWUsImV4cGFuZCI6InN0YW5kYXJkPXJ0c3Amc3RyZWFtZm9ybT1ydHAiLCJhIjoiOTgzYjRjMmUxMThlNGU1OTlkYThmMTI3NTkyMGViODV8MXwwfDEiLCJ0IjoxfQ=="; + // tparam.ipc_url = "rtsp://122.97.218.170:8604/openUrl/V5nXRHa?params=eyJwcm90b2NhbCI6InJ0c3AiLCJjbGllbnRUeXBlIjoib3Blbl9hcGkiLCJleHByaWVUaW1lIjotMSwicHJvdG9jb2wiOiJydHNwIiwiZXhwaXJlVGltZSI6MzAwLCJlbmFibGVNR0MiOnRydWUsImV4cGFuZCI6InN0YW5kYXJkPXJ0c3Amc3RyZWFtZm9ybT1ydHAiLCJhIjoiMTBjZjM4N2JjY2Y5NDg3YzhjNWYzNjE2M2ViMWUyNTJ8MXwwfDEiLCJ0IjoxfQ=="; + //tparam.ipc_url = "/opt/share/data/bayue.mp4"; break; case 4: tparam.ipc_url = "/opt/share/data/Street.uvf"; @@ -790,6 +793,14 @@ void test_gpu(int gpuID){ // std::vector algor_vec2 = {algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED}; std::vector algor_vec3 = {algorithm_type_t::FACE_SNAPSHOT}; +/* + int repeat_num = 1000; + while(repeat_num--) { + printf("============================:%d\n",repeat_num); + string task_id = createTask(handle, algor_vec, 3 + gpuID * 10); + string task_id1 = createTask(handle, algor_vec2, 5); + string task_id2 = createTask(handle, algor_vec2, 6); +*/ // string task_id = createTask(handle, algor_vec, 3 + gpuID * 10); // string task_id1 = createTask(handle, algor_vec2, 5); @@ -815,12 +826,18 @@ void test_gpu(int gpuID){ // createTask(handle, algor_vec, 17); // createTask(handle, algor_vec, 18); // createTask(handle, algor_vec, 19); +/* // test_snapshot(handle); - + sleep(60); //60s + finish_task(handle, (char*)task_id2.data(), 0); + finish_task(handle, (char*)task_id1.data(), 0); + }*/ while (getchar() != 'q'); // finish_task(handle, (char*)task_id.data(), 0); + + // finish_task(handle, (char*)task_id1.data(), 0); tsl_aiplatform_release(&handle); } @@ -849,4 +866,4 @@ int main(int argc, char *argv[]) { printf("Done.\n"); return 0; -} \ No newline at end of file +} diff --git a/src/reprocessing_module/save_snapshot_reprocessing.cpp b/src/reprocessing_module/save_snapshot_reprocessing.cpp index 0bbe573..e3ea0a4 100755 --- a/src/reprocessing_module/save_snapshot_reprocessing.cpp +++ b/src/reprocessing_module/save_snapshot_reprocessing.cpp @@ -114,4 +114,4 @@ void save_snapshot_reprocessing::save_img_process() { } } -} +} \ No newline at end of file diff --git a/src/reprocessing_module/snapshot_reprocessing.cpp b/src/reprocessing_module/snapshot_reprocessing.cpp index a5512bd..3bd6e40 100755 --- a/src/reprocessing_module/snapshot_reprocessing.cpp +++ b/src/reprocessing_module/snapshot_reprocessing.cpp @@ -770,6 +770,7 @@ void snapshot_reprocessing::release_finished_locus_snapshot(const string taskid, VPCUtil::vpc_img_release(ss->second.snapShotLittle); } total_snapshot_info.erase(ss); + return; } } } @@ -804,12 +805,13 @@ void snapshot_reprocessing::release_village_finished_locus_snapshot(const string if (strcmp(ss->first.video_id.c_str(), taskid.c_str()) == 0) { if (bRelease){ - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { VPCUtil::vpc_img_release(ss->second.snapShots[i].snapShot); VPCUtil::vpc_img_release(ss->second.snapShots[i].snapShotLittle); } } total_village_snapshot_info.erase(ss); + return; } } } diff --git a/src/reprocessing_module/snapshot_reprocessing.h b/src/reprocessing_module/snapshot_reprocessing.h index 6e20487..d513316 100755 --- a/src/reprocessing_module/snapshot_reprocessing.h +++ b/src/reprocessing_module/snapshot_reprocessing.h @@ -82,8 +82,8 @@ public: void update_village_bestsnapshot(vector vec_devMem, vector &ol_det_result, vector>& delete_object_id); map get_total_village_snapshot_info(); - void release_finished_locus_snapshot(const string taskid, const int obj_id, bool bRelease); - void release_village_finished_locus_snapshot(const string taskid, const int obj_id, bool bRelease); + void release_finished_locus_snapshot(const string taskid, const int objid = -1, bool bRelease = true); //-1为删除该路所有任务的快照图 + void release_village_finished_locus_snapshot(const string taskid, const int objid = -1, bool bRelease = true); private: 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); diff --git a/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp b/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp index 32c64ba..d31b1ed 100755 --- a/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp +++ b/src/tsl_aiplatform_jni/AiEngineNativeInterface.cpp @@ -261,7 +261,7 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter jstring str_taskParam_taskId = (jstring)env->GetObjectField(taskParam, fid_taskParam_taskId); const char *taskParam_taskId = env->GetStringUTFChars(str_taskParam_taskId, JNI_FALSE); jobject taskParam_algorConfigParams = env->GetObjectField(taskParam, fid_taskParam_algorConfigParams); - + jint taskParam_dec_type = env->GetIntField(taskParam, fid_taskParam_dec_type); jint taskParam_port = env->GetIntField(taskParam, fid_taskParam_port); jint taskParam_protocal = env->GetIntField(taskParam, fid_taskParam_protocal); @@ -272,7 +272,6 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter jfieldID fid_syRectParam_width = env->GetFieldID(cls_syRectParam, "width", "I"); jfieldID fid_syRectParam_height = env->GetFieldID(cls_syRectParam, "height", "I"); - // java to C++ task_param mTaskParam; mTaskParam.ipc_url = taskParam_ipcUrl; @@ -290,7 +289,7 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter map psnapshot_AlgorConfigParamResSnapshotFolderMap; map snapshot_AlgorConfigParamResVideoFolderMap; map psnapshot_AlgorConfigParamResVideoFolderMap; - + jclass cls_arraylist = env->FindClass("java/util/ArrayList"); // method in class ArrayList jmethodID mid_arraylist_get = env->GetMethodID(cls_arraylist, "get", "(I)Ljava/lang/Object;"); @@ -309,7 +308,6 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter jclass cls_AlgorConfigParam = env->GetObjectClass(algorConfigParam_algorInitParam); - /* assign public variables. */ auto algor_basic_param = new algor_basic_config_param_t; { @@ -317,19 +315,19 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter env->GetFieldID(cls_AlgorConfigParam, "algor_valid_rect", "Lcom/objecteye/pojo/common/SyRectParam;"); jobject ssAlgorConfigParam_algorRect = env->GetObjectField(algorConfigParam_algorInitParam, fid_ssAlgorConfigParam_algorRect); - + jint ssAlgorConfigParam_algorRect_left = env->GetIntField(ssAlgorConfigParam_algorRect, fid_syRectParam_left); jint ssAlgorConfigParam_algorRect_top = env->GetIntField(ssAlgorConfigParam_algorRect, fid_syRectParam_top); jint ssAlgorConfigParam_algorRect_width = env->GetIntField(ssAlgorConfigParam_algorRect, fid_syRectParam_width); jint ssAlgorConfigParam_algorRect_height = env->GetIntField(ssAlgorConfigParam_algorRect, fid_syRectParam_height); - + jfieldID fid_ssAlgorConfigParam_snapshotLittleFolder = env->GetFieldID(cls_AlgorConfigParam, "result_folder_little", "Ljava/lang/String;"); jfieldID fid_ssAlgorConfigParam_snapshotFolder = env->GetFieldID(cls_AlgorConfigParam, "result_folder", "Ljava/lang/String;"); jfieldID fid_ssAlgorConfigParam_videoFolder = env->GetFieldID(cls_AlgorConfigParam, "video_folder", "Ljava/lang/String;"); //视频存储地址 - + snapshot_little_AlgorConfigParamResSnapshotFolderMap[i] = (jstring)env->GetObjectField(algorConfigParam_algorInitParam, fid_ssAlgorConfigParam_snapshotLittleFolder); psnapshot_little_AlgorConfigParamResSnapshotFolderMap[i] = @@ -342,7 +340,7 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter (jstring)env->GetObjectField(algorConfigParam_algorInitParam, fid_ssAlgorConfigParam_videoFolder); psnapshot_AlgorConfigParamResVideoFolderMap[i] = (char *)env->GetStringUTFChars(snapshot_AlgorConfigParamResVideoFolderMap[i], JNI_FALSE); - + auto algor_init_config_param = new algor_init_config_param_t; @@ -385,34 +383,29 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter case algorithm_type_t::TRICYCLE_MANNED: case algorithm_type_t::TRUCK_MANNED: { jfieldID fid = env->GetFieldID(cls_AlgorConfigParam, "hs_threshold", "I"); - jint j_hs_threshold = env->GetFloatField(algorConfigParam_algorInitParam, fid); - + jint j_hs_threshold = env->GetIntField(algorConfigParam_algorInitParam, fid); fid = env->GetFieldID(cls_AlgorConfigParam, "m_frame", "I"); jint j_m_frame = env->GetIntField(algorConfigParam_algorInitParam, fid); - fid = env->GetFieldID(cls_AlgorConfigParam, "n_frame", "I"); jint j_n_frame = env->GetIntField(algorConfigParam_algorInitParam, fid); - fid = env->GetFieldID(cls_AlgorConfigParam, "obj_min_width", "I"); jint j_min_width = env->GetIntField(algorConfigParam_algorInitParam, fid); - fid = env->GetFieldID(cls_AlgorConfigParam, "obj_min_height", "I"); jint j_min_height = env->GetIntField(algorConfigParam_algorInitParam, fid); - fid = env->GetFieldID(cls_AlgorConfigParam, "obj_confidence_threshold", "F"); jfloat j_confidence_threshold = env->GetFloatField(algorConfigParam_algorInitParam, fid); - // std::printf("%s:%d i is %d mn is [%d %d] threshold is %d\n", __FILE__, __LINE__, i, (int)j_m_frame, - // (int)j_n_frame, (int)j_hs_threshold); + std::printf("%s:%d i is %d mn is [%d %d] threshold is %d\n", __FILE__, __LINE__, i, (int)j_m_frame, + (int)j_n_frame, (int)j_hs_threshold); typedef algor_config_param_manned_incident algor_config_param_type; mTaskParam.algor_config_params[i].algor_init_config_param->algor_param = new algor_config_param_type; auto algor_param = (algor_config_param_type *)mTaskParam.algor_config_params[i].algor_init_config_param->algor_param; - + algor_param->m = (int)j_m_frame; algor_param->n = (int)j_n_frame; algor_param->hs_count_threshold = (int)j_hs_threshold; - + algor_param->obj_min_width = (int)j_min_width; algor_param->obj_min_height = (int)j_min_height; algor_param->obj_confidence_threshold = (float)j_confidence_threshold; @@ -490,8 +483,8 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_TSLAiEngineNativeInter algor_param->n = (int)j_n_frame; algor_param->threshold = (float)j_threshold; - // std::printf("%s:%d i is %d mn is [%d %d] threshold is %f\n", __FILE__, __LINE__, i, algor_param->m, - // algor_param->n, algor_param->threshold); + std::printf("%s:%d i is %d mn is [%d %d] threshold is %f\n", __FILE__, __LINE__, i, algor_param->m, + algor_param->n, algor_param->threshold); } break; case algorithm_type_t::PEDESTRIAN_FIGHT: { jfieldID fid = env->GetFieldID(cls_AlgorConfigParam, "threshold", "F");