Commit dce94814c6d00e95f07ba7877ff13fff259965e3
1 parent
3eab27ba
同步windows代码
Showing
17 changed files
with
182 additions
and
65 deletions
.vscode/launch.json
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | "type": "cppdbg", |
7 | 7 | "request": "launch", |
8 | 8 | "program": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512/test", |
9 | - "args": ["file:///home/cmhu/data/video/Street.uvf","1","0","./db/mvpt.bin"], | |
9 | + "args": ["file:///home/cmhu/data/video/Street.uvf","2","0","./db/mvpt.bin"], | |
10 | 10 | "stopAtEntry": false, |
11 | 11 | "cwd": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512", |
12 | 12 | "environment": [], | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile
... | ... | @@ -60,7 +60,7 @@ INCLUDE= -I $(OPENCV_ROOT)/include/opencv4 \ |
60 | 60 | |
61 | 61 | LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ |
62 | 62 | -L/usr/lib/x86_64-linux-gnu -lnvcuvid \ |
63 | - -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler \ | |
63 | + -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lSfxTranscoder -lSfxLog -lSfxHttpServer -lSfxNetwork\ | |
64 | 64 | -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lface_detect -lvehicle_recognize -lvehicle_color -lhuman_parsing -lhuman_car_parsing -lnon_vehicle_fea_trt -lvehicle_rear_recognition -lvehicle_fea_int8 -lvehicle_plate_dr -lvpd2 \ |
65 | 65 | -L$(UTOOLS_SSD_ROOT) -l:libutools.so \ |
66 | 66 | -L$(DEPEND_DIR)/lib -l:liblibjasper.a -l:libIlmImf.a -l:liblibjpeg.a -l:liblibtiff.a -l:liblibpng.a \ |
... | ... | @@ -70,7 +70,7 @@ LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ |
70 | 70 | -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \ |
71 | 71 | |
72 | 72 | |
73 | -CFLAGS_LIB=-g -O2 -Wall -Wno-deprecated $(DEFS) -lz -ldl -lpthread -fPIC -fvisibility=hidden -Wl,-Bsymbolic | |
73 | +CFLAGS_LIB=-g -O0 -Wall -Wno-deprecated $(DEFS) -lz -ldl -lpthread -fPIC -fvisibility=hidden -Wl,-Bsymbolic | |
74 | 74 | CFLAGS = $(CFLAGS_LIB) $(INCLUDE) -std=c++11 -DUSE_CUDNN |
75 | 75 | # -DUNICODE -D_UNICODE |
76 | 76 | NFLAGS_LIB=-g -c $(DEFS) -shared -Xcompiler -fPIC -Xcompiler -fvisibility=hidden | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/SfxDecoder/DxDecoderWrap.cpp
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | #include "ColorSpace.h" |
5 | 5 | |
6 | 6 | #include "sfx_depend_inc.h" |
7 | +#include "opencv2/opencv.hpp" | |
7 | 8 | |
8 | 9 | #include <iostream> |
9 | 10 | |
... | ... | @@ -58,7 +59,11 @@ bool DxDecoderWrap::isStream(string sVideoFileName) { |
58 | 59 | if (pos == 0) { |
59 | 60 | int n = target.size(); |
60 | 61 | sVideoFileName = sVideoFileName.erase(pos, n); |
62 | + }else { | |
63 | + // 非file 开头,直接判为视频流 | |
64 | + return true; | |
61 | 65 | } |
66 | + | |
62 | 67 | pos = sVideoFileName.find_first_of('?'); |
63 | 68 | if (pos != string::npos) { |
64 | 69 | sVideoFileName = sVideoFileName.substr(0, pos); |
... | ... | @@ -78,9 +83,13 @@ bool DxDecoderWrap::isStream(string sVideoFileName) { |
78 | 83 | |
79 | 84 | int DxDecoderWrap::DxOpenDecoder(const DxConfig& cfg) |
80 | 85 | { |
86 | + cout << "before check: " << cfg.uri << endl; | |
87 | + | |
81 | 88 | //判断是否为实时流 |
82 | 89 | m_bReal = isStream(cfg.uri); |
83 | 90 | |
91 | + cout << "before check: " << cfg.uri << endl; | |
92 | + | |
84 | 93 | m_nums = 0; |
85 | 94 | m_bPause = false; |
86 | 95 | |
... | ... | @@ -93,6 +102,8 @@ int DxDecoderWrap::DxOpenDecoder(const DxConfig& cfg) |
93 | 102 | m_cfg.userPtr = this; |
94 | 103 | m_cfg.escbk = CUDADecoder_Callback; |
95 | 104 | m_cfg.logcbk = DecoderLog_Callback; |
105 | + m_cfg.log_all = cfg.log_all; | |
106 | + m_cfg.log_user_ptr = cfg.log_user_ptr; | |
96 | 107 | m_cfg.devId = cfg.devId; |
97 | 108 | m_cfg.uri = cfg.uri; |
98 | 109 | m_cfg.dec_name = cfg.name; |
... | ... | @@ -101,6 +112,8 @@ int DxDecoderWrap::DxOpenDecoder(const DxConfig& cfg) |
101 | 112 | m_name = cfg.name; |
102 | 113 | m_devId = cfg.devId; |
103 | 114 | |
115 | + cout << "before open: " << m_cfg.uri << endl; | |
116 | + | |
104 | 117 | bool bRet= m_pDec->OpenDecoder(m_cfg); |
105 | 118 | if (bRet) |
106 | 119 | { |
... | ... | @@ -285,7 +298,29 @@ void DxDecoderWrap::DxCUDADecoderCallback( void * buf, unsigned int size, int wi |
285 | 298 | return ; |
286 | 299 | } |
287 | 300 | |
288 | - Nv12ToColor24<BGR24>((unsigned char*)buf, width, pHwData, 3 * width, width, height, 0); | |
301 | + // Nv12ToColor24<BGR24>((unsigned char*)buf, m_width, pHwData, 3 * m_width, m_width, m_height, 0); | |
302 | + | |
303 | + | |
304 | + cudaStatus = cudaMemcpy(pHwData, buf, rgbSize * sizeof(unsigned char), cudaMemcpyDeviceToDevice); | |
305 | + | |
306 | + | |
307 | + // int rgb_size = 3 * m_width * m_height; | |
308 | + // unsigned char* cpu_data = new unsigned char[rgb_size]; | |
309 | + // cudaStatus = cudaMemcpy(cpu_data, pHwData, rgb_size * sizeof(unsigned char), cudaMemcpyDeviceToHost); | |
310 | + | |
311 | + // if (timestamp > 245 && timestamp < 255) | |
312 | + // { | |
313 | + // string file_name = "./nv12/"+to_string(timestamp) + ".txt"; | |
314 | + // FILE* fp=fopen(file_name.c_str(),"wb"); | |
315 | + // fwrite(cpu_data, rgb_size, 1, fp); | |
316 | + // fclose(fp); | |
317 | + // } | |
318 | + | |
319 | + // cv::Mat img(m_height, m_width, CV_8UC3, cpu_data); | |
320 | + // cv::imwrite("test.jpg", img); | |
321 | + // delete[] cpu_data; | |
322 | + // cpu_data = nullptr; | |
323 | + | |
289 | 324 | |
290 | 325 | DxGPUFrame frame; |
291 | 326 | frame.width = m_width; |
... | ... | @@ -309,7 +344,7 @@ void DxDecoderWrap::DxCUDADecoderCallback( void * buf, unsigned int size, int wi |
309 | 344 | return; |
310 | 345 | } |
311 | 346 | |
312 | - std::cout << "waiting queue " << frame_nb << std::endl; | |
347 | + // std::cout << "waiting queue " << frame_nb << std::endl; | |
313 | 348 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
314 | 349 | } |
315 | 350 | } | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/SfxDecoder/DxDecoderWrap.h
... | ... | @@ -27,6 +27,9 @@ typedef struct DxConfig |
27 | 27 | int skip_frame; |
28 | 28 | |
29 | 29 | string uri; |
30 | + | |
31 | + LOG_ALL_CALLBACK log_all; | |
32 | + void* log_user_ptr; | |
30 | 33 | }DxConfig; |
31 | 34 | |
32 | 35 | typedef struct DxGPUFrame |
... | ... | @@ -78,7 +81,7 @@ public: |
78 | 81 | public: |
79 | 82 | string GetName() {return m_name;}; |
80 | 83 | bool isStream(string sVideoFileName); |
81 | - | |
84 | + | |
82 | 85 | void DxCUDADecoderCallback(void * buf, unsigned int size, int width, int height, unsigned long long timestamp ); |
83 | 86 | int DxDecoderLogCallback(DxLogLevel level, const char * log, unsigned int logLen ); |
84 | 87 | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/SfxDecoder/SfxDecoder.cpp
... | ... | @@ -2,9 +2,14 @@ |
2 | 2 | |
3 | 3 | #include <thread> |
4 | 4 | #include <chrono> |
5 | +#include <iostream> | |
5 | 6 | |
6 | 7 | #include "sfx_depend_inc.h" |
7 | 8 | |
9 | +#include "cuda_kernels.h" | |
10 | +#include <fstream> | |
11 | +#include <iostream> | |
12 | + | |
8 | 13 | using namespace std; |
9 | 14 | |
10 | 15 | SfxDecoder::SfxDecoder( ) |
... | ... | @@ -42,13 +47,15 @@ bool SfxDecoder::OpenDecoder(DxDecoderConfig& cfg) |
42 | 47 | sfx_cfg->flags.useFastDecode = 0; |
43 | 48 | sfx_cfg->flags.accelId = m_cfg.devId; |
44 | 49 | sfx_cfg->flags.frameNumber = 1; |
45 | - sfx_cfg->flags.fmt = SFX_VIDEO_FORMAT_NV12U8; | |
46 | - //sfx_cfg->flags.fmt = SFX_VIDEO_FORMAT_C3BGRU8; | |
50 | + // sfx_cfg->flags.fmt = SFX_VIDEO_FORMAT_NV12U8; | |
51 | + sfx_cfg->flags.fmt = SFX_VIDEO_FORMAT_C3BGRU8; | |
47 | 52 | |
48 | 53 | m_handler = SfxStreamHandlerInterface::SfxGetInstance(sfx_cfg); |
49 | 54 | |
50 | 55 | m_dec_name = m_cfg.dec_name; |
51 | 56 | |
57 | + cout << "open: " << m_cfg.uri << endl; | |
58 | + | |
52 | 59 | int nRet = m_handler->SfxOpenStreamHandler( m_cfg.uri.c_str() ); |
53 | 60 | if (nRet != 0) { |
54 | 61 | m_bRun = false; |
... | ... | @@ -63,10 +70,12 @@ bool SfxDecoder::OpenDecoder(DxDecoderConfig& cfg) |
63 | 70 | |
64 | 71 | int SfxDecoder::CloseDecoder() |
65 | 72 | { |
66 | - m_handler->SfxCloseStreamHandler(); | |
67 | - while (m_bRun) | |
68 | - { | |
69 | - std::this_thread::sleep_for(std::chrono::milliseconds(250)); | |
73 | + if (sfx_null != m_handler) { // linux待同步 | |
74 | + m_handler->SfxCloseStreamHandler(); | |
75 | + while (m_bRun) | |
76 | + { | |
77 | + std::this_thread::sleep_for(std::chrono::milliseconds(250)); | |
78 | + } | |
70 | 79 | } |
71 | 80 | |
72 | 81 | return 0; |
... | ... | @@ -128,9 +137,7 @@ sfx_32 SfxDecoder::SfxLogDefaultHandler( |
128 | 137 | sfx_u32 logLen |
129 | 138 | ) |
130 | 139 | { |
131 | - SfxDecoder * pThis = sfx_null; | |
132 | - | |
133 | - pThis = ( SfxDecoder * )userPtr; | |
140 | + SfxDecoder * pThis = ( SfxDecoder * )userPtr; | |
134 | 141 | |
135 | 142 | if ( SFX_LOG_LEVEL_IMPORTANT == level) //modify by zsh 220602 |
136 | 143 | { |
... | ... | @@ -138,19 +145,17 @@ sfx_32 SfxDecoder::SfxLogDefaultHandler( |
138 | 145 | return 0; |
139 | 146 | } |
140 | 147 | |
141 | - | |
142 | 148 | if ( SFX_LOG_LEVEL_CLEANUP == level ) |
143 | 149 | { |
144 | 150 | pThis->m_bRun = sfx_false; |
145 | 151 | if ( pThis->m_cfg.logcbk ) |
146 | 152 | { |
147 | - pThis->m_cfg.logcbk( | |
148 | - pThis->m_cfg.userPtr, | |
149 | - DX_LOG_LEVEL_CLEANUP, | |
150 | - "DxDecoder[CUDA] module exited..", | |
151 | - 0 | |
152 | - ); | |
153 | + pThis->m_cfg.logcbk( pThis->m_cfg.userPtr, DX_LOG_LEVEL_CLEANUP, "DxDecoder[CUDA] module exited..", 0 ); | |
153 | 154 | } |
155 | + } | |
156 | + else if (pThis->m_cfg.log_all) | |
157 | + { | |
158 | + pThis->m_cfg.log_all(pThis->m_cfg.log_user_ptr, (int)level, log, logLen); | |
154 | 159 | } |
155 | 160 | |
156 | 161 | return 0; | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/SfxDecoder/SfxDecoder.h
... | ... | @@ -21,12 +21,17 @@ typedef enum DxLogLevel |
21 | 21 | typedef int (*DxLogHandler)( const void * userPtr, DxLogLevel level, const char * log, unsigned int logLen ); |
22 | 22 | |
23 | 23 | |
24 | +typedef void(*LOG_ALL_CALLBACK)(const void * userPtr, int log_level, const char* log, unsigned int logLen); | |
25 | + | |
26 | + | |
24 | 27 | typedef void (*DXDECODER_CALLBACK)( const void * userPtr, void * buf, unsigned int size, int width, int height, unsigned long long timestamp ); |
25 | 28 | |
26 | 29 | |
27 | 30 | typedef struct DxDecoderConfig |
28 | 31 | { |
29 | 32 | DxLogHandler logcbk; // 日志回调接口 |
33 | + LOG_ALL_CALLBACK log_all{nullptr}; | |
34 | + void* log_user_ptr{nullptr}; | |
30 | 35 | const void * userPtr; // 用户数据 |
31 | 36 | DXDECODER_CALLBACK escbk; // 解码后帧数据回调接口 |
32 | 37 | int devId; | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/SfxDecoder/SfxEnv.hpp
0 → 100644
1 | +#include "SfxStreamHandlerInterface.h" | |
2 | + | |
3 | + | |
4 | +using namespace std; | |
5 | + | |
6 | +class SfxEnv { | |
7 | +public: | |
8 | + static void init(){ | |
9 | + static SfxEnv* singleton = nullptr; | |
10 | + if (singleton == nullptr){ | |
11 | + singleton = new SfxEnv(); | |
12 | + } | |
13 | + return ; | |
14 | + } | |
15 | + | |
16 | +private: | |
17 | + SfxEnv(){ | |
18 | + SfxStreamHandlerInterface::SfxInitialize(100); | |
19 | + } | |
20 | + | |
21 | + ~SfxEnv(){ | |
22 | + SfxStreamHandlerInterface::SfxUninitialize(); | |
23 | + } | |
24 | +}; | |
0 | 25 | \ No newline at end of file | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp
... | ... | @@ -13,6 +13,7 @@ |
13 | 13 | |
14 | 14 | #include "../utils/logger.hpp" |
15 | 15 | #include "../cuda_src/CropImg.h" |
16 | +#include "../SfxDecoder/SfxEnv.hpp" | |
16 | 17 | |
17 | 18 | |
18 | 19 | #define AUTHORIZATION |
... | ... | @@ -101,9 +102,9 @@ int CMutliSourceVideoProcess::FinishProcessThread() |
101 | 102 | AI_LOG_LEVEL_WARNING = 3, // 警告日志通知,模块一切正常(如:重要流程通知) |
102 | 103 | AI_LOG_LEVEL_ERROR = 4, // 重要日志,如结果和严重错误 |
103 | 104 | */ |
104 | -int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_INFO_CALLBACK tObjInfoCallbackFunc, VIDEO_FINISH_CALLBACK tFinishCallbackFunc) | |
105 | +int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_INFO_CALLBACK tObjInfoCallbackFunc) | |
105 | 106 | { |
106 | - set_default_logger(LogLevel(1), "multi_source_process", "logs/main.log", 64 * 1024 * 1024, 30); | |
107 | + set_default_logger(LogLevel(vptParam.serviceID), vptParam.name, vptParam.path, 64 * 1024 * 1024, 30); | |
107 | 108 | |
108 | 109 | licence_status = -1; |
109 | 110 | thrd_status = -1; |
... | ... | @@ -127,6 +128,7 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN |
127 | 128 | return AUTHOR_ERROR; |
128 | 129 | } |
129 | 130 | |
131 | + SfxEnv::init(); | |
130 | 132 | |
131 | 133 | cuInit(0); |
132 | 134 | int device_count = 0; |
... | ... | @@ -164,10 +166,6 @@ int CMutliSourceVideoProcess::InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_IN |
164 | 166 | |
165 | 167 | viewTaskID = -1; |
166 | 168 | TotalTask = 0; |
167 | - | |
168 | - taskFinishCallbackFunc = nullptr; | |
169 | - if (tFinishCallbackFunc != nullptr) | |
170 | - taskFinishCallbackFunc = std::bind(tFinishCallbackFunc, this, std::placeholders::_1); | |
171 | 169 | |
172 | 170 | taskObjInfoCallbackFunc = nullptr; |
173 | 171 | if (tObjInfoCallbackFunc != nullptr) |
... | ... | @@ -242,9 +240,9 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) |
242 | 240 | task.taskTcuvid = NULL; |
243 | 241 | |
244 | 242 | //回调通知上层任务结束 |
245 | - if (taskFinishCallbackFunc != nullptr) { | |
243 | + if (task.taskFinishCallbackFunc != nullptr) { | |
246 | 244 | std::lock_guard<std::mutex> l(m_snaphot_helper.callback_tx); |
247 | - taskFinishCallbackFunc(task.taskID); | |
245 | + task.taskFinishCallbackFunc(task.taskID); | |
248 | 246 | } |
249 | 247 | |
250 | 248 | LOG_INFO("task {} is finished. timeusing: {}", taskID, get_cur_time_ms() - task.timestamp); |
... | ... | @@ -329,6 +327,8 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh |
329 | 327 | return false; |
330 | 328 | } |
331 | 329 | |
330 | + cout << "AddTask: " << new_task.taskFileSource << endl; | |
331 | + | |
332 | 332 | DxConfig cfg = { 0 }; |
333 | 333 | cfg.devId = mgpuid; |
334 | 334 | cfg.forceTcp = false; |
... | ... | @@ -336,6 +336,8 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh |
336 | 336 | cfg.name = std::to_string(new_task.taskID); |
337 | 337 | cfg.skip_frame = skip_frame_; |
338 | 338 | cfg.uri = new_task.taskFileSource; |
339 | + cfg.log_all = (LOG_ALL_CALLBACK)tparam.log; | |
340 | + cfg.log_user_ptr = tparam.userPtr; | |
339 | 341 | if (new_task.taskTcuvid->DxOpenDecoder(cfg) != 0) |
340 | 342 | { |
341 | 343 | cout << "Add Task Failed! Please check you video file name!" << endl; |
... | ... | @@ -353,11 +355,15 @@ bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh |
353 | 355 | |
354 | 356 | new_task.taskObjCallbackFunc = nullptr; |
355 | 357 | if (objCallbackFunc != nullptr) |
356 | - new_task.taskObjCallbackFunc = std::bind(objCallbackFunc, this, std::placeholders::_1); | |
358 | + new_task.taskObjCallbackFunc = std::bind(objCallbackFunc, tparam.userPtr, std::placeholders::_1); | |
357 | 359 | |
358 | 360 | new_task.taskRealTimeCallbackFunc = nullptr; |
359 | 361 | if (realTimeCallbackFunc != nullptr) |
360 | - new_task.taskRealTimeCallbackFunc = std::bind(realTimeCallbackFunc, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); | |
362 | + new_task.taskRealTimeCallbackFunc = std::bind(realTimeCallbackFunc, tparam.userPtr, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); | |
363 | + | |
364 | + new_task.taskFinishCallbackFunc = nullptr; | |
365 | + if (tparam.tFinishCallbackFunc != nullptr) | |
366 | + new_task.taskFinishCallbackFunc = std::bind(tparam.tFinishCallbackFunc, tparam.userPtr, std::placeholders::_1); | |
361 | 367 | |
362 | 368 | if (resultFolderLittle == NULL) |
363 | 369 | { |
... | ... | @@ -459,9 +465,14 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) |
459 | 465 | newOper.decMode = tparam.decMode; |
460 | 466 | newOper.taskObjCallbackFunc = tparam.obj_snapshot_callback_func; |
461 | 467 | newOper.taskRealTimeCallbackFunc = tparam.rt_view_callback_func; |
468 | + newOper.tFinishCallbackFunc = tparam.tFinishCallbackFunc; | |
469 | + newOper.taskSfxLogFunc = tparam.log; | |
470 | + newOper.logUserPtr = tparam.userPtr; | |
462 | 471 | memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE); |
463 | 472 | TaskOperatorQ.push_back(newOper); |
464 | 473 | taskCondVar.wait_for(l, std::chrono::seconds(20)); |
474 | + | |
475 | + cout << "AddOperator: " << newOper.videoFileName << endl; | |
465 | 476 | } |
466 | 477 | |
467 | 478 | int addRes = -1; |
... | ... | @@ -534,7 +545,13 @@ void CMutliSourceVideoProcess::OperatorTask() |
534 | 545 | memcpy(tparam.minBoxsize, newOperator.minBoxsize, sizeof(sy_rect)* DETECTTYPE); |
535 | 546 | tparam.obj_snapshot_callback_func = newOperator.taskObjCallbackFunc; |
536 | 547 | tparam.rt_view_callback_func = newOperator.taskRealTimeCallbackFunc; |
548 | + tparam.tFinishCallbackFunc = newOperator.tFinishCallbackFunc; | |
537 | 549 | tparam.decMode = newOperator.decMode; |
550 | + tparam.log = newOperator.taskSfxLogFunc; | |
551 | + tparam.userPtr = newOperator.logUserPtr; | |
552 | + | |
553 | + cout << "before AddTask: " << tparam.video_filename << endl; | |
554 | + | |
538 | 555 | AddTask(tparam); |
539 | 556 | } |
540 | 557 | break; | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h
... | ... | @@ -99,7 +99,11 @@ struct Operator{ |
99 | 99 | TaskOperator changeTaskOperator; |
100 | 100 | VIDEO_OBJECT_SNAPSHOT_CALLBACK taskObjCallbackFunc; |
101 | 101 | VIDEO_REALTIME_CALLBACK taskRealTimeCallbackFunc; |
102 | + VIDEO_FINISH_CALLBACK tFinishCallbackFunc; | |
102 | 103 | sy_rect minBoxsize[DETECTTYPE]; |
104 | + | |
105 | + SFX_LOG_CALLBACK taskSfxLogFunc; | |
106 | + void* logUserPtr; | |
103 | 107 | }; |
104 | 108 | |
105 | 109 | |
... | ... | @@ -109,7 +113,7 @@ public: |
109 | 113 | CMutliSourceVideoProcess(); |
110 | 114 | ~CMutliSourceVideoProcess(); |
111 | 115 | |
112 | - int InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_INFO_CALLBACK tObjInfoCallbackFunc, VIDEO_FINISH_CALLBACK tFinishCallbackFunc); | |
116 | + int InitAlgorthim(mvpt_param vptParam, VIDEO_OBJECT_INFO_CALLBACK tObjInfoCallbackFunc); | |
113 | 117 | |
114 | 118 | int get_task_progress(int taskid, double & progress); |
115 | 119 | void OperatorTask(); |
... | ... | @@ -140,8 +144,7 @@ public: |
140 | 144 | |
141 | 145 | int viewTaskID; |
142 | 146 | |
143 | - FINISH_CALLBACK taskFinishCallbackFunc; | |
144 | - OBJECT_INFO_CALLBACK taskObjInfoCallbackFunc; | |
147 | + OBJECT_INFO_CALLBACK taskObjInfoCallbackFunc {nullptr}; | |
145 | 148 | |
146 | 149 | std::mutex taskMutex; |
147 | 150 | std::condition_variable taskCondVar; | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/VPTProcess.cpp
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/common.h
... | ... | @@ -86,6 +86,7 @@ struct Task{ |
86 | 86 | int taskTotalFrameCount{1}; |
87 | 87 | SNAPSHOT_CALLBACK taskObjCallbackFunc; |
88 | 88 | REALTIME_CALLBACK taskRealTimeCallbackFunc; |
89 | + FINISH_CALLBACK taskFinishCallbackFunc{nullptr}; | |
89 | 90 | cv::Mat frameImage; |
90 | 91 | char* folderNameLittle; |
91 | 92 | char* folderName; | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/header.h
... | ... | @@ -85,6 +85,7 @@ typedef struct vplate_num |
85 | 85 | { |
86 | 86 | char character[4]; |
87 | 87 | float maxprob; |
88 | + int index; | |
88 | 89 | }vplate_num; |
89 | 90 | #endif |
90 | 91 | |
... | ... | @@ -96,7 +97,12 @@ typedef struct vplate_result |
96 | 97 | float detect_score; |
97 | 98 | vplate_num recg[PLATENUM]; |
98 | 99 | float num_score; |
99 | - int type; //车牌类型 | |
100 | + int type; //车牌类型。只做车牌检测,车牌类型为:0-单层车牌,1-双层车牌;做车牌检测识别,0-单排蓝色 1-单排黄色 2-单排白色 3-单排黑色 4-双排黄色 5-双排白色 6-新能源黄绿色 7-新能源白绿色 | |
101 | + | |
102 | + int state; //车牌状态:0-无车牌,1-车牌,2-遮挡车牌 | |
103 | + float state_score;//车牌状态置信度 | |
104 | + | |
105 | + sy_point rr_point[4];//斜框 | |
100 | 106 | }vplate_result; |
101 | 107 | #endif |
102 | 108 | |
... | ... | @@ -219,11 +225,16 @@ typedef void(*VIDEO_REALTIME_CALLBACK)(void * handle, unsigned char *img_data, i |
219 | 225 | typedef void(*VIDEO_FINISH_CALLBACK)(void * handle, const int task_id); |
220 | 226 | |
221 | 227 | |
228 | +typedef void(*SFX_LOG_CALLBACK)(void * userPtr, int log_level, const char* log, unsigned int logLen); | |
229 | + | |
230 | + | |
222 | 231 | //TASK初始化参数 |
223 | 232 | #ifndef __TASK_PARAM__ |
224 | 233 | #define __TASK_PARAM__ |
225 | 234 | typedef struct task_param |
226 | 235 | { |
236 | + void* userPtr; | |
237 | + SFX_LOG_CALLBACK log; | |
227 | 238 | char video_filename[256]; |
228 | 239 | char result_folder_little[256]; |
229 | 240 | char result_folder[256]; |
... | ... | @@ -234,9 +245,9 @@ typedef struct task_param |
234 | 245 | sy_rect minBoxsize[DETECTTYPE]; //自定义的minBoxsize大小 |
235 | 246 | VIDEO_OBJECT_SNAPSHOT_CALLBACK obj_snapshot_callback_func; |
236 | 247 | VIDEO_REALTIME_CALLBACK rt_view_callback_func; |
248 | + VIDEO_FINISH_CALLBACK tFinishCallbackFunc; | |
237 | 249 | |
238 | - //task_param() : video_filename(0), result_folder_little(0), result_folder(0), result_folder_face(0) {} | |
239 | - task_param() : jpeg_quality(30) {} //debug by zsh | |
250 | + task_param() : jpeg_quality(30) {} | |
240 | 251 | }task_param; |
241 | 252 | #endif |
242 | 253 | |
... | ... | @@ -253,8 +264,8 @@ typedef struct mvpt_param |
253 | 264 | int skip_frame; //内部跳帧数 |
254 | 265 | |
255 | 266 | /********************************日志参数*****************************/ |
256 | - char path[2048]; | |
257 | - char name[512]; | |
267 | + char* path; | |
268 | + char* name; | |
258 | 269 | unsigned int serviceID; |
259 | 270 | unsigned char logMask; |
260 | 271 | unsigned int limitSize; |
... | ... | @@ -269,7 +280,6 @@ typedef struct mvpt_param |
269 | 280 | sy_command face_det_config; //是否开启人脸检测 |
270 | 281 | |
271 | 282 | VIDEO_OBJECT_INFO_CALLBACK task_obj_info_callback_func; //目标检测结果实时返回回调函数 |
272 | - VIDEO_FINISH_CALLBACK task_finish_callbackfunc; //任务分析结束结果回调函数 | |
273 | 283 | }mvpt_param; |
274 | 284 | #endif |
275 | 285 | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/mvpt.cpp
... | ... | @@ -7,7 +7,7 @@ int mvpt_init(void **handle, mvpt_param param) |
7 | 7 | |
8 | 8 | *handle = new CMutliSourceVideoProcess(); |
9 | 9 | CMutliSourceVideoProcess* tools = (CMutliSourceVideoProcess*)*handle; |
10 | - return tools->InitAlgorthim(param, param.task_obj_info_callback_func, param.task_finish_callbackfunc); | |
10 | + return tools->InitAlgorthim(param, param.task_obj_info_callback_func); | |
11 | 11 | } |
12 | 12 | |
13 | 13 | //int AddTask(void *handle, char* videoFileName) | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/HumanCarParsing.cpp
... | ... | @@ -61,6 +61,7 @@ int HumanCarParsing::init(int gpuid, char* auth_license) |
61 | 61 | param.engine = ENGINE_TENSORRT; |
62 | 62 | param.serialize_file = "./serialize_file/HCP"; |
63 | 63 | param.max_batch = 20; |
64 | + param.auth_license = auth_license; | |
64 | 65 | if (hcp_init(&handle, param) != 0) |
65 | 66 | { |
66 | 67 | LOG_ERROR("hcp_init Failed!"); | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/cuda_src/ImageSaveGPU.cpp
... | ... | @@ -37,7 +37,7 @@ int partMemCopy(unsigned char* d_srcRGB, int src_width, int src_height, unsigned |
37 | 37 | { |
38 | 38 | cudaError_t cudaStatus = cuda_common::PartMemCopy(d_srcRGB, src_width, src_height, d_dstRGB, left, top, right, bottom); |
39 | 39 | if (cudaStatus != cudaSuccess) { |
40 | - LOG_ERROR("cuda_common::PartMemCopy failed: {} {} {} {} {} {} {}",cudaGetErrorString(cudaStatus), left, top, right, bottom, src_height, d_dstRGB); | |
40 | + LOG_ERROR("cuda_common::PartMemCopy failed: {} {} {} {} {} {}",cudaGetErrorString(cudaStatus), left, top, right, bottom, src_height); | |
41 | 41 | return -1; |
42 | 42 | } |
43 | 43 | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/cuda_src/PartMemCopy.cu
1 | 1 | #include "cuda_kernels.h" |
2 | 2 | #include <algorithm> |
3 | + | |
3 | 4 | typedef unsigned char uchar; |
4 | 5 | typedef unsigned int uint32; |
5 | 6 | typedef int int32; |
... | ... | @@ -246,17 +247,28 @@ namespace cuda_common |
246 | 247 | cudaMalloc(&gpu_dst_rgb, 1000 * sizeof(unsigned char*)); |
247 | 248 | cudaMemcpy(gpu_dst_rgb, d_dstRGB, count * sizeof(unsigned char*), cudaMemcpyHostToDevice); |
248 | 249 | |
249 | - //cudaMemcpy(cpu_personfloat, d_srcRGB, 112*224*2*sizeof(float), cudaMemcpyDeviceToHost); | |
250 | - // for(int i=0;i<100;i++) | |
251 | - // { | |
252 | - // printf("the score is %f\t",cpu_personfloat[i]); | |
253 | - // } | |
250 | + | |
254 | 251 | PartCopy_ResizeImgBilinearBGR_Mean_Variance_CUDAKernel << < grid, block >> > ( |
255 | 252 | d_srcRGB, src_width, src_height, |
256 | 253 | gpu_left, gpu_top, gpu_right, gpu_bottom, |
257 | 254 | gpu_dst_rgb, count, gpu_dst_w, gpu_dst_h, |
258 | 255 | submeanb, submeang, submeanr, |
259 | 256 | varianceb, varianceg, variancer); |
257 | + | |
258 | + cudaError_t cudaStatus = cudaGetLastError(); | |
259 | + do | |
260 | + { | |
261 | + if (cudaStatus != cudaSuccess) { | |
262 | + fprintf(stderr, "Part 270 kernel_memcopy launch failed: %s\n", cudaGetErrorString(cudaStatus)); | |
263 | + break; | |
264 | + } | |
265 | + cudaStatus = cudaDeviceSynchronize(); | |
266 | + if (cudaStatus != cudaSuccess) { | |
267 | + fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching kernel_bilinear!\n", cudaStatus); | |
268 | + break; | |
269 | + } | |
270 | + } while (0); | |
271 | + | |
260 | 272 | cudaFree(gpu_top); |
261 | 273 | cudaFree(gpu_bottom); |
262 | 274 | cudaFree(gpu_left); |
... | ... | @@ -264,24 +276,13 @@ namespace cuda_common |
264 | 276 | cudaFree(gpu_dst_w); |
265 | 277 | cudaFree(gpu_dst_h); |
266 | 278 | cudaFree(gpu_dst_rgb); |
267 | - | |
268 | - cudaError_t cudaStatus = cudaGetLastError(); | |
269 | - if (cudaStatus != cudaSuccess) { | |
270 | - fprintf(stderr, "Part 270 kernel_memcopy launch failed: %s\n", cudaGetErrorString(cudaStatus)); | |
271 | - return cudaStatus; | |
272 | - } | |
273 | - cudaStatus = cudaDeviceSynchronize(); | |
274 | - if (cudaStatus != cudaSuccess) { | |
275 | - fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching kernel_bilinear!\n", cudaStatus); | |
276 | - return cudaStatus; | |
277 | - } | |
278 | 279 | |
279 | 280 | /*cudaEventRecord(stop, 0); |
280 | 281 | cudaEventSynchronize(stop); |
281 | 282 | cudaEventElapsedTime(&time, start, stop); |
282 | 283 | cudaEventDestroy(start); |
283 | 284 | cudaEventDestroy(stop); |
284 | - printf("核函数消耗时间:%f\n", time);*/ | |
285 | + printf("锟剿猴拷锟斤拷锟斤拷锟斤拷时锟斤拷:%f\n", time);*/ | |
285 | 286 | |
286 | 287 | return cudaStatus; |
287 | 288 | } | ... | ... |
vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp
... | ... | @@ -664,6 +664,10 @@ void videoFinishCallback(void * handle, const int taskID) |
664 | 664 | // } |
665 | 665 | } |
666 | 666 | |
667 | +void log_all(void * userPtr, int log_level, const char* log, unsigned int logLen) { | |
668 | + // cout << "log all: " << log_level << " " << logLen << " " << log << endl; | |
669 | +} | |
670 | + | |
667 | 671 | //操作句柄 |
668 | 672 | void *handle; |
669 | 673 | static int total_index = 0; |
... | ... | @@ -687,11 +691,16 @@ void create_task(const char * videoFileName, int total_index) { |
687 | 691 | tparam.on_image_display = false; |
688 | 692 | tparam.jpeg_quality = 30; //debug by zsh |
689 | 693 | tparam.decMode = 0; // 关键帧解码 |
694 | + tparam.log = log_all; | |
695 | + tparam.userPtr = nullptr; | |
696 | + | |
697 | + cout << "create_task:" << tparam.video_filename << endl; | |
690 | 698 | |
691 | 699 | //tparam.video_filename = argv[total_index%4]; |
692 | 700 | memcpy(tparam.minBoxsize, m_boxsize, sizeof(sy_rect)* DETECTTYPE); |
693 | 701 | tparam.rt_view_callback_func = videoRTViewCallback; |
694 | 702 | tparam.obj_snapshot_callback_func = videoObjSnapshotCallback; |
703 | + tparam.tFinishCallbackFunc = videoFinishCallback; | |
695 | 704 | |
696 | 705 | for (int tmp = 0; tmp < 10; tmp ++) { |
697 | 706 | string tmp_path = "results/" + vpt_types[tmp]; |
... | ... | @@ -710,10 +719,13 @@ int main(int argc, char* argv[]) |
710 | 719 | cout << "You must input videoFileName, iAddTaskCount and gpuid." << endl; |
711 | 720 | return -1; |
712 | 721 | } |
722 | + | |
713 | 723 | const char * videoFileName = argv[1]; |
714 | 724 | addTaskCount = atoi(argv[2]); |
715 | 725 | int gpuID = atoi(argv[3]); |
716 | 726 | |
727 | + cout << "cmd:" << videoFileName << endl; | |
728 | + | |
717 | 729 | //初始化参数设置 |
718 | 730 | mvpt_param vptParam; |
719 | 731 | // vptParam.hp_analysis_config = SY_CONFIG_CLOSE; |
... | ... | @@ -722,7 +734,7 @@ int main(int argc, char* argv[]) |
722 | 734 | // vptParam.hf_recg_config = SY_CONFIG_CLOSE; |
723 | 735 | // vptParam.hcf_recg_config = SY_CONFIG_CLOSE; |
724 | 736 | // vptParam.vcf_recg_config = SY_CONFIG_CLOSE; |
725 | - vptParam.face_det_config = SY_CONFIG_CLOSE; | |
737 | + // vptParam.face_det_config = SY_CONFIG_CLOSE; | |
726 | 738 | |
727 | 739 | vptParam.hp_analysis_config = SY_CONFIG_OPEN; |
728 | 740 | vptParam.hcp_analysis_config = SY_CONFIG_OPEN; |
... | ... | @@ -730,20 +742,19 @@ int main(int argc, char* argv[]) |
730 | 742 | vptParam.hf_recg_config = SY_CONFIG_OPEN; |
731 | 743 | vptParam.hcf_recg_config = SY_CONFIG_OPEN; |
732 | 744 | vptParam.vcf_recg_config = SY_CONFIG_OPEN; |
733 | - // vptParam.face_det_config = SY_CONFIG_OPEN; | |
745 | + vptParam.face_det_config = SY_CONFIG_OPEN; | |
734 | 746 | |
735 | 747 | vptParam.vrdbpath = argv[4]; |
736 | 748 | //vptParam.vrdbpath = "../../db/mvpt.bin"; |
737 | 749 | vptParam.auth_license = "sy_va_sub_sdk_2023"; //通用授权 |
738 | 750 | vptParam.task_obj_info_callback_func = videoObjInfoCallback; |
739 | - vptParam.task_finish_callbackfunc = videoFinishCallback; | |
740 | 751 | vptParam.gpuid = gpuID; |
741 | 752 | vptParam.wait_framecount = 30; |
742 | 753 | vptParam.serviceID = 0; |
743 | 754 | vptParam.limitSize = (10 << 20); |
744 | 755 | vptParam.skip_frame = 5; |
745 | - strcat(vptParam.name, "gbrealtime"); | |
746 | - strcat(vptParam.path, "./log/"); | |
756 | + vptParam.name = "gbrealtime"; | |
757 | + vptParam.path = "./logs/main.log"; | |
747 | 758 | int flag = mvpt_init(&handle, vptParam); |
748 | 759 | |
749 | 760 | if (0 != flag) | ... | ... |