diff --git a/vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile.qx b/vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile.qx deleted file mode 100644 index f22b6ba..0000000 --- a/vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile.qx +++ /dev/null @@ -1,105 +0,0 @@ -CC = gcc -XX = g++ -AR = ar - -NVCC = /usr/local/cuda/bin/nvcc - -MNT_HOME = /home/cmhu/Project_VideoStructure - -PROJECT_ROOT= $(MNT_HOME)/vehicle_structure_platform.git0708-3080-trt-face -DEPEND_DIR = $(MNT_HOME)/Linux_3rdparty -SDK_ROOT = $(MNT_HOME)/SDK - -SRC_ROOT = $(PROJECT_ROOT)/src/VPT - -UTOOLS_SSD_ROOT = $(DEPEND_DIR)/utools_trt_v1.4.0 -HIDE_MODEL_CAFFE2 = $(PROJECT_ROOT)/model/hidemodel_caffe_1108 -HIDE_MODEL_TRT = $(PROJECT_ROOT)/model/vptModeTrt -AUTHORITY_DIR = $(DEPEND_DIR)/authority_linux_20200114 -TRT_ROOT = $(DEPEND_DIR)/TensorRT-8.6.1.6 -OPENCV_ROOT = $(DEPEND_DIR)/opencv-4.5.4/release -FFMPEG_ROOT = $(DEPEND_DIR)/ffmpeg-5.0.1/release - -TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so - -DEFS=-DOS_LINUX -DLOG_INFO2 - -INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ - -I $(DEPEND_DIR)/include \ - -I $(OPENCV_ROOT)/include/opencv4 \ - -I $(OPENCV_ROOT)/include/opencv4/opencv2 \ - -I $(UTOOLS_SSD_ROOT) \ - -I $(SRC_ROOT) \ - -I $(TRT_ROOT)/include \ - -I $(DEPEND_DIR)/include/cairo \ - -I $(SRC_ROOT)/sort \ - -I $(SRC_ROOT)/snapshot_analysis \ - -I $(SRC_ROOT)/../DxDecoder \ - -I /usr/local/cuda/include \ - -I $(HIDE_MODEL_CAFFE2) \ - -I $(HIDE_MODEL_TRT) \ - -I $(AUTHORITY_DIR) \ - -I $(FFMPEG_ROOT)/include \ - -I $(SDK_ROOT)/face_detect2/face_detect \ - -LIBSPATH= -L ../DxDecoder -l:libDxDecoder.a \ - -L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ - -L/usr/lib/x86_64-linux-gnu -lnvcuvid \ - -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lvpd2 \ - -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lface_detect -lvehicle_brand_cls -lvr_vehicle_type_10cls -lvr5905cls -lvehicle_recognize -lvehicle_color -lhuman_parsing -lhuman_car_parsing -lnon_vehicle_fea_trt -lvehicle_rear_recognition -lvf_int8 -lvp2_yolo\ - -L$(UTOOLS_SSD_ROOT) -l:libutools.so \ - -L$(DEPEND_DIR)/lib -l:liblibjasper.a -l:libIlmImf.a -l:liblibjpeg.a -l:liblibtiff.a -l:liblibpng.a \ - -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ - -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\ - -L$(AUTHORITY_DIR) -l:libauthority.a \ - -L $(DEPEND_DIR)/include/boost_linux_x86_64/lib -l:libboost_system.a -l:libboost_thread.a \ - - -CFLAGS_LIB=-g -O0 -Wall -Wno-deprecated $(DEFS) -lz -fPIC -fvisibility=hidden -Wl,-Bsymbolic -CFLAGS = $(CFLAGS_LIB) $(INCLUDE) -std=c++11 -DUSE_CUDNN - # -DUNICODE -D_UNICODE -NFLAGS_LIB=-g -c $(DEFS) -shared -Xcompiler -fPIC -Xcompiler -fvisibility=hidden -NFLAGS = $(NFLAGS_LIB) $(INCLUDE) -std=c++11 - -LIBS= - -SRCS:=$(wildcard $(SRC_ROOT)/*.cpp) \ - $(wildcard ${SRC_ROOT}/sort/*.cpp) \ - $(wildcard $(SRC_ROOT)/MD5/mID.cpp) \ - $(wildcard $(HIDE_MODEL_CAFFE2)/*.cpp) \ - $(wildcard $(HIDE_MODEL_TRT)/*.cpp) \ - $(wildcard $(SRC_ROOT)/snapshot_analysis/*.cpp) \ - -OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS))) - -CU_SOURCES = $(wildcard ${SRC_ROOT}/snapshot_analysis/*.cu) -CU_OBJS = $(patsubst %.cu, %.o, $(notdir $(CU_SOURCES))) - -all:$(TARGET) - -$(TARGET):$(OBJS) $(CU_OBJS) - rm -f $(TARGET) - $(XX) $(CFLAGS) -shared -o $@ $^ $(LIBSPATH) $(LIBS) -Wl,-rpath=$(DEPEND_DIR)/video_structure_sdk_20220512 - rm -f *.o - -%.o:$(SRC_ROOT)/%.cpp - $(XX) $(CFLAGS) -c $< -%.o:$(SRC_ROOT)/MD5/%.cpp - $(XX) $(CFLAGS) -c $< -%.o:$(SRC_ROOT)/sort/%.cpp - $(XX) $(CFLAGS) -c $< -%.o:$(HIDE_MODEL_CAFFE2)/%.cpp - $(XX) $(CFLAGS) -c $< -%.o:$(HIDE_MODEL_TRT)/%.cpp - $(XX) $(CFLAGS) -c $< -%.o:$(SRC_ROOT)/snapshot_analysis/%.cpp - $(XX) $(CFLAGS) -c $< -%.o:$(SRC_ROOT)/snapshot_analysis/%.cu - @echo "#######################CU_OBJS:$@###############" - $(NVCC) $(NFLAGS) -o $@ $< - -.PHONY:clean -clean: - rm -f *.o $(TARGET) - - diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp index e365cae..d7f2954 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp @@ -311,10 +311,10 @@ void FFNvDecoder::decode_thread() void FFNvDecoder::decode_finished(){ if (avctx) { - if (avctx->hw_device_ctx) { - av_buffer_unref(&avctx->hw_device_ctx); - avctx->hw_device_ctx = nullptr; - } + // if (avctx->hw_device_ctx) { + // av_buffer_unref(&avctx->hw_device_ctx); + // avctx->hw_device_ctx = nullptr; + // } avcodec_free_context(&avctx); avctx = nullptr; } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp index bdc4b5c..c4374ee 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp @@ -63,11 +63,11 @@ int HumanCarParsing::init(int gpuid, char* auth_license) param.max_batch = 20; if (hcp_init(&handle, param) != 0) { - LOG_ERROR("Init HCP Failed!"); + LOG_ERROR("hcp_init Failed!"); return FAILED; } - LOG_INFO("HumanCarParsing init success! gpu_id: {}", gpuid); + LOG_INFO("hcp_init success! gpu_id: {}", gpuid); return SUCCESS; } @@ -98,6 +98,6 @@ int HumanCarParsing::release() handle = nullptr; } - LOG_INFO("HumanCarParsing Release."); + LOG_INFO("hcp_release"); return SUCCESS; } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanFea.cpp index d7ec000..418892e 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanFea.cpp @@ -1,46 +1,60 @@ -#include "non_vehicle_fea.h" +#include "HumanFea.h" #include "sy_common.h" #include -int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license) + +#include "../../FFNvDecoder/logger.hpp" + +HumanFea::HumanFea(/* args */) { +} - int ret = SUCCESS; +HumanFea::~HumanFea() +{ + LOG_INFO("~HumanFea"); +} +int HumanFea::init(int gpuid, char* auth_license) +{ human_fea_param fea_param; fea_param.mode = DEVICE_GPU; fea_param.gpuid = gpuid; fea_param.thres = 0.6; fea_param.engine = ENGINE_TENSORRT; - //未锟斤拷效 fea_param.max_batch = 20; fea_param.serialize_file = "./serialize_file/HF"; fea_param.auth_license = auth_license; - if (human_fea_init(&handle, fea_param) != SUCCESS) + + int ret = human_fea_init(&handle, fea_param); + if (ret != SUCCESS) { - printf("sy_human_parsing_fea_init(error): init end. (ret = %d)\n", ret); - ret = HUMANPARSING_INIT_ERROR; + LOG_ERROR("human_fea_init failed:{}", ret); + return FAILED; } + LOG_INFO("human_fea_init success! gpu_id: {}", gpuid); return SUCCESS; - } -int NonVehicleFea_Process(void * handle, sy_img * batch_img, int batch_size, human_fea_result*& result) +int HumanFea::process(sy_img * batch_img, int batch_size, human_fea_result*& result) { - for (int i = 0; i < batch_size; i++) - { - if (batch_img[i].data_ == NULL) - std::cout << i << " NonVehicleFea data null" << std::endl; + for (int i = 0; i < batch_size; i++) { + if (batch_img[i].data_ == NULL) { + LOG_ERROR("data null!"); + return FAILED; + } } return human_fea_batch(handle, batch_img, batch_size, result); - } -int NonVehicleFea_Release(void *& handle) +int HumanFea::release() { - human_fea_release(&handle); - handle = NULL; + if(handle) { + human_fea_release(&handle); + handle = nullptr; + } + + LOG_INFO("human_fea_release"); return SUCCESS; } \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanFea.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanFea.h new file mode 100644 index 0000000..413c030 --- /dev/null +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanFea.h @@ -0,0 +1,17 @@ +#pragma once +#include "non_vehicle_fea_trt.h" +#include "utools.h" + + +class HumanFea { +public: + HumanFea(/* args */); + ~HumanFea(); + + int init(int gpuid, char* auth_license); + int process(sy_img * batch_img, int batch_size, human_fea_result*& result); + int release(); + +private: + void* handle{nullptr}; +}; \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.cpp index b8d5e53..156bd50 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.cpp @@ -1,30 +1,42 @@ #include "HumanParsing.h" #include -//static string head[] = { "长发", "短发", "其他" }; -//static string head_color[] = { "黑", "白", "其他" }; -//static string eye[] = { "未戴眼镜", "戴眼镜" }; -//static string mouth[] = { "未戴口罩", "戴口罩" }; -//static string up[] ={ "T恤/背心", "衬衫", "毛衣"," 外套" , "连衣裙", "其他" }; -//static std::string up_color[] = { "黑", "白", "灰", "红", "蓝", "黄", "绿", "多色", "其他" }; -//static string clothing_text[] = { "纯色", "碎花", "条纹/格子", "其他" }; -//static string down[6] = { "长裤", "短裤", "长裙", "短裙", "连衣裙", "其他" }; -//static std::string down_color[] = { "黑", "白", "灰", "红", "蓝", "黄", "绿", "多色", "其他" }; -//static string bao[5] = { "无包", "有包" }; -//static std::string sex[] = { "男", "女", "不明" }; -//static std::string age[] = { "小孩", "成人", "不明" }; -//static std::string viewpoint[] = { "正面","背面", "侧面" }; -//static string dasan[2] = { "未打伞", "打伞" }; -//static string child[2] = { "未抱小孩", "抱小孩" }; -//static string personstate[5] = { "行走/站立", "奔跑", "蹲/坐", "推车", "其他" }; + +#include "../../FFNvDecoder/logger.hpp" + + +//static string head[] = { "闀垮彂", "鐭彂", "鍏朵粬" }; +//static string head_color[] = { "榛", "鐧", "鍏朵粬" }; +//static string eye[] = { "鏈埓鐪奸暅", "鎴寸溂闀" }; +//static string mouth[] = { "鏈埓鍙g僵", "鎴村彛缃" }; +//static string up[] ={ "T鎭/鑳屽績", "琛~", "姣涜。"," 澶栧" , "杩炶。瑁", "鍏朵粬" }; +//static std::string up_color[] = { "榛", "鐧", "鐏", "绾", "钃", "榛", "缁", "澶氳壊", "鍏朵粬" }; +//static string clothing_text[] = { "绾壊", "纰庤姳", "鏉$汗/鏍煎瓙", "鍏朵粬" }; +//static string down[6] = { "闀胯¥", "鐭¥", "闀胯", "鐭", "杩炶。瑁", "鍏朵粬" }; +//static std::string down_color[] = { "榛", "鐧", "鐏", "绾", "钃", "榛", "缁", "澶氳壊", "鍏朵粬" }; +//static string bao[5] = { "鏃犲寘", "鏈夊寘" }; +//static std::string sex[] = { "鐢", "濂", "涓嶆槑" }; +//static std::string age[] = { "灏忓", "鎴愪汉", "涓嶆槑" }; +//static std::string viewpoint[] = { "姝i潰","鑳岄潰", "渚ч潰" }; +//static string dasan[2] = { "鏈墦浼", "鎵撲紴" }; +//static string child[2] = { "鏈姳灏忓", "鎶卞皬瀛" }; +//static string personstate[5] = { "琛岃蛋/绔欑珛", "濂旇窇", "韫/鍧", "鎺ㄨ溅", "鍏朵粬" }; const int FIR_INDEX_SIZE = 16; const int SEC_INDEX_SIZE[FIR_INDEX_SIZE] = { 3, 3, 2, 2, 6, 9, 4, 6, 9, 2, 3, 3, 3, 2, 2, 5 }; +HumanParsing::HumanParsing(/* args */) +{ +} + +HumanParsing::~HumanParsing() +{ + LOG_INFO("~HumanParsing"); +} -int HumanParsing_Init(void *&handle, int gpuid, char* auth_license) +int HumanParsing::init(int gpuid, char* auth_license) { hp_param param; param.mode = DEVICE_GPU; @@ -33,30 +45,25 @@ int HumanParsing_Init(void *&handle, int gpuid, char* auth_license) param.max_batch = 20; param.serialize_file = "./serialize_file/HP"; param.auth_license = auth_license; - if (hp_init(&handle, param) != 0) - { - cout << "Init HP Failed!" << endl; + if (hp_init(&handle, param) != 0) { + LOG_ERROR("hp_init failed!"); return FAILED; } + LOG_INFO("hp_init success! gpu_id: {}", gpuid); return SUCCESS; } - - - -#include -int HumanParsing_Process(void * handle, sy_img * batch_img, int batch_size, hp_analysis_res*& result) +int HumanParsing::process(sy_img * batch_img, int batch_size, hp_analysis_res*& result) { - - for (int i = 0; i < batch_size; i++) { - if (batch_img[i].data_ == NULL) - cout << i << " data null" << endl; + if (batch_img[i].data_ == NULL) { + LOG_ERROR("data null!"); + return FAILED; + } } - //cout << "begin HumanParsingProcessBatch" << endl; hp_batch(handle, batch_img, batch_size, result); for (int b = 0; b < batch_size; b++) @@ -73,90 +80,16 @@ int HumanParsing_Process(void * handle, sy_img * batch_img, int batch_size, hp_ } } - //cout << "end HumanParsingProcessBatch" << endl; - - - //for (int b = 0; b < batch_size; b++) - //{ - // ctools_result &cur_result = result[b]; - // int big_class_count = cur_result.obj_count_; - // ctools_obj_result &index_score = cur_result.obj_results_[big_class_count]; - - // if (index_score.data_count_ != FIR_INDEX_SIZE * 2) - // { - // printf("wrong result.\n"); - // break; - // } - - // //for (int i = 0; i < FIR_INDEX_SIZE; i++) - // //{ - // // //int resIndex = result[j][i].index; - // // int resIndex = index_score.data_[i * 2]; - - // // switch (i) - // // { - // // case 0: - // // cout << head[resIndex] << " "; - // // break; - // // case 1: - // // cout << head_color[resIndex] << " "; - // // break; - // // case 2: - // // cout << eye[resIndex] << " "; - // // break; - // // case 3: - // // cout << mouth[resIndex] << " "; - // // break; - // // case 4: - // // cout << up[resIndex] << " "; - // // break; - // // case 5: - // // cout << up_color[resIndex] << " "; - // // break; - // // case 6: - // // cout << clothing_text[resIndex] << " "; - // // break; - // // case 7: - // // cout << down[resIndex] << " "; - // // break; - // // case 8: - // // cout << down_color[resIndex] << " "; - // // break; - // // case 9: - // // cout << bao[resIndex] << " "; - // // break; - // // case 10: - // // cout << sex[resIndex] << " "; - // // break; - // // case 11: - // // cout << age[resIndex] << " "; - // // break; - // // case 12: - // // cout << viewpoint[resIndex] << " "; - // // break; - // // case 13: - // // cout << dasan[resIndex] << " "; - // // break; - // // case 14: - // // cout << child[resIndex] << " "; - // // break; - // // case 15: - // // cout << personstate[resIndex] << " "; - // // break; - // // default: - // // break; - // // } - - // //} - // //cout << endl << endl; - //} - return SUCCESS; } -int HumanParsing_Release(void *& handle) +int HumanParsing::release() { - if(handle) - hp_release(&handle); + if(handle) { + hp_release(&handle); + handle = nullptr; + } + + LOG_INFO("hp_release"); return SUCCESS; } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.h index 6fda72c..9ffe9c3 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanParsing.h @@ -8,7 +8,16 @@ using namespace std; +class HumanParsing +{ +public: + HumanParsing(/* args */); + ~HumanParsing(); -int HumanParsing_Init(void *&handle, int gpuid, char* auth_license); -int HumanParsing_Process(void * handle, sy_img * batch_img, int batchsize, hp_analysis_res*& result); -int HumanParsing_Release(void *& handle); + int init(int gpuid, char* auth_license); + int process(sy_img * batch_img, int batchsize, hp_analysis_res*& result); + int release(); + +private: + void *handle {nullptr}; +}; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/SnapShotFrameCache.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/SnapShotFrameCache.cpp deleted file mode 100644 index 1f087eb..0000000 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/SnapShotFrameCache.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include "SnapShotFrameCache.h" - -void SnapShotFrameCache::init_cache(unsigned int cache_len, unsigned int cache_count) -{ - this->cache_len = cache_len; - this->cache_count = cache_count; - alloc(); -} - -bool SnapShotFrameCache::alloc() -{ - for (size_t i = 0; i < cache_count; i++) - { - void * frame = NULL; - auto cudaStatus = cudaMalloc((void**)&frame, cache_len); - if (cudaStatus != cudaSuccess) - { - return false; - } - cache.push(frame); - } - return true; -} - -void * SnapShotFrameCache::get_frame() -{ - if (cache.empty()) - { - alloc(); - if (!cache.empty()) - { - void * frame = cache.front(); - cache.pop(); - return frame; - } - else - { - return nullptr; - } - } - else - { - void * frame = cache.front(); - cache.pop(); - return frame; - } -} - -void SnapShotFrameCache::release(void * frame) -{ - cache.push(frame); -} - -void SnapShotFrameCache::free() -{ - while (!cache.empty()) - { - void * frame = cache.front(); - cudaFree(frame); - cache.pop(); - } -} \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/SnapShotFrameCache.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/SnapShotFrameCache.h deleted file mode 100644 index c06cdbb..0000000 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/SnapShotFrameCache.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "../FFNvDecoder/DxDecoderWrap.h" -#include -#define SHOT_CACHE_SIZE -#define VEHICLE_WIDTH 320 -class SnapShotFrameCache -{ -public: - void init_cache(unsigned int cache_len, unsigned int cache_count); - void * get_frame(); - void release(void * frame); - void free(); -private: - bool alloc(); - std::queue cache; - unsigned int cache_len; - unsigned int cache_count; -}; \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.cpp index bdf9d7c..f2597d9 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.cpp @@ -1,7 +1,21 @@ #include "VehicleColor.h" -static char colorLabel[14][8] = { "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷" }; -int VehicleColor_Init(void *&handle, int gpuid, char* auth_license) +#include "../../FFNvDecoder/logger.hpp" + + +static char colorLabel[14][8] = { "妫", "姗", "鐏", "鐧", "绮", "绱", "绾", "缁", "钃", "閲", "閾", "闈", "榛", "榛" }; + +VehicleColor::VehicleColor(/* args */) +{ +} + +VehicleColor::~VehicleColor() +{ + LOG_INFO("~VehicleColor"); +} + + +int VehicleColor::init(int gpuid, char* auth_license) { vc_param params; params.mode = DEVICE_GPU; @@ -13,58 +27,36 @@ int VehicleColor_Init(void *&handle, int gpuid, char* auth_license) int ret = vc_init(&handle, params); if (ret != 0) { - cout << "Init Ret Failed!" << endl; + LOG_ERROR("vc_init failed!"); return FAILED; } + LOG_INFO("vc_init success! gpu_id: {}", gpuid); return SUCCESS; } -#include -int VehicleColor_Process(void * handle, sy_img * batch_img, int batch_size, vc_result *&result) +int VehicleColor::process(sy_img * batch_img, int batch_size, vc_result *&result) { for (int i = 0; i < batch_size; i++) { - if (batch_img[i].data_ == NULL) - cout << i << " data null" << endl; + if (batch_img[i].data_ == NULL) { + LOG_ERROR("data null"); + return FAILED; + } } - // ctools_result *result=NULL; - //cout << "begin vc ProcessBatch" << endl; - vc_batch(handle, batch_img, batch_size, result); - //cout << "end vc ProcessBatch" << endl; - - //for (int b = 0; b < batch_size; b++) - //{ - - // ctools_result &cur_result = result[b]; - // int big_class_count = cur_result.obj_count_; - - // for (int i = 0; i < cur_result.obj_count_ + 1; i++) - // { - // ctools_obj_result &index_score_1 = cur_result.obj_results_[i]; - - // /* for (int j = 0; j < index_score_1.data_count_; j++) - // printf("%.2f ", index_score_1.data_[j]); - // printf("\n");*/ - // } - - - // ctools_obj_result &index_score = cur_result.obj_results_[big_class_count]; - // float *index_score_data = index_score.data_; - // int index_count = index_score_data[0]; - // float score = index_score_data[1]; - // printf("%d-%d, %s, index = %d, score = %.2f\n", b, batch_size, colorLabel[index_count], index_count, score); - // //cudaFree(images[j].data); - //} return SUCCESS; } -int VehicleColor_Release(void *& handle) +int VehicleColor::release() { - if (handle) - vc_release(&handle); + if (handle) { + vc_release(&handle); + handle = nullptr; + } + + LOG_INFO("release."); return SUCCESS; } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.h index 55ec62e..31ec266 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleColor.h @@ -8,7 +8,16 @@ using namespace std; +class VehicleColor +{ +public: + VehicleColor(/* args */); + ~VehicleColor(); -int VehicleColor_Init(void *&handle, int gpuid, char* auth_license); -int VehicleColor_Process(void * handle, sy_img * batch_img,int batchsize, vc_result *&result); -int VehicleColor_Release(void *& handle); + int init(int gpuid, char* auth_license); + int process(sy_img * batch_img,int batchsize, vc_result *&result); + int release(); + +private: + void* handle {nullptr}; +}; \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleFeature.cpp index 2dc3d29..c6c983f 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleFeature.cpp @@ -1,11 +1,22 @@ -#include "vehicle_features.h" +#include "VehicleFeature.h" #include #include "sy_errorinfo.h" + +#include "../../FFNvDecoder/logger.hpp" + using namespace std; -void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int &height); -int vhd_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) +VehicleFeature::VehicleFeature(/* args */) +{ +} + +VehicleFeature::~VehicleFeature() +{ + LOG_INFO("~VehicleFeature"); +} + +int VehicleFeature::init_vpd(char*dbpath, int gpuid, char* auth_license) { vehicle_pendant_det_param params; params.gpuid = gpuid; @@ -13,16 +24,16 @@ int vhd_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) params.serialize_file = "./serialize_file/VPD"; params.thresld = 0.6; params.auth_license = auth_license; - if (vpd2_init(&handle, params) !=0) { - cout << "Init vhd Failed!" << endl; + if (vpd2_init(&vpd_handle, params) !=0) { + LOG_ERROR("vpd2_init failed!"); return FAILED; } + LOG_INFO("vpd2_init success! gpu_id: {}", gpuid); return SUCCESS; } - -int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) +int VehicleFeature::init_vf(char*dbpath, int gpuid, char* auth_license) { vf_param params; params.gpuid = gpuid; @@ -31,26 +42,25 @@ int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license) params.max_batch = 20; params.serialize_file = "./serialize_file/VF"; params.auth_license = auth_license; - // params.db_path = dbpath; - if (vf_init(&handle, params) !=0) - { - cout << "Init VF Failed!" << endl; + if (vf_init(&vf_handle, params) !=0) { + LOG_ERROR("vf_init failed!"); return FAILED; - } + + LOG_INFO("vf_init success! gpu_id: {}", gpuid); return SUCCESS; } - - -int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd2_result*& result) +int VehicleFeature::process_vpd(sy_img * batch_img, int batch_size, vpd2_result*& result) { for (int i = 0; i < batch_size; i++) { - if (batch_img[i].data_ == NULL) - cout << i << " data null" << endl; + if (batch_img[i].data_ == NULL) { + LOG_ERROR("data null!"); + return FAILED; + } } - vpd2_process(handle, batch_img, batch_size, result); + vpd2_process(vpd_handle, batch_img, batch_size, result); for (int b = 0; b < batch_size; b++) { @@ -64,17 +74,13 @@ int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd return SUCCESS; } - -#include -#include -#include - -int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8**& result) +int VehicleFeature::process_vf( sy_img * batch_img, int batch_size, int8**& result) { for (int i = 0; i < batch_size; i++) { - if (batch_img[i].data_ == NULL) - cout << i << " data null" << endl; + if (batch_img[i].data_ == NULL){ + LOG_ERROR("data null!"); + } } int **fea = new int*[batch_size]; @@ -83,7 +89,7 @@ int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8 fea[i] = new int[FEATURESIZE]; } - vf_feature_batch(handle, batch_img, batch_size, fea); + vf_feature_batch(vf_handle, batch_img, batch_size, fea); for (int i = 0; i < batch_size; i++) { @@ -111,27 +117,34 @@ int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8 return SUCCESS; } -int vhd_feature_release(void *& handle) +int VehicleFeature::release_vpd() { - if (handle) - vpd2_release(&handle); - return SUCCESS; + if (vpd_handle){ + vpd2_release(&vpd_handle); + vpd_handle = nullptr; + } + + LOG_INFO("release_vpd"); + return SUCCESS; } -int vf_feature_release(void *& handle) +int VehicleFeature::release_vf() { - if (handle) - vf_release(&handle); - return SUCCESS; + if (vf_handle) { + vf_release(&vf_handle); + vf_handle = nullptr; + } + + LOG_INFO("release_vf"); + return SUCCESS; } -void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int &height) +void VehicleFeature::RectboundCheck(int Width, int Height, int &left, int &top, int &width, int &height) { #ifdef _DEBUG - printf("img: Width = %d Height = %d\n", - Width, Height); - printf("Src: width = %d height = %d, x = %d, y =%d\n", Width, Height, left, top); + printf("img: Width = %d Height = %d\n", Width, Height); + printf("Src: width = %d height = %d, x = %d, y =%d\n", width, height, left, top); #endif if (left <= 0) left = 0; @@ -153,6 +166,11 @@ void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int height = Height - 1 - top; if (height <= 0) height = 0; + +#ifdef _DEBUG + printf("img: Width = %d Height = %d\n", Width, Height); + printf("Src: width = %d height = %d, x = %d, y =%d\n", width, height, left, top); +#endif } diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleFeature.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleFeature.h new file mode 100644 index 0000000..9efa4ff --- /dev/null +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleFeature.h @@ -0,0 +1,34 @@ + + +#ifndef _VEHICLEFEATURES_H_ +#define _VEHICLEFEATURES_H_ +#include "vehicle_fea_int8.h" +#include "vpd.h" + +#ifndef __INT8__ +#define __INT8__ +typedef unsigned char int8; +#endif + +class VehicleFeature { +public: + VehicleFeature(/* args */); + ~VehicleFeature(); + + int init_vpd(char*dbpath, int gpuid, char* auth_license); + int process_vpd(sy_img * batch_img, int batch_size, vpd2_result*& result); + int release_vpd(); + + int init_vf(char*dbpath, int gpuid, char* auth_license); + int process_vf( sy_img * batch_img, int batch_size, int8**& result); + int release_vf(); + +private: + void RectboundCheck(int Width, int Height, int &left, int &top, int &width, int &height); + +private: + void* vpd_handle {nullptr}; + void* vf_handle {nullptr}; +}; + +#endif diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp index 35a8f3c..7fb7639 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehiclePlate.cpp @@ -2,9 +2,18 @@ #include #include "../../FFNvDecoder/logger.hpp" -//static string type[69] = { "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "鲁", "豫", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "锟斤拷", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "锟斤拷", "学", "使", "锟斤拷" }; -int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license) + +VehiclePlate::VehiclePlate(/* args */) +{ +} + +VehiclePlate::~VehiclePlate() +{ + LOG_INFO("~VehiclePlate"); +} + +int VehiclePlate::init(int gpuid, char* auth_license) { vp_detect_param param; param.gpuid = gpuid; @@ -20,43 +29,39 @@ int VehiclePlateDetectRecog_Init(void *&handle, int gpuid, char* auth_license) param.auth_license = "sy_va_sub_sdk_2023"; int ret = vpdr_init(&handle, param, rparam); - - if (ret != 0) - { - cout << "vpdr_init Failed!" << endl; + if (ret != 0){ + LOG_ERROR("vpdr_init Failed!"); return FAILED; } + LOG_INFO("vpdr_init success! gpu_id: {}", gpuid); return SUCCESS; } -int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_plate_result *&result) +int VehiclePlate::process(sy_img * batch_img, int batchsize, vehicle_plate_result *&result) { sy_img cpu_batch_img[batchsize]; for (int i = 0; i < batchsize; i++) { - if (batch_img[i].data_ == NULL) - { + if (batch_img[i].data_ == NULL) { LOG_ERROR("data null "); return FAILED; } - cpu_batch_img[i].data_ = (unsigned char *)malloc(batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char)); - cudaMemcpy(cpu_batch_img[i].data_, batch_img[i].data_, batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char), cudaMemcpyDeviceToHost); - cpu_batch_img[i].w_ = batch_img[i].w_; - cpu_batch_img[i].h_ = batch_img[i].h_; - cpu_batch_img[i].c_ = batch_img[i].c_; + // cpu_batch_img[i].data_ = (unsigned char *)malloc(batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char)); + // cudaMemcpy(cpu_batch_img[i].data_, batch_img[i].data_, batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char), cudaMemcpyDeviceToHost); + // cpu_batch_img[i].w_ = batch_img[i].w_; + // cpu_batch_img[i].h_ = batch_img[i].h_; + // cpu_batch_img[i].c_ = batch_img[i].c_; } vehicle_plate_results * all_result = new vehicle_plate_results[batchsize] {}; - for (int i = 0; i #include "utools.h" #include + + using namespace std; +class VehicleRearRecg +{ +private: + void* handle{nullptr}; + +public: + VehicleRearRecg(/* args */); + ~VehicleRearRecg(); -int VehicleRearRecg_Init(void *&handle, char*dbpath, int gpuid, char* auth_license); -int VehicleRearRecg_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_rear_result *&vr_result); -int VehicleRearRecg_Release(void *& handle); + int init(char*dbpath, int gpuid, char* auth_license); + int process(sy_img * batch_img, int batchsize, vehicle_rear_result *&vr_result); + int release(); +}; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp index 0cdf4f0..051fcf9 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.cpp @@ -1,9 +1,23 @@ -#include "vehicle_recognition.h" +#include "VehicleRecognition.h" #include #include "sy_errorinfo.h" -#include "vehicle_features.h" + +#include "../../FFNvDecoder/logger.hpp" + + using namespace std; -int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license) + + +VehicleRecognition::VehicleRecognition(/* args */) +{ +} + +VehicleRecognition::~VehicleRecognition() +{ + LOG_INFO("~VehicleRecognition"); +} + +int VehicleRecognition::init(char*dbpath, int gpuid, char* auth_license) { vr_param params; params.gpuid = 0; @@ -16,20 +30,22 @@ int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_li params.auth_license = "sy_va_sub_sdk_2023"; int ret = vr_init(&handle, params); - if (ret != 0) - { - cout << "VR Init Failed!" << endl; + if (ret != 0) { + LOG_ERROR("vr_init failed!"); return FAILED; } + + LOG_INFO("vr_init success! gpu_id: {}", gpuid); return SUCCESS; } -int VehicleRecognition_Process(void * handle, sy_img * batch_img, int batchsize, vehicle_recog_result *&vrresult) +int VehicleRecognition::process(sy_img * batch_img, int batchsize, vehicle_recog_result *&vrresult) { - for (int i = 0; i < batchsize; i++) - { - if (batch_img[i].data_ == NULL) - cout << i << " data null" << endl; + for (int i = 0; i < batchsize; i++) { + if (batch_img[i].data_ == NULL) { + LOG_ERROR("data null "); + return FAILED; + } } vr_batch(handle, batch_img, batchsize, vrresult); @@ -37,9 +53,13 @@ int VehicleRecognition_Process(void * handle, sy_img * batch_img, int batchsize return SUCCESS; } -int VehicleRecognition_Release(void *& handle) +int VehicleRecognition::release() { - if (handle) - vr_release(&handle); + if (handle) { + vr_release(&handle); + handle = nullptr; + } + + LOG_INFO("release"); return SUCCESS; -} +} \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h index cf20b04..f30bbc4 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/VehicleRecognition.h @@ -9,7 +9,19 @@ using namespace std; +class VehicleRecognition +{ +public: + VehicleRecognition(/* args */); + ~VehicleRecognition(); + + int init(char*dbpath, int gpuid, char* auth_license); + int process(sy_img * batch_img,int batchsize, vehicle_recog_result*&vr_result); + int release(); + +private: + void* handle{nullptr}; +}; + + -int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license); -int VehicleRecognition_Process(void * handle, sy_img * batch_img,int batchsize, vehicle_recog_result*&vr_result); -int VehicleRecognition_Release(void *& handle); diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h deleted file mode 100644 index e66be18..0000000 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/non_vehicle_fea.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include "non_vehicle_fea_trt.h" -#include "utools.h" - -int NonVehicleFea_Init(void *&handle, int gpuid, char* auth_license); -int NonVehicleFea_Process(void * handle, sy_img * batch_img, int batch_size, human_fea_result*& result); -int NonVehicleFea_Release(void *& handle); \ No newline at end of file diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp index a219161..de70b32 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp @@ -1,14 +1,6 @@ #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" #include "snapshot_helper.h" -#include "HumanParsing.h" -#include "VehiclePlate.h" -#include "VehicleRecognition.h" -#include "VehicleColor.h" -#include "non_vehicle_fea.h" -//#include "HumanFeatures.h" -#include "vehicle_features.h" -#include "VehicleRearRecg.h" #include "CropImg.h" #include @@ -114,7 +106,7 @@ void snapshot_helper::snapshot_helper_init(int gpuid, double gpu_total_memory, c if (hp_analysis_cf == SY_CONFIG_OPEN || hf_recg_cf == SY_CONFIG_OPEN) { - HumanParsing_Init(hp_handle, gpuid, auth_license); + m_human_parsing.init(gpuid, auth_license); } if (hcp_analysis_cf == SY_CONFIG_OPEN || hcf_recg_cf == SY_CONFIG_OPEN) @@ -124,25 +116,24 @@ void snapshot_helper::snapshot_helper_init(int gpuid, double gpu_total_memory, c if (hf_recg_cf == SY_CONFIG_OPEN || hcf_recg_cf == SY_CONFIG_OPEN) { - NonVehicleFea_Init(nvf_handle, gpuid, auth_license); + m_human_fea.init(gpuid, auth_license); } - if (vehicle_analysis_cf == SY_CONFIG_OPEN) { - VehicleColor_Init(vc_handle, gpuid, auth_license); - VehiclePlateDetectRecog_Init(vp_handle, gpuid, auth_license); - VehicleRecognition_Init(vr_handle, dbpath_utf8, gpuid, auth_license); - VehicleRearRecg_Init(vrr_handle, dbpath, gpuid, auth_license); + m_vehicle_color.init(gpuid, auth_license); + m_vehicle_plate.init(gpuid, auth_license); + m_vehicle_recognition.init(dbpath_utf8, gpuid, auth_license); + m_vehicle_rear_recog.init(dbpath, gpuid, auth_license); } - if (vehicle_analysis_cf == SY_CONFIG_OPEN || vcf_recg_cf == SY_CONFIG_OPEN) - { - vhd_features_init(vhd_handle, dbpath_utf8, gpuid, auth_license); + + if (vehicle_analysis_cf == SY_CONFIG_OPEN || vcf_recg_cf == SY_CONFIG_OPEN) { + m_vehicle_feature.init_vpd(dbpath_utf8, gpuid, auth_license); } if (vcf_recg_cf == SY_CONFIG_OPEN) { - vf_features_init(vf_handle, dbpath_utf8, gpuid, auth_license); + m_vehicle_feature.init_vf(dbpath_utf8, gpuid, auth_license); } @@ -174,15 +165,15 @@ void snapshot_helper::snapshot_helper_init(int gpuid, double gpu_total_memory, c void snapshot_helper::snapshot_helper_release() { m_bExit = true; - HumanParsing_Release(hp_handle); + m_human_parsing.release(); m_human_car_parsing.release(); - VehicleColor_Release(vc_handle); - VehiclePlateDetectRecog_Release(vp_handle); - VehicleRecognition_Release(vr_handle); - VehicleRearRecg_Release(vrr_handle); - vhd_feature_release(vhd_handle); - vf_feature_release(vf_handle); - NonVehicleFea_Release(nvf_handle); + m_vehicle_color.release(); + m_vehicle_plate.release(); + m_vehicle_recognition.release(); + m_vehicle_rear_recog.release(); + m_vehicle_feature.release_vpd(); + m_vehicle_feature.release_vf(); + m_human_fea.release(); if (batch_hp != NULL) { @@ -515,16 +506,12 @@ void snapshot_helper::finish_task_ss_analysis(int task_id) //鏄 if (hp_analysis_cf == SY_CONFIG_OPEN) { result = new hp_analysis_res[hp_batch_count]{}; - //TimeCounting t("HumanParsing_Process"); - HumanParsing_Process(hp_handle, finish_hp_img, hp_batch_count, result); + m_human_parsing.process(finish_hp_img, hp_batch_count, result); } - if (hf_recg_cf == SY_CONFIG_OPEN) - { + if (hf_recg_cf == SY_CONFIG_OPEN) { result_f = new human_fea_result[hp_batch_count]{}; - - //TimeCounting t("NonVehicleFea_Process"); - NonVehicleFea_Process(nvf_handle, finish_hp_img, hp_batch_count, result_f); + m_human_fea.process(finish_hp_img, hp_batch_count, result_f); } int resIndex = 0; for (int k = 0; k < hp_batch_count; k++) @@ -621,11 +608,9 @@ void snapshot_helper::finish_task_ss_analysis(int task_id) //鏄 m_human_car_parsing.process(finish_hcp_img, hcp_batch_count, result); } - if (hcf_recg_cf == SY_CONFIG_OPEN) - { + if (hcf_recg_cf == SY_CONFIG_OPEN) { result_f = new human_fea_result[hcp_batch_count]{}; - //TimeCounting t("NonVehicleFea_Process"); - NonVehicleFea_Process(nvf_handle, finish_hcp_img, hcp_batch_count, result_f); + m_human_fea.process(finish_hcp_img, hcp_batch_count, result_f); } int resIndex = 0; @@ -720,11 +705,8 @@ void snapshot_helper::finish_task_ss_analysis(int task_id) //鏄 vehicle_plate_result *vp_result = new vehicle_plate_result[det_batch_size]{}; vr_result *vrresult = new vr_result[det_batch_size]{}; if (vehicle_analysis_cf == SY_CONFIG_OPEN) { - if(det_batch_size == 3) { - printf("batchsize: %d \n", det_batch_size); - } - VehicleColor_Process(vc_handle, finish_vehicle_img, det_batch_size, vcresult); - VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, det_batch_size, vp_result); + m_vehicle_color.process(finish_vehicle_img, det_batch_size, vcresult); + m_vehicle_plate.process(finish_vehicle_img, det_batch_size, vp_result); VehicleRecog_Process(finish_vehicle_img, det_batch_size, vrresult, det_vehicle_keys.data()); } @@ -735,7 +717,7 @@ void snapshot_helper::finish_task_ss_analysis(int task_id) //鏄 fea[ii] = new int8[FEATURESIZE]{}; } - vf_features_process(vf_handle, finish_vehicle_img, det_batch_size, fea); + m_vehicle_feature.process_vf(finish_vehicle_img, det_batch_size, fea); } int feaIndex = 0; @@ -885,18 +867,14 @@ void snapshot_helper::hp_analysis() } //绠楁硶鍒嗘瀽 - if (hp_analysis_cf == SY_CONFIG_OPEN) - { + if (hp_analysis_cf == SY_CONFIG_OPEN) { result = new hp_analysis_res[obj_batch_count]{}; - //TimeCounting t("HumanParsing_Process"); - HumanParsing_Process(hp_handle, batch_hp, obj_batch_count, result); + m_human_parsing.process(batch_hp, obj_batch_count, result); } - if (hf_recg_cf == SY_CONFIG_OPEN) - { + if (hf_recg_cf == SY_CONFIG_OPEN) { result_f = new human_fea_result[obj_batch_count]{}; - //TimeCounting t("NonVehicleFea_Process"); - NonVehicleFea_Process(nvf_handle, batch_hp, obj_batch_count, result_f); + m_human_fea.process(batch_hp, obj_batch_count, result_f); } //鍒犻櫎宸茬粡杩涜淇濆瓨鍜屼簩娆″睘鎬у垎鏋愮殑鐩爣 @@ -1003,11 +981,9 @@ void snapshot_helper::hcp_analysis() m_human_car_parsing.process(batch_hcp, obj_batch_count, result); } - if (hcf_recg_cf == SY_CONFIG_OPEN) - { + if (hcf_recg_cf == SY_CONFIG_OPEN) { result_f = new human_fea_result[obj_batch_count]{}; - //TimeCounting t("NonVehicleFea_Process"); - NonVehicleFea_Process(nvf_handle, batch_hcp, obj_batch_count, result_f); + m_human_fea.process(batch_hcp, obj_batch_count, result_f); } int resIndex = 0; @@ -1113,10 +1089,7 @@ bool snapshot_helper::vehicle_color_analysis() } vc_result *vcresult = new vc_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; - { - //TimeCounting t("VehicleColor_Process"); - VehicleColor_Process(vc_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vcresult); - } + m_vehicle_color.process(batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vcresult); for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++) { @@ -1195,7 +1168,7 @@ bool snapshot_helper::vehicle_plate_dr_analysis() batch_vehicle[i].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame); } vehicle_plate_result *vp_result = new vehicle_plate_result[cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/]{}; - VehiclePlateDetectRecog_Process(vp_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vp_result); + m_vehicle_plate.process(batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vp_result); int resIndex = 0; for (int i = 0; i < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; i++) @@ -1242,7 +1215,7 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr { vhd_res[b].vpd_res = new vpd_info[OBJ_MAX_COUNT]; } - vhd_features_process(vhd_handle, batch_img, batchsize, vhd_res); + m_vehicle_feature.process_vpd(batch_img, batchsize, vhd_res); for (int vc_idx = 0; vc_idx < batchsize; vc_idx++) { @@ -1323,7 +1296,7 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr { LOG_DEBUG("index_head : {}", index_head); vehicle_recog_result *vrresult = new vehicle_recog_result[index_head]{}; - VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult); + m_vehicle_recognition.process(batch_vehicle_head, index_head, vrresult); int resIndex = 0; @@ -1339,7 +1312,7 @@ void snapshot_helper::VehicleRecog_Process(sy_img * batch_img, int batchsize, vr if (index_rear != 0) { vehicle_rear_result *vrresult = new vehicle_rear_result[index_rear]{}; - VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult); + m_vehicle_rear_recog.process(batch_vehicle_rear, index_rear, vrresult); int resIndex = 0; for (auto & item : mp_rear) @@ -1447,7 +1420,8 @@ bool snapshot_helper::vehicle_recg_analysis() { vhd_res[b].vpd_res = new vpd_info[OBJ_MAX_COUNT]; } - vhd_features_process(vhd_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vhd_res); + + m_vehicle_feature.process_vpd(batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, vhd_res); for (int vc_idx = 0; vc_idx < cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/; vc_idx++) { @@ -1528,7 +1502,7 @@ bool snapshot_helper::vehicle_recg_analysis() if (index_head != 0) { vehicle_recog_result *vrresult = new vehicle_recog_result[index_head]{}; - VehicleRecognition_Process(vr_handle, batch_vehicle_head, index_head, vrresult); + m_vehicle_recognition.process(batch_vehicle_head, index_head, vrresult); int resIndex = 0; for (auto & item : mp_head) @@ -1549,7 +1523,7 @@ bool snapshot_helper::vehicle_recg_analysis() if (index_rear != 0) { vehicle_rear_result *vrresult = new vehicle_rear_result[index_rear]{}; - VehicleRearRecg_Process(vrr_handle, batch_vehicle_rear, index_rear, vrresult); + m_vehicle_rear_recog.process(batch_vehicle_rear, index_rear, vrresult); int resIndex = 0; for (auto & item : mp_rear) @@ -1609,10 +1583,7 @@ bool snapshot_helper::vehicle_recg_analysis() memset(fea[i], 0, sizeof(int8) * FEATURESIZE); } - { - //TimeCounting t("vf_features_process"); - vf_features_process(vf_handle, batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, fea); - } + m_vehicle_feature.process_vf(batch_vehicle, cur_batchsize/*OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE*/, fea); int resIndex = 0; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h index cdc40bf..13c93a2 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h @@ -11,6 +11,14 @@ #include #include "ImageSaveCache.h" #include "HumanCarParsing.h" +#include "HumanParsing.h" +#include "HumanFea.h" +#include "VehicleFeature.h" +#include "VehiclePlate.h" +#include "VehicleColor.h" +#include "VehicleRearRecg.h" +#include "VehicleRecognition.h" + using namespace std; #define EDGESIZE 4 @@ -33,9 +41,6 @@ using namespace std; #define FALSE 0 #endif - - - #define Sleep(a) usleep((a)*1000) //typedef int BOOL; #define BOOL bool @@ -182,7 +187,6 @@ private: int save_snapshot(bool is_image, bool on_image_display, OBJ_KEY obj_key, char* filename, char* mode, unsigned char* imgData, int width, int height, int taskID, int objID, int recFlag, int left, int top, int right, int bottom); int save_snapshot(OBJ_KEY obj_key); int save_face_snapshot(OBJ_KEY obj_key); - void save_without_analysis(OBJ_KEY obj_key); //閽堝杞︽媶寮鐨勪簩娆″睘鎬у垎鏋 @@ -190,6 +194,13 @@ private: private: HumanCarParsing m_human_car_parsing; + HumanParsing m_human_parsing; + HumanFea m_human_fea; + VehicleFeature m_vehicle_feature; + VehicleColor m_vehicle_color; + VehiclePlate m_vehicle_plate; + VehicleRearRecg m_vehicle_rear_recog; + VehicleRecognition m_vehicle_recognition; queue count_person; queue count_bike; @@ -203,15 +214,7 @@ private: sy_img * batch_hcp = nullptr; sy_img * batch_vehicle = nullptr; sy_img * batch_vehicle_vf = nullptr; - - void * hp_handle = nullptr; - void * vc_handle = nullptr; - void * vp_handle = nullptr; - void * vr_handle = nullptr; - void * vrr_handle = nullptr; - void * nvf_handle = nullptr; - void * vhd_handle = nullptr; - void * vf_handle = nullptr; + sy_command hp_analysis_cf; sy_command hcp_analysis_cf; sy_command vehicle_analysis_cf; @@ -222,9 +225,6 @@ private: sy_command vehicle_plate_det_recg_cf; sy_command face_detect_cf; - void * hf_handle = nullptr; - void * hcf_handle = nullptr; - int count_vehivle_finishanalysis = 0; int OBJ_SCALE = 2; int OBJ_BATCH_COUNT = 0; diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h deleted file mode 100644 index 6753921..0000000 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/vehicle_features.h +++ /dev/null @@ -1,25 +0,0 @@ - - -#ifndef _VEHICLEFEATURES_H_ -#define _VEHICLEFEATURES_H_ -#include "vehicle_fea_int8.h" -#include "vpd.h" - -#ifndef __INT8__ -#define __INT8__ -typedef unsigned char int8; -#endif - -int vhd_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license); - -int vf_features_init(void *&handle, char*dbpath, int gpuid, char* auth_license); - -int vhd_features_process(void * handle, sy_img * batch_img, int batch_size, vpd2_result*& result); - -int vf_features_process(void * handle, sy_img * batch_img, int batch_size, int8**& result); - -int vhd_feature_release(void *& handle); - -int vf_feature_release(void *& handle); - -#endif