Commit a1c0194c32d446cd68a73914ed9961ff2375d516

Authored by Hu Chunming
1 parent 1d41673e

FFNvDecoder 初步功能版

Showing 17 changed files with 302 additions and 277 deletions
.vscode/launch.json
@@ -20,6 +20,24 @@ @@ -20,6 +20,24 @@
20 } 20 }
21 ] 21 ]
22 },{ 22 },{
  23 + "name": "test_ffnvdecoder",
  24 + "type": "cppdbg",
  25 + "request": "launch",
  26 + "program": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512/test",
  27 + "args": ["/home/cmhu/data/video/Street.uvf","6","0","./db/mvpt.bin"],
  28 + "stopAtEntry": false,
  29 + "cwd": "${workspaceFolder}/Linux_3rdparty/video_structure_sdk_20220512",
  30 + "environment": [],
  31 + "externalConsole": false,
  32 + "MIMode": "gdb",
  33 + "setupCommands": [
  34 + {
  35 + "description": "Enable pretty-printing for gdb",
  36 + "text": "-enable-pretty-printing",
  37 + "ignoreFailures": true
  38 + }
  39 + ]
  40 + },{
23 "name": "test_face", 41 "name": "test_face",
24 "type": "cppdbg", 42 "type": "cppdbg",
25 "request": "launch", 43 "request": "launch",
vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile
@@ -2,6 +2,7 @@ CC = gcc @@ -2,6 +2,7 @@ CC = gcc
2 XX = g++ 2 XX = g++
3 AR = ar 3 AR = ar
4 4
  5 +CUDA = /usr/local/cuda
5 NVCC = /usr/local/cuda/bin/nvcc 6 NVCC = /usr/local/cuda/bin/nvcc
6 7
7 MNT_HOME = /home/cmhu/Project_VideoStructure 8 MNT_HOME = /home/cmhu/Project_VideoStructure
@@ -11,6 +12,7 @@ DEPEND_DIR = $(MNT_HOME)/Linux_3rdparty @@ -11,6 +12,7 @@ DEPEND_DIR = $(MNT_HOME)/Linux_3rdparty
11 SDK_ROOT = $(MNT_HOME)/SDK 12 SDK_ROOT = $(MNT_HOME)/SDK
12 13
13 SRC_ROOT = $(PROJECT_ROOT)/src/VPT 14 SRC_ROOT = $(PROJECT_ROOT)/src/VPT
  15 +FFNVDECODER_ROOT = $(PROJECT_ROOT)/src/FFNvDecoder
14 16
15 UTOOLS_SSD_ROOT = $(DEPEND_DIR)/utools_trt_v1.4.0 17 UTOOLS_SSD_ROOT = $(DEPEND_DIR)/utools_trt_v1.4.0
16 HIDE_MODEL_CAFFE2 = $(PROJECT_ROOT)/model/hidemodel_caffe_1108 18 HIDE_MODEL_CAFFE2 = $(PROJECT_ROOT)/model/hidemodel_caffe_1108
@@ -19,6 +21,7 @@ AUTHORITY_DIR = $(DEPEND_DIR)/authority_linux_20200114 @@ -19,6 +21,7 @@ AUTHORITY_DIR = $(DEPEND_DIR)/authority_linux_20200114
19 TRT_ROOT = $(DEPEND_DIR)/TensorRT-8.6.1.6 21 TRT_ROOT = $(DEPEND_DIR)/TensorRT-8.6.1.6
20 OPENCV_ROOT = $(DEPEND_DIR)/opencv-4.5.4/release 22 OPENCV_ROOT = $(DEPEND_DIR)/opencv-4.5.4/release
21 FFMPEG_ROOT = $(DEPEND_DIR)/ffmpeg-5.0.1/release 23 FFMPEG_ROOT = $(DEPEND_DIR)/ffmpeg-5.0.1/release
  24 +SPDLOG_ROOT = $(DEPEND_DIR)/spdlog-1.9.2/release
22 25
23 TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so 26 TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so
24 27
@@ -34,16 +37,18 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ @@ -34,16 +37,18 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \
34 -I $(DEPEND_DIR)/include/cairo \ 37 -I $(DEPEND_DIR)/include/cairo \
35 -I $(SRC_ROOT)/sort \ 38 -I $(SRC_ROOT)/sort \
36 -I $(SRC_ROOT)/snapshot_analysis \ 39 -I $(SRC_ROOT)/snapshot_analysis \
37 - -I $(SRC_ROOT)/../DxDecoder \  
38 - -I /usr/local/cuda/include \  
39 -I $(HIDE_MODEL_CAFFE2) \ 40 -I $(HIDE_MODEL_CAFFE2) \
40 -I $(HIDE_MODEL_TRT) \ 41 -I $(HIDE_MODEL_TRT) \
41 -I $(AUTHORITY_DIR) \ 42 -I $(AUTHORITY_DIR) \
42 -I $(FFMPEG_ROOT)/include \ 43 -I $(FFMPEG_ROOT)/include \
43 -I $(SDK_ROOT)/face_detect2/face_detect \ 44 -I $(SDK_ROOT)/face_detect2/face_detect \
  45 + -I $(SPDLOG_ROOT)/include \
  46 + -I $(FFNVDECODER_ROOT) \
  47 + -I $(FFNVDECODER_ROOT)/common/inc \
  48 + -I $(FFNVDECODER_ROOT)/common/UtilNPP \
  49 + -I $(CUDA)/include \
44 50
45 -LIBSPATH= -L ../DxDecoder -l:libDxDecoder.a \  
46 - -L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ 51 +LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \
47 -L/usr/lib/x86_64-linux-gnu -lnvcuvid \ 52 -L/usr/lib/x86_64-linux-gnu -lnvcuvid \
48 -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lvpd2 \ 53 -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lvpd2 \
49 -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\ 54 -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\
@@ -53,9 +58,10 @@ LIBSPATH= -L ../DxDecoder -l:libDxDecoder.a \ @@ -53,9 +58,10 @@ LIBSPATH= -L ../DxDecoder -l:libDxDecoder.a \
53 -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\ 58 -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\
54 -L$(AUTHORITY_DIR) -l:libauthority.a \ 59 -L$(AUTHORITY_DIR) -l:libauthority.a \
55 -L $(DEPEND_DIR)/include/boost_linux_x86_64/lib -l:libboost_system.a -l:libboost_thread.a \ 60 -L $(DEPEND_DIR)/include/boost_linux_x86_64/lib -l:libboost_system.a -l:libboost_thread.a \
  61 + -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \
56 62
57 63
58 -CFLAGS_LIB=-g -O0 -Wall -Wno-deprecated $(DEFS) -lz -fPIC -fvisibility=hidden -Wl,-Bsymbolic 64 +CFLAGS_LIB=-g -O0 -Wall -Wno-deprecated $(DEFS) -lz -ldl -lpthread -fPIC -fvisibility=hidden -Wl,-Bsymbolic
59 CFLAGS = $(CFLAGS_LIB) $(INCLUDE) -std=c++11 -DUSE_CUDNN 65 CFLAGS = $(CFLAGS_LIB) $(INCLUDE) -std=c++11 -DUSE_CUDNN
60 # -DUNICODE -D_UNICODE 66 # -DUNICODE -D_UNICODE
61 NFLAGS_LIB=-g -c $(DEFS) -shared -Xcompiler -fPIC -Xcompiler -fvisibility=hidden 67 NFLAGS_LIB=-g -c $(DEFS) -shared -Xcompiler -fPIC -Xcompiler -fvisibility=hidden
@@ -69,10 +75,13 @@ SRCS:=$(wildcard $(SRC_ROOT)/*.cpp) \ @@ -69,10 +75,13 @@ SRCS:=$(wildcard $(SRC_ROOT)/*.cpp) \
69 $(wildcard $(HIDE_MODEL_CAFFE2)/*.cpp) \ 75 $(wildcard $(HIDE_MODEL_CAFFE2)/*.cpp) \
70 $(wildcard $(HIDE_MODEL_TRT)/*.cpp) \ 76 $(wildcard $(HIDE_MODEL_TRT)/*.cpp) \
71 $(wildcard $(SRC_ROOT)/snapshot_analysis/*.cpp) \ 77 $(wildcard $(SRC_ROOT)/snapshot_analysis/*.cpp) \
72 - 78 + $(wildcard $(FFNVDECODER_ROOT)/*.cpp)
  79 +
73 OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS))) 80 OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS)))
74 81
75 -CU_SOURCES = $(wildcard ${SRC_ROOT}/snapshot_analysis/*.cu) 82 +CU_SOURCES = $(wildcard ${SRC_ROOT}/snapshot_analysis/*.cu) \
  83 + $(wildcard ${FFNVDECODER_ROOT}/*.cu)
  84 +
76 CU_OBJS = $(patsubst %.cu, %.o, $(notdir $(CU_SOURCES))) 85 CU_OBJS = $(patsubst %.cu, %.o, $(notdir $(CU_SOURCES)))
77 86
78 all:$(TARGET) 87 all:$(TARGET)
@@ -97,6 +106,13 @@ $(TARGET):$(OBJS) $(CU_OBJS) @@ -97,6 +106,13 @@ $(TARGET):$(OBJS) $(CU_OBJS)
97 %.o:$(SRC_ROOT)/snapshot_analysis/%.cu 106 %.o:$(SRC_ROOT)/snapshot_analysis/%.cu
98 @echo "#######################CU_OBJS:$@###############" 107 @echo "#######################CU_OBJS:$@###############"
99 $(NVCC) $(NFLAGS) -o $@ $< 108 $(NVCC) $(NFLAGS) -o $@ $<
  109 +
  110 +%.o:$(FFNVDECODER_ROOT)/%.cpp
  111 + $(XX) $(CFLAGS) -c $<
  112 +
  113 +%.o:$(FFNVDECODER_ROOT)/%.cu
  114 + @echo "#######################CU_OBJS:$@###############"
  115 + $(NVCC) $(NFLAGS) -o $@ $<
100 116
101 .PHONY:clean 117 .PHONY:clean
102 clean: 118 clean:
vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile.FFNvDecoder renamed to vehicle_structure_platform.git0708-3080-trt-face/linux/VPT/Makefile.qx
@@ -2,7 +2,6 @@ CC = gcc @@ -2,7 +2,6 @@ CC = gcc
2 XX = g++ 2 XX = g++
3 AR = ar 3 AR = ar
4 4
5 -CUDA = /usr/local/cuda  
6 NVCC = /usr/local/cuda/bin/nvcc 5 NVCC = /usr/local/cuda/bin/nvcc
7 6
8 MNT_HOME = /home/cmhu/Project_VideoStructure 7 MNT_HOME = /home/cmhu/Project_VideoStructure
@@ -12,7 +11,6 @@ DEPEND_DIR = $(MNT_HOME)/Linux_3rdparty @@ -12,7 +11,6 @@ DEPEND_DIR = $(MNT_HOME)/Linux_3rdparty
12 SDK_ROOT = $(MNT_HOME)/SDK 11 SDK_ROOT = $(MNT_HOME)/SDK
13 12
14 SRC_ROOT = $(PROJECT_ROOT)/src/VPT 13 SRC_ROOT = $(PROJECT_ROOT)/src/VPT
15 -FFNVDECODER_ROOT = $(PROJECT_ROOT)/src/FFNvDecoder  
16 14
17 UTOOLS_SSD_ROOT = $(DEPEND_DIR)/utools_trt_v1.4.0 15 UTOOLS_SSD_ROOT = $(DEPEND_DIR)/utools_trt_v1.4.0
18 HIDE_MODEL_CAFFE2 = $(PROJECT_ROOT)/model/hidemodel_caffe_1108 16 HIDE_MODEL_CAFFE2 = $(PROJECT_ROOT)/model/hidemodel_caffe_1108
@@ -21,7 +19,6 @@ AUTHORITY_DIR = $(DEPEND_DIR)/authority_linux_20200114 @@ -21,7 +19,6 @@ AUTHORITY_DIR = $(DEPEND_DIR)/authority_linux_20200114
21 TRT_ROOT = $(DEPEND_DIR)/TensorRT-8.6.1.6 19 TRT_ROOT = $(DEPEND_DIR)/TensorRT-8.6.1.6
22 OPENCV_ROOT = $(DEPEND_DIR)/opencv-4.5.4/release 20 OPENCV_ROOT = $(DEPEND_DIR)/opencv-4.5.4/release
23 FFMPEG_ROOT = $(DEPEND_DIR)/ffmpeg-5.0.1/release 21 FFMPEG_ROOT = $(DEPEND_DIR)/ffmpeg-5.0.1/release
24 -SPDLOG_ROOT = $(DEPEND_DIR)/spdlog-1.9.2/release  
25 22
26 TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so 23 TARGET = $(DEPEND_DIR)/video_structure_sdk_20220512/libmvpt.so
27 24
@@ -37,18 +34,16 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \ @@ -37,18 +34,16 @@ INCLUDE= -I $(DEPEND_DIR)/include/boost_linux_x86_64/include \
37 -I $(DEPEND_DIR)/include/cairo \ 34 -I $(DEPEND_DIR)/include/cairo \
38 -I $(SRC_ROOT)/sort \ 35 -I $(SRC_ROOT)/sort \
39 -I $(SRC_ROOT)/snapshot_analysis \ 36 -I $(SRC_ROOT)/snapshot_analysis \
  37 + -I $(SRC_ROOT)/../DxDecoder \
  38 + -I /usr/local/cuda/include \
40 -I $(HIDE_MODEL_CAFFE2) \ 39 -I $(HIDE_MODEL_CAFFE2) \
41 -I $(HIDE_MODEL_TRT) \ 40 -I $(HIDE_MODEL_TRT) \
42 -I $(AUTHORITY_DIR) \ 41 -I $(AUTHORITY_DIR) \
43 -I $(FFMPEG_ROOT)/include \ 42 -I $(FFMPEG_ROOT)/include \
44 -I $(SDK_ROOT)/face_detect2/face_detect \ 43 -I $(SDK_ROOT)/face_detect2/face_detect \
45 - -I $(SPDLOG_ROOT)/include \  
46 - -I $(FFNVDECODER_ROOT) \  
47 - -I $(FFNVDECODER_ROOT)/common/inc \  
48 - -I $(FFNVDECODER_ROOT)/common/UtilNPP \  
49 - -I $(CUDA)/include \  
50 44
51 -LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ 45 +LIBSPATH= -L ../DxDecoder -l:libDxDecoder.a \
  46 + -L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \
52 -L/usr/lib/x86_64-linux-gnu -lnvcuvid \ 47 -L/usr/lib/x86_64-linux-gnu -lnvcuvid \
53 -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lvpd2 \ 48 -L$(DEPEND_DIR)/video_structure_sdk_20220512 -lSfxDecoder -lSfxStreamHandler -lvpd2 \
54 -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\ 49 -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\
@@ -58,10 +53,9 @@ LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \ @@ -58,10 +53,9 @@ LIBSPATH=-L/usr/local/cuda/lib64 -lcuda -lcudart -lcurand -lcublas \
58 -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\ 53 -L $(OPENCV_ROOT)/lib -lopencv_video -lopencv_highgui -lopencv_imgproc -lopencv_core -lopencv_imgcodecs\
59 -L$(AUTHORITY_DIR) -l:libauthority.a \ 54 -L$(AUTHORITY_DIR) -l:libauthority.a \
60 -L $(DEPEND_DIR)/include/boost_linux_x86_64/lib -l:libboost_system.a -l:libboost_thread.a \ 55 -L $(DEPEND_DIR)/include/boost_linux_x86_64/lib -l:libboost_system.a -l:libboost_thread.a \
61 - -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \  
62 56
63 57
64 -CFLAGS_LIB=-g -O0 -Wall -Wno-deprecated $(DEFS) -lz -ldl -lpthread -fPIC -fvisibility=hidden -Wl,-Bsymbolic 58 +CFLAGS_LIB=-g -O0 -Wall -Wno-deprecated $(DEFS) -lz -fPIC -fvisibility=hidden -Wl,-Bsymbolic
65 CFLAGS = $(CFLAGS_LIB) $(INCLUDE) -std=c++11 -DUSE_CUDNN 59 CFLAGS = $(CFLAGS_LIB) $(INCLUDE) -std=c++11 -DUSE_CUDNN
66 # -DUNICODE -D_UNICODE 60 # -DUNICODE -D_UNICODE
67 NFLAGS_LIB=-g -c $(DEFS) -shared -Xcompiler -fPIC -Xcompiler -fvisibility=hidden 61 NFLAGS_LIB=-g -c $(DEFS) -shared -Xcompiler -fPIC -Xcompiler -fvisibility=hidden
@@ -75,13 +69,10 @@ SRCS:=$(wildcard $(SRC_ROOT)/*.cpp) \ @@ -75,13 +69,10 @@ SRCS:=$(wildcard $(SRC_ROOT)/*.cpp) \
75 $(wildcard $(HIDE_MODEL_CAFFE2)/*.cpp) \ 69 $(wildcard $(HIDE_MODEL_CAFFE2)/*.cpp) \
76 $(wildcard $(HIDE_MODEL_TRT)/*.cpp) \ 70 $(wildcard $(HIDE_MODEL_TRT)/*.cpp) \
77 $(wildcard $(SRC_ROOT)/snapshot_analysis/*.cpp) \ 71 $(wildcard $(SRC_ROOT)/snapshot_analysis/*.cpp) \
78 - $(wildcard $(FFNVDECODER_ROOT)/*.cpp)  
79 - 72 +
80 OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS))) 73 OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS)))
81 74
82 -CU_SOURCES = $(wildcard ${SRC_ROOT}/snapshot_analysis/*.cu) \  
83 - $(wildcard ${FFNVDECODER_ROOT}/*.cu)  
84 - 75 +CU_SOURCES = $(wildcard ${SRC_ROOT}/snapshot_analysis/*.cu)
85 CU_OBJS = $(patsubst %.cu, %.o, $(notdir $(CU_SOURCES))) 76 CU_OBJS = $(patsubst %.cu, %.o, $(notdir $(CU_SOURCES)))
86 77
87 all:$(TARGET) 78 all:$(TARGET)
@@ -106,13 +97,6 @@ $(TARGET):$(OBJS) $(CU_OBJS) @@ -106,13 +97,6 @@ $(TARGET):$(OBJS) $(CU_OBJS)
106 %.o:$(SRC_ROOT)/snapshot_analysis/%.cu 97 %.o:$(SRC_ROOT)/snapshot_analysis/%.cu
107 @echo "#######################CU_OBJS:$@###############" 98 @echo "#######################CU_OBJS:$@###############"
108 $(NVCC) $(NFLAGS) -o $@ $< 99 $(NVCC) $(NFLAGS) -o $@ $<
109 -  
110 -%.o:$(FFNVDECODER_ROOT)/%.cpp  
111 - $(XX) $(CFLAGS) -c $<  
112 -  
113 -%.o:$(FFNVDECODER_ROOT)/%.cu  
114 - @echo "#######################CU_OBJS:$@###############"  
115 - $(NVCC) $(NFLAGS) -o $@ $<  
116 100
117 .PHONY:clean 101 .PHONY:clean
118 clean: 102 clean:
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/AbstractDecoder.cpp
@@ -40,7 +40,8 @@ FFImgInfo* AbstractDecoder::snapshot(){ @@ -40,7 +40,8 @@ FFImgInfo* AbstractDecoder::snapshot(){
40 } 40 }
41 41
42 // 队列中数据大于1 42 // 队列中数据大于1
43 - gpuFrame = mFrameQueue.front(); 43 + GPUFrame* frame = mFrameQueue.front();
  44 + gpuFrame = frame->gpuFrame;
44 m_queue_mutex.unlock(); 45 m_queue_mutex.unlock();
45 break; 46 break;
46 } 47 }
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/AbstractDecoder.h
@@ -57,6 +57,7 @@ struct FFDecConfig{ @@ -57,6 +57,7 @@ struct FFDecConfig{
57 string gpuid; // gpu id 57 string gpuid; // gpu id
58 bool force_tcp{true}; // 是否指定使用tcp连接 58 bool force_tcp{true}; // 是否指定使用tcp连接
59 int skip_frame{1}; // 跳帧数 59 int skip_frame{1}; // 跳帧数
  60 + bool keyframe_decode_mod; // 关键帧模式解码
60 61
61 int port; // gb28181接收数据的端口号 62 int port; // gb28181接收数据的端口号
62 DECODE_REQUEST_STREAM_CALLBACK request_stream_cbk; // gb28181请求流 63 DECODE_REQUEST_STREAM_CALLBACK request_stream_cbk; // gb28181请求流
@@ -129,7 +130,7 @@ public: @@ -129,7 +130,7 @@ public:
129 130
130 FFDecConfig m_cfg; 131 FFDecConfig m_cfg;
131 132
132 - queue<AVFrame*> mFrameQueue; 133 + queue<GPUFrame*> mFrameQueue;
133 mutex m_queue_mutex; 134 mutex m_queue_mutex;
134 mutex m_snapshot_mutex; 135 mutex m_snapshot_mutex;
135 136
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.cpp
@@ -21,7 +21,8 @@ void decode_finished_cbk(const void * userPtr){ @@ -21,7 +21,8 @@ void decode_finished_cbk(const void * userPtr){
21 DxDecoderWrap::DxDecoderWrap( const DxConfig * cfg ) 21 DxDecoderWrap::DxDecoderWrap( const DxConfig * cfg )
22 { 22 {
23 m_bClose = false; 23 m_bClose = false;
24 - m_pDec = NULL; 24 + m_pDec = nullptr;
  25 + m_pHwData = nullptr;
25 26
26 m_cfg.post_decoded_cbk = decoded_cbk; 27 m_cfg.post_decoded_cbk = decoded_cbk;
27 m_cfg.decode_finished_cbk = decode_finished_cbk; 28 m_cfg.decode_finished_cbk = decode_finished_cbk;
@@ -29,6 +30,11 @@ DxDecoderWrap::DxDecoderWrap( const DxConfig * cfg ) @@ -29,6 +30,11 @@ DxDecoderWrap::DxDecoderWrap( const DxConfig * cfg )
29 m_cfg.gpuid = std::to_string(cfg->devId); 30 m_cfg.gpuid = std::to_string(cfg->devId);
30 31
31 m_name = cfg->name; 32 m_name = cfg->name;
  33 + m_decMode = cfg->decMode;
  34 +
  35 + CUdevice cuDevice;
  36 + cuDeviceGet(&cuDevice, cfg->devId);
  37 + cuCtxCreate(&m_cuda_cxt, 0, cuDevice);
32 38
33 return; 39 return;
34 } 40 }
@@ -60,6 +66,10 @@ int DxDecoderWrap::DxOpenDecoder( const char * uri, unsigned int skip ) @@ -60,6 +66,10 @@ int DxDecoderWrap::DxOpenDecoder( const char * uri, unsigned int skip )
60 m_pDec->setName(m_name) ; 66 m_pDec->setName(m_name) ;
61 m_pDec->m_postDecArg = this; 67 m_pDec->m_postDecArg = this;
62 m_pDec->m_finishedDecArg = this; 68 m_pDec->m_finishedDecArg = this;
  69 + if(1 == m_decMode) {
  70 + m_pDec->setDecKeyframe(true);
  71 + }
  72 + m_pDec->start();
63 LOG_INFO("[{}][{}]- 解码器初始化成功", m_name.c_str(), uri); 73 LOG_INFO("[{}][{}]- 解码器初始化成功", m_name.c_str(), uri);
64 return 0; 74 return 0;
65 } 75 }
@@ -77,16 +87,29 @@ int DxDecoderWrap::DxOpenDecoder( const char * uri, unsigned int skip ) @@ -77,16 +87,29 @@ int DxDecoderWrap::DxOpenDecoder( const char * uri, unsigned int skip )
77 int DxDecoderWrap::DxCloseDecoder() 87 int DxDecoderWrap::DxCloseDecoder()
78 { 88 {
79 m_bClose = true; 89 m_bClose = true;
  90 +
80 if(m_pDec) { 91 if(m_pDec) {
81 m_pDec->close(); 92 m_pDec->close();
82 delete m_pDec; 93 delete m_pDec;
83 m_pDec = nullptr; 94 m_pDec = nullptr;
84 } 95 }
85 96
86 - if(pHwData != nullptr){  
87 - cudaFree(pHwData); 97 + m_queue_frames_mutex.lock();
  98 + while (m_queue_frames.size() > 0) {
  99 + GPUFrame * decodedFrame = m_queue_frames.front();
  100 + m_queue_frames.pop();
  101 + delete decodedFrame;
  102 + decodedFrame = nullptr;
  103 + }
  104 + m_queue_frames_mutex.unlock();
  105 +
  106 + if(m_pHwData != nullptr){
  107 + cudaFree(m_pHwData);
88 } 108 }
89 109
  110 + cuCtxPopCurrent(nullptr);
  111 + cuCtxDestroy(m_cuda_cxt);
  112 +
90 return 0; 113 return 0;
91 } 114 }
92 115
@@ -112,8 +135,8 @@ int DxDecoderWrap::DxGetResolution( int * width, int * height ) @@ -112,8 +135,8 @@ int DxDecoderWrap::DxGetResolution( int * width, int * height )
112 return -1; 135 return -1;
113 } 136 }
114 137
115 -int DxDecoderWrap::DxGetFrameCount(){  
116 - 138 +int DxDecoderWrap::DxGetFrameCount()
  139 +{
117 if(m_pDec != nullptr){ 140 if(m_pDec != nullptr){
118 return m_pDec->GetFrameCount(); 141 return m_pDec->GetFrameCount();
119 } 142 }
@@ -150,9 +173,13 @@ bool DxDecoderWrap::DxDecoderIsRun() const @@ -150,9 +173,13 @@ bool DxDecoderWrap::DxDecoderIsRun() const
150 } 173 }
151 174
152 175
153 -bool DxDecoderWrap::DxFrameIsEmpty() const 176 +bool DxDecoderWrap::DxFrameIsEmpty()
154 { 177 {
155 - return 0 == m_frames.counts; 178 + m_queue_frames_mutex.lock();
  179 + int count = m_queue_frames.size();
  180 + m_queue_frames_mutex.unlock();
  181 +
  182 + return 0 == count;
156 } 183 }
157 184
158 185
@@ -164,6 +191,11 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) @@ -164,6 +191,11 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame )
164 } 191 }
165 192
166 m_queue_frames_mutex.lock(); 193 m_queue_frames_mutex.lock();
  194 + if(m_queue_frames.size() <= 0) {
  195 + m_queue_frames_mutex.unlock();
  196 + return -1;
  197 + }
  198 +
167 GPUFrame * decodedFrame = m_queue_frames.front(); 199 GPUFrame * decodedFrame = m_queue_frames.front();
168 m_queue_frames.pop(); 200 m_queue_frames.pop();
169 m_queue_frames_mutex.unlock(); 201 m_queue_frames_mutex.unlock();
@@ -171,17 +203,18 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) @@ -171,17 +203,18 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame )
171 AVFrame* gpuFrame = decodedFrame->gpuFrame; 203 AVFrame* gpuFrame = decodedFrame->gpuFrame;
172 204
173 cudaSetDevice(atoi(m_cfg.gpuid.c_str())); 205 cudaSetDevice(atoi(m_cfg.gpuid.c_str()));
  206 + cuCtxPushCurrent(m_cuda_cxt);
174 cudaError_t cudaStatus; 207 cudaError_t cudaStatus;
175 size_t rgbSize = 3 * gpuFrame->width * gpuFrame->height * sizeof(unsigned char); 208 size_t rgbSize = 3 * gpuFrame->width * gpuFrame->height * sizeof(unsigned char);
176 - if(pHwData == nullptr){  
177 - cudaStatus = cudaMalloc((void **)&pHwData, rgbSize); 209 + if(m_pHwData == nullptr){
  210 + cudaStatus = cudaMalloc((void **)&m_pHwData, rgbSize);
178 if (cudaStatus != cudaSuccess) { 211 if (cudaStatus != cudaSuccess) {
179 LOG_ERROR("[{}]- cudaMalloc failed !!!", m_name.c_str()); 212 LOG_ERROR("[{}]- cudaMalloc failed !!!", m_name.c_str());
180 return -1; 213 return -1;
181 } 214 }
182 } 215 }
183 cuda_common::setColorSpace( ITU_709, 0 ); 216 cuda_common::setColorSpace( ITU_709, 0 );
184 - cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], pHwData, gpuFrame->width, gpuFrame->height); 217 + cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], m_pHwData, gpuFrame->width, gpuFrame->height);
185 cudaDeviceSynchronize(); 218 cudaDeviceSynchronize();
186 if (cudaStatus != cudaSuccess) { 219 if (cudaStatus != cudaSuccess) {
187 LOG_ERROR("[{}]- CUDAToBGR failed !!!", m_name.c_str()); 220 LOG_ERROR("[{}]- CUDAToBGR failed !!!", m_name.c_str());
@@ -191,7 +224,7 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) @@ -191,7 +224,7 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame )
191 frame->width = gpuFrame->width; 224 frame->width = gpuFrame->width;
192 frame->height = gpuFrame->height; 225 frame->height = gpuFrame->height;
193 frame->size = rgbSize; 226 frame->size = rgbSize;
194 - frame->frame = pHwData; 227 + frame->frame = m_pHwData;
195 frame->timestamp = decodedFrame->ts; 228 frame->timestamp = decodedFrame->ts;
196 229
197 delete decodedFrame; 230 delete decodedFrame;
@@ -200,12 +233,14 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame ) @@ -200,12 +233,14 @@ int DxDecoderWrap::DxLockFrame( DxGPUFrame * frame )
200 return 0; 233 return 0;
201 } 234 }
202 235
203 -void DxDecoderWrap::post_decode_thread(GPUFrame * gpuFrame) { 236 +void DxDecoderWrap::post_decode_thread(GPUFrame * decodedFrame) {
204 while(!m_bClose) { 237 while(!m_bClose) {
205 m_queue_frames_mutex.lock(); 238 m_queue_frames_mutex.lock();
206 if(m_queue_frames.size() < 3) { 239 if(m_queue_frames.size() < 3) {
207 - m_queue_frames.push(gpuFrame); 240 + // 入队
  241 + m_queue_frames.push(decodedFrame);
208 m_queue_frames_mutex.unlock(); 242 m_queue_frames_mutex.unlock();
  243 + break;
209 } else { 244 } else {
210 m_queue_frames_mutex.unlock(); 245 m_queue_frames_mutex.unlock();
211 std::this_thread::sleep_for(std::chrono::milliseconds(10)); 246 std::this_thread::sleep_for(std::chrono::milliseconds(10));
@@ -214,5 +249,5 @@ void DxDecoderWrap::post_decode_thread(GPUFrame * gpuFrame) { @@ -214,5 +249,5 @@ void DxDecoderWrap::post_decode_thread(GPUFrame * gpuFrame) {
214 } 249 }
215 250
216 void DxDecoderWrap::decode_finished_thread() { 251 void DxDecoderWrap::decode_finished_thread() {
217 - 252 + m_bClose = true;
218 } 253 }
219 \ No newline at end of file 254 \ No newline at end of file
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/DxDecoderWrap.h
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 typedef struct DxConfig 16 typedef struct DxConfig
17 { 17 {
18 int devId; // 设备(GPU)ID 18 int devId; // 设备(GPU)ID
19 - int decMode; // 解码模式 19 + int decMode; // 解码模式: 0 全解码; 1 关键帧解码
20 int colorFmt; // 颜色空间 20 int colorFmt; // 颜色空间
21 bool forceTcp; // 对于实时流,是否强制为TCP取流 21 bool forceTcp; // 对于实时流,是否强制为TCP取流
22 std::string name; 22 std::string name;
@@ -58,7 +58,7 @@ public: @@ -58,7 +58,7 @@ public:
58 58
59 int DxGetResolution( int * width, int * height ); 59 int DxGetResolution( int * width, int * height );
60 60
61 - bool DxFrameIsEmpty() const; 61 + bool DxFrameIsEmpty();
62 int DxLockFrame( DxGPUFrame * frame ); 62 int DxLockFrame( DxGPUFrame * frame );
63 63
64 int PauseDecoder(); 64 int PauseDecoder();
@@ -72,8 +72,6 @@ public: @@ -72,8 +72,6 @@ public:
72 private: 72 private:
73 bool m_bClose; 73 bool m_bClose;
74 74
75 - DxGPUFrames m_frames;  
76 -  
77 FFDecConfig m_cfg; 75 FFDecConfig m_cfg;
78 string m_name; 76 string m_name;
79 FFNvDecoder* m_pDec; 77 FFNvDecoder* m_pDec;
@@ -81,7 +79,10 @@ private: @@ -81,7 +79,10 @@ private:
81 std::queue<GPUFrame *> m_queue_frames; 79 std::queue<GPUFrame *> m_queue_frames;
82 std::mutex m_queue_frames_mutex; 80 std::mutex m_queue_frames_mutex;
83 81
84 - unsigned char *pHwData {nullptr}; 82 + unsigned char *m_pHwData {nullptr};
  83 + CUcontext m_cuda_cxt;
  84 +
  85 + int m_decMode{0};
85 }; 86 };
86 87
87 #endif 88 #endif
88 \ No newline at end of file 89 \ No newline at end of file
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.cpp
@@ -59,14 +59,14 @@ bool FFNvDecoder::init(FFDecConfig&amp; cfg) @@ -59,14 +59,14 @@ bool FFNvDecoder::init(FFDecConfig&amp; cfg)
59 { 59 {
60 m_cfg = cfg; 60 m_cfg = cfg;
61 61
62 - // todo : fstream判断错误  
63 - fstream infile(cfg.uri);  
64 - if (infile.is_open()){ 62 + FILE* fp;
  63 + fp=fopen(cfg.uri.c_str(),"rb");
  64 + if(fp!=nullptr) {
65 m_bReal = false; 65 m_bReal = false;
66 - infile.close();  
67 - }else { 66 + } else {
68 m_bReal = true; 67 m_bReal = true;
69 } 68 }
  69 + fclose(fp);
70 70
71 post_decoded_cbk = cfg.post_decoded_cbk; 71 post_decoded_cbk = cfg.post_decoded_cbk;
72 decode_finished_cbk = cfg.decode_finished_cbk; 72 decode_finished_cbk = cfg.decode_finished_cbk;
@@ -119,6 +119,7 @@ bool FFNvDecoder::init(const char* uri, const char* gpuid, bool force_tcp) @@ -119,6 +119,7 @@ bool FFNvDecoder::init(const char* uri, const char* gpuid, bool force_tcp)
119 return false; 119 return false;
120 120
121 m_fps = av_q2d(stream ->avg_frame_rate); 121 m_fps = av_q2d(stream ->avg_frame_rate);
  122 + m_nb_frames = stream->nb_frames;
122 123
123 avctx->opaque = this; 124 avctx->opaque = this;
124 // 设置解码器管理器的像素格式回调函数 125 // 设置解码器管理器的像素格式回调函数
@@ -197,6 +198,7 @@ void FFNvDecoder::decode_thread() @@ -197,6 +198,7 @@ void FFNvDecoder::decode_thread()
197 198
198 // long start_time = get_cur_time(); 199 // long start_time = get_cur_time();
199 200
  201 + unsigned long long index = 0;
200 while (m_bRunning) 202 while (m_bRunning)
201 { 203 {
202 if (!m_bReal) 204 if (!m_bReal)
@@ -220,15 +222,10 @@ void FFNvDecoder::decode_thread() @@ -220,15 +222,10 @@ void FFNvDecoder::decode_thread()
220 if (result == AVERROR_EOF || result < 0) 222 if (result == AVERROR_EOF || result < 0)
221 { 223 {
222 av_packet_unref(pkt); 224 av_packet_unref(pkt);
223 - LOG_ERROR("Failed to read frame!"); 225 + LOG_INFO("Failed to read frame!");
224 break; 226 break;
225 } 227 }
226 228
227 - if (m_dec_keyframe && !(pkt->flags & AV_PKT_FLAG_KEY)) {  
228 - av_packet_unref(pkt);  
229 - continue;  
230 - }  
231 -  
232 if (m_bReal) 229 if (m_bReal)
233 { 230 {
234 if (m_bPause) 231 if (m_bPause)
@@ -240,6 +237,14 @@ void FFNvDecoder::decode_thread() @@ -240,6 +237,14 @@ void FFNvDecoder::decode_thread()
240 } 237 }
241 238
242 if (stream_index == pkt->stream_index){ 239 if (stream_index == pkt->stream_index){
  240 +
  241 + index++;
  242 +
  243 + if (m_dec_keyframe && !(pkt->flags & AV_PKT_FLAG_KEY)) {
  244 + av_packet_unref(pkt);
  245 + continue;
  246 + }
  247 +
243 result = avcodec_send_packet(avctx, pkt); 248 result = avcodec_send_packet(avctx, pkt);
244 if (result < 0){ 249 if (result < 0){
245 av_packet_unref(pkt); 250 av_packet_unref(pkt);
@@ -260,7 +265,10 @@ void FFNvDecoder::decode_thread() @@ -260,7 +265,10 @@ void FFNvDecoder::decode_thread()
260 if(gpuFrame != nullptr){ 265 if(gpuFrame != nullptr){
261 m_queue_mutex.lock(); 266 m_queue_mutex.lock();
262 if(mFrameQueue.size() <= 10){ 267 if(mFrameQueue.size() <= 10){
263 - mFrameQueue.push(gpuFrame); 268 + GPUFrame* frame = new GPUFrame();
  269 + frame->ts = index;
  270 + frame->gpuFrame = gpuFrame;
  271 + mFrameQueue.push(frame);
264 }else{ 272 }else{
265 av_frame_free(&gpuFrame); 273 av_frame_free(&gpuFrame);
266 } 274 }
@@ -286,8 +294,9 @@ void FFNvDecoder::decode_thread() @@ -286,8 +294,9 @@ void FFNvDecoder::decode_thread()
286 294
287 // 清空队列 295 // 清空队列
288 while(mFrameQueue.size() > 0){ 296 while(mFrameQueue.size() > 0){
289 - AVFrame * gpuFrame = mFrameQueue.front();  
290 - av_frame_free(&gpuFrame); 297 + GPUFrame * frame = mFrameQueue.front();
  298 + delete frame;
  299 + frame = nullptr;
291 mFrameQueue.pop(); 300 mFrameQueue.pop();
292 } 301 }
293 302
@@ -323,18 +332,15 @@ void FFNvDecoder::post_decode_thread(){ @@ -323,18 +332,15 @@ void FFNvDecoder::post_decode_thread(){
323 std::lock_guard<std::mutex> l(m_snapshot_mutex); 332 std::lock_guard<std::mutex> l(m_snapshot_mutex);
324 // 取队头数据 333 // 取队头数据
325 m_queue_mutex.lock(); 334 m_queue_mutex.lock();
326 - AVFrame * gpuFrame = mFrameQueue.front(); 335 + GPUFrame* frame = mFrameQueue.front();
327 mFrameQueue.pop(); 336 mFrameQueue.pop();
328 m_queue_mutex.unlock(); 337 m_queue_mutex.unlock();
329 // 跳帧 338 // 跳帧
330 if (skip_frame == 1 || index % skip_frame == 0){ 339 if (skip_frame == 1 || index % skip_frame == 0){
331 - GPUFrame* frame = new GPUFrame();  
332 - frame->ts = index;  
333 - frame->gpuFrame = gpuFrame;  
334 post_decoded_cbk(m_postDecArg, frame); 340 post_decoded_cbk(m_postDecArg, frame);
335 } 341 }
336 342
337 - av_frame_free(&gpuFrame); 343 + // av_frame_free(&gpuFrame);
338 344
339 index++; 345 index++;
340 } 346 }
@@ -403,6 +409,5 @@ float FFNvDecoder::fps(){ @@ -403,6 +409,5 @@ float FFNvDecoder::fps(){
403 } 409 }
404 410
405 unsigned long long FFNvDecoder::GetFrameCount() { 411 unsigned long long FFNvDecoder::GetFrameCount() {
406 - // todo  
407 - return 1; 412 + return m_nb_frames;
408 } 413 }
409 \ No newline at end of file 414 \ No newline at end of file
vehicle_structure_platform.git0708-3080-trt-face/src/FFNvDecoder/FFNvDecoder.h
@@ -60,4 +60,5 @@ private: @@ -60,4 +60,5 @@ private:
60 bool m_bReal; // 是否实时流 60 bool m_bReal; // 是否实时流
61 61
62 float m_fps; 62 float m_fps;
  63 + unsigned long long m_nb_frames;
63 }; 64 };
64 \ No newline at end of file 65 \ No newline at end of file
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.h
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #include <vector> 3 #include <vector>
4 #include "common.h" 4 #include "common.h"
5 #include <mutex> 5 #include <mutex>
6 -#include "../DxDecoder/DxDecoderWrap.h" 6 +#include "../FFNvDecoder/DxDecoderWrap.h"
7 using std::map; 7 using std::map;
8 using std::vector; 8 using std::vector;
9 class ImageSaveCache 9 class ImageSaveCache
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp
@@ -394,7 +394,6 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) @@ -394,7 +394,6 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID)
394 tasks[i].taskObjCallbackFunc = nullptr; 394 tasks[i].taskObjCallbackFunc = nullptr;
395 tasks[i].taskRealTimeCallbackFunc = nullptr; 395 tasks[i].taskRealTimeCallbackFunc = nullptr;
396 396
397 -  
398 m_snaphot_helper.finish_task_ss_analysis(taskID, m_hp_analysis_config, m_hcp_analysis_config, m_vehicle_analysis_config, m_hf_recg_config, m_hcf_recg_config, m_vcf_recg_config); //�Ƿ�����������ʶ��); 397 m_snaphot_helper.finish_task_ss_analysis(taskID, m_hp_analysis_config, m_hcp_analysis_config, m_vehicle_analysis_config, m_hf_recg_config, m_hcf_recg_config, m_vcf_recg_config); //�Ƿ�����������ʶ��);
399 398
400 if (tasks[i].folderName) 399 if (tasks[i].folderName)
@@ -488,11 +487,15 @@ void CMutliSourceVideoProcess::FinishViewTask() @@ -488,11 +487,15 @@ void CMutliSourceVideoProcess::FinishViewTask()
488 printf("-----------------------finish view task-----------------------\n"); 487 printf("-----------------------finish view task-----------------------\n");
489 } 488 }
490 489
491 -  
492 -//bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* resultFolderLittle, const char* resultFolder, const char* resultFolderface, bool on_image_display, sy_rect minBoxsize[DETECTTYPE], VIDEO_OBJECT_SNAPSHOT_CALLBACK objCallbackFunc/* = NULL*/, VIDEO_REALTIME_CALLBACK realTimeCallbackFunc/* = NULL*/)  
493 -bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* resultFolderLittle, const char* resultFolder, const char* resultFolderface, bool on_image_display, int jpeg_quality, sy_rect minBoxsize[DETECTTYPE], VIDEO_OBJECT_SNAPSHOT_CALLBACK objCallbackFunc/* = NULL*/, VIDEO_REALTIME_CALLBACK realTimeCallbackFunc/* = NULL*/) //debug by zsh 490 +bool CMutliSourceVideoProcess::AddTask(task_param tparam) //debug by zsh
494 { 491 {
495 - //checkGpuMem(); 492 + const char* videoFileName = tparam.video_filename;
  493 + const char* resultFolderLittle = tparam.result_folder_little;
  494 + const char* resultFolder = tparam.result_folder;
  495 + const char* resultFolderface = tparam.result_folder_face;
  496 + VIDEO_OBJECT_SNAPSHOT_CALLBACK objCallbackFunc = tparam.obj_snapshot_callback_func;
  497 + VIDEO_REALTIME_CALLBACK realTimeCallbackFunc = tparam.rt_view_callback_func;
  498 +
496 std::lock_guard<std::mutex> l(_tx_add_task); 499 std::lock_guard<std::mutex> l(_tx_add_task);
497 using std::placeholders::_1; 500 using std::placeholders::_1;
498 // printf("begin real add task\n"); 501 // printf("begin real add task\n");
@@ -503,31 +506,16 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re @@ -503,31 +506,16 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re
503 VPTResult.resize(capacity); 506 VPTResult.resize(capacity);
504 } 507 }
505 508
506 - string sVideoFileName = videoFileName;  
507 -  
508 - string target = "file://";  
509 - int pos = sVideoFileName.find(target);  
510 - if (pos == 0) {  
511 - int n = target.size();  
512 - sVideoFileName = sVideoFileName.erase(pos, n);  
513 - }  
514 - pos = sVideoFileName.find_first_of('?');  
515 - if (pos != string::npos) {  
516 - sVideoFileName = sVideoFileName.substr(0, pos);  
517 - }  
518 -  
519 Task new_task = {}; 509 Task new_task = {};
520 new_task.taskID = TotalTask; 510 new_task.taskID = TotalTask;
521 new_task.taskFileSource = videoFileName; 511 new_task.taskFileSource = videoFileName;
522 - memcpy(new_task.task_min_boxsize, minBoxsize, sizeof(sy_rect)* DETECTTYPE);  
523 - 512 + memcpy(new_task.task_min_boxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE);
524 513
525 DxConfig cfg = { 0 }; 514 DxConfig cfg = { 0 };
526 cfg.devId = mgpuid; 515 cfg.devId = mgpuid;
527 - cfg.decMode = 0;  
528 - cfg.colorFmt = 0;  
529 cfg.forceTcp = false; 516 cfg.forceTcp = false;
530 - cfg.type = DX_DECODER_TYPE_SFXLAB; 517 + cfg.decMode = tparam.decMode;
  518 + cfg.name = std::to_string(new_task.taskID);
531 new_task.taskTcuvid = new DxDecoderWrap(&cfg); 519 new_task.taskTcuvid = new DxDecoderWrap(&cfg);
532 if (NULL == new_task.taskTcuvid) 520 if (NULL == new_task.taskTcuvid)
533 { 521 {
@@ -631,8 +619,8 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re @@ -631,8 +619,8 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re
631 new_task_info.snapshot_folder = new_task.folderNameLittle; 619 new_task_info.snapshot_folder = new_task.folderNameLittle;
632 new_task_info.snapshot_folder_face = new_task.folderNameFace; 620 new_task_info.snapshot_folder_face = new_task.folderNameFace;
633 new_task_info.task_total_framecount = new_task.taskTotalFrameCount; 621 new_task_info.task_total_framecount = new_task.taskTotalFrameCount;
634 - new_task_info._on_image_display = on_image_display;  
635 - new_task_info.jpeg_quality_ = jpeg_quality; //debug by zsh 622 + new_task_info._on_image_display = tparam.on_image_display;
  623 + new_task_info.jpeg_quality_ = tparam.jpeg_quality; //debug by zsh
636 new_task_info.obj_callback = new_task.taskObjCallbackFunc; 624 new_task_info.obj_callback = new_task.taskObjCallbackFunc;
637 m_snaphot_helper.add_task_info(new_task.taskID, new_task_info); 625 m_snaphot_helper.add_task_info(new_task.taskID, new_task_info);
638 626
@@ -640,20 +628,8 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re @@ -640,20 +628,8 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re
640 TaskinPlay++; 628 TaskinPlay++;
641 tasks.push_back(new_task); 629 tasks.push_back(new_task);
642 630
643 - // printf("finish push tasks\n");  
644 -  
645 - //return 1;  
646 - //std::cout<<__LINE__<<"of"<<__FILE__<<"debug\n";  
647 - if (!ProcessFlag)  
648 - {  
649 - /*for (int num = 0; num < 5; ++num)  
650 - {*/  
651 - //create_thread()��һ���������������Դ���thead���������̣߳�ͬʱ�����ڲ���list  
652 - // group.create_thread(boost::bind(&runchild , num)) ;  
653 - //saveSnapshotsThreadGroup.create_thread(boost::bind(SnapshotThreadProcess, this, 0));  
654 - //} 631 + if (!ProcessFlag) {
655 ProcessThread = boost::thread(ThreadProcess, this); 632 ProcessThread = boost::thread(ThreadProcess, this);
656 - //std::cout << "begin algorithm" << std::endl;  
657 ProcessFlag = true; 633 ProcessFlag = true;
658 } 634 }
659 635
@@ -668,8 +644,7 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) @@ -668,8 +644,7 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam)
668 644
669 if (!ProcessFlag) 645 if (!ProcessFlag)
670 { 646 {
671 - //AddTask(tparam.video_filename, tparam.result_folder_little, tparam.result_folder, tparam.result_folder_face, tparam.on_image_display, tparam.minBoxsize, tparam.obj_snapshot_callback_func, tparam.rt_view_callback_func);  
672 - AddTask(tparam.video_filename, tparam.result_folder_little, tparam.result_folder, tparam.result_folder_face, tparam.on_image_display, tparam.jpeg_quality, tparam.minBoxsize, tparam.obj_snapshot_callback_func, tparam.rt_view_callback_func); //debug by zsh 647 + AddTask(tparam);
673 boost::thread::sleep(boost::get_system_time() + boost::posix_time::microseconds(500)); 648 boost::thread::sleep(boost::get_system_time() + boost::posix_time::microseconds(500));
674 } 649 }
675 else 650 else
@@ -680,12 +655,14 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam) @@ -680,12 +655,14 @@ int CMutliSourceVideoProcess::AddOperator(task_param tparam)
680 Operator newOper; 655 Operator newOper;
681 newOper.changeTaskID = 0; 656 newOper.changeTaskID = 0;
682 newOper.changeTaskOperator = ADDTASK; 657 newOper.changeTaskOperator = ADDTASK;
683 - newOper.videoFileName = tparam.video_filename;  
684 - newOper.resultFolderLittleName = tparam.result_folder_little;  
685 - newOper.result_folder_face = tparam.result_folder_face;  
686 - newOper.resultFolderName = tparam.result_folder; 658 +
  659 + strcpy(newOper.videoFileName, tparam.video_filename);
  660 + strcpy(newOper.resultFolderLittleName, tparam.result_folder_little);
  661 + strcpy(newOper.resultFolderName, tparam.result_folder);
  662 + strcpy(newOper.result_folder_face, tparam.result_folder_face);
687 newOper.on_image_display = tparam.on_image_display; 663 newOper.on_image_display = tparam.on_image_display;
688 - newOper.jpeg_quality = tparam.jpeg_quality; //debug by zsh 664 + newOper.jpeg_quality = tparam.jpeg_quality;
  665 + newOper.decMode = tparam.decMode;
689 newOper.taskObjCallbackFunc = tparam.obj_snapshot_callback_func; 666 newOper.taskObjCallbackFunc = tparam.obj_snapshot_callback_func;
690 newOper.taskRealTimeCallbackFunc = tparam.rt_view_callback_func; 667 newOper.taskRealTimeCallbackFunc = tparam.rt_view_callback_func;
691 memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE); 668 memcpy(newOper.minBoxsize, tparam.minBoxsize, sizeof(sy_rect)* DETECTTYPE);
@@ -741,7 +718,6 @@ void CMutliSourceVideoProcess::AddOperator(int taskID, int taskOper) @@ -741,7 +718,6 @@ void CMutliSourceVideoProcess::AddOperator(int taskID, int taskOper)
741 Operator newOper = {}; 718 Operator newOper = {};
742 newOper.changeTaskID = taskID; 719 newOper.changeTaskID = taskID;
743 newOper.changeTaskOperator = TaskOperator(taskOper); 720 newOper.changeTaskOperator = TaskOperator(taskOper);
744 - newOper.videoFileName = NULL;  
745 //TaskOperatorQ.push(newOper); 721 //TaskOperatorQ.push(newOper);
746 TaskOperatorQ.push_back(newOper); 722 TaskOperatorQ.push_back(newOper);
747 } 723 }
@@ -757,8 +733,20 @@ void CMutliSourceVideoProcess::OperatorTask() @@ -757,8 +733,20 @@ void CMutliSourceVideoProcess::OperatorTask()
757 switch (newOperator.changeTaskOperator) 733 switch (newOperator.changeTaskOperator)
758 { 734 {
759 case ADDTASK: 735 case ADDTASK:
760 - //AddTask(newOperator.videoFileName, newOperator.resultFolderLittleName, newOperator.resultFolderName, newOperator.result_folder_face, newOperator.on_image_display, newOperator.minBoxsize, newOperator.taskObjCallbackFunc, newOperator.taskRealTimeCallbackFunc);  
761 - AddTask(newOperator.videoFileName, newOperator.resultFolderLittleName, newOperator.resultFolderName, newOperator.result_folder_face, newOperator.on_image_display, newOperator.jpeg_quality, newOperator.minBoxsize, newOperator.taskObjCallbackFunc, newOperator.taskRealTimeCallbackFunc); //debug by zsh 736 + {
  737 + task_param tparam;
  738 + strcpy(tparam.video_filename, newOperator.videoFileName);
  739 + strcpy(tparam.result_folder_little, newOperator.resultFolderLittleName);
  740 + strcpy(tparam.result_folder, newOperator.resultFolderName);
  741 + strcpy(tparam.result_folder_face, newOperator.result_folder_face);
  742 + tparam.on_image_display = newOperator.on_image_display;
  743 + tparam.jpeg_quality = newOperator.jpeg_quality;
  744 + memcpy(tparam.minBoxsize, newOperator.minBoxsize, sizeof(sy_rect)* DETECTTYPE);
  745 + tparam.obj_snapshot_callback_func = newOperator.taskObjCallbackFunc;
  746 + tparam.rt_view_callback_func = newOperator.taskRealTimeCallbackFunc;
  747 + tparam.decMode = newOperator.decMode;
  748 + AddTask(tparam);
  749 + }
762 break; 750 break;
763 case PAUSETASK: 751 case PAUSETASK:
764 PauseTask(newOperator.changeTaskID); 752 PauseTask(newOperator.changeTaskID);
@@ -1031,44 +1019,9 @@ DWORD ThreadProcess(LPVOID param) @@ -1031,44 +1019,9 @@ DWORD ThreadProcess(LPVOID param)
1031 { 1019 {
1032 if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun()) 1020 if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun())
1033 { 1021 {
1034 - if (pThreadParam->tasks[i].taskTcuvid->DxLockFrame(&frame) == 0)  
1035 - {  
1036 - if (!pThreadParam->tasks[i].task_algorithm_data.frame && frame.width > 0 && frame.height > 0)  
1037 - {  
1038 - cudaError_t cudaStatus = cudaMalloc((void**)&pThreadParam->tasks[i].task_algorithm_data.frame, 3 * frame.size * frame.height * sizeof(unsigned char));  
1039 - if (cudaStatus != cudaSuccess) {  
1040 - fprintf(stderr, "here cudaMalloc m_pRGBData[0] failed! error: %s\n", cudaGetErrorString(cudaStatus));  
1041 - break;  
1042 - }  
1043 -  
1044 - pThreadParam->tasks[i].task_algorithm_data.height = frame.height;  
1045 - pThreadParam->tasks[i].task_algorithm_data.width = frame.width;  
1046 - pThreadParam->tasks[i].task_algorithm_data.size = frame.size;  
1047 -  
1048 - pThreadParam->tasks[i].frameImage = cv::Mat::zeros(frame.height, frame.width, CV_8UC3);  
1049 - pThreadParam->tasks[i].taskDataToRT = (float*)malloc(3 * frame.height * frame.width * sizeof(unsigned char));  
1050 - AddTaskTracker(pThreadParam->VPT_Handle, pThreadParam->tasks[i].taskID, 1, 1);  
1051 - }  
1052 -  
1053 - //copy decode data  
1054 - if (pThreadParam->tasks[i].task_algorithm_data.frame)  
1055 - {  
1056 - int height = frame.height;  
1057 - int width = frame.width;  
1058 -  
1059 - Nv12ToColor24<BGR24>( (unsigned char *)frame.frame, width, (unsigned char *)pThreadParam->tasks[i].task_algorithm_data.frame, 3 * width, width, height, 0 );  
1060 -  
1061 - pThreadParam->tasks[i].task_algorithm_data.timestamp = frame.timestamp;  
1062 -  
1063 - k.insert(i);  
1064 - pThreadParam->TaskinPlayID.insert(pThreadParam->tasks[i].taskID);  
1065 - }  
1066 - else  
1067 - {  
1068 - std::cout << "NOT ALLOC: pThreadParam->tasks[i].taskDataToBackup.frame" << pThreadParam->tasks[i].task_algorithm_data.frame << std::endl;  
1069 - }  
1070 -  
1071 - pThreadParam->tasks[i].taskTcuvid->DxUnlockFrame(); 1022 + if(pThreadParam->tasks[i].taskTcuvid->DxLockFrame(&pThreadParam->tasks[i].task_algorithm_data) == 0) {
  1023 + k.insert(i);
  1024 + pThreadParam->TaskinPlayID.insert(pThreadParam->tasks[i].taskID);
1072 } 1025 }
1073 } 1026 }
1074 else if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && !pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun()) 1027 else if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && !pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun())
@@ -1756,7 +1709,7 @@ DWORD ThreadProcess(LPVOID param) @@ -1756,7 +1709,7 @@ DWORD ThreadProcess(LPVOID param)
1756 vector<int>().swap(deleteObjectID[i]); 1709 vector<int>().swap(deleteObjectID[i]);
1757 vector<vector<int>>().swap(deleteObjectID); 1710 vector<vector<int>>().swap(deleteObjectID);
1758 1711
1759 - // pThreadParam->m_snaphot_helper.object_attri_analysis(); 1712 + pThreadParam->m_snaphot_helper.object_attri_analysis();
1760 1713
1761 #ifdef LOG_INFO2 1714 #ifdef LOG_INFO2
1762 long long second_analysis_time2 = get_cur_time_ms(); 1715 long long second_analysis_time2 = get_cur_time_ms();
@@ -1788,7 +1741,7 @@ DWORD ThreadProcess(LPVOID param) @@ -1788,7 +1741,7 @@ DWORD ThreadProcess(LPVOID param)
1788 } 1741 }
1789 long long costTime1 = get_cur_time_ms() - begintime1; 1742 long long costTime1 = get_cur_time_ms() - begintime1;
1790 std::cout << "==================== Process Thread is Finished: " << std::endl; 1743 std::cout << "==================== Process Thread is Finished: " << std::endl;
1791 - printf("total frame cost time = %lld us, process times: %d \n", costTime1, process_times); 1744 + printf("total frame cost time = %lld us, process times: %d total_count: %d \n", costTime1, process_times, total_count);
1792 1745
1793 pThreadParam->m_snaphot_helper.snapShotInfo.clear(); 1746 pThreadParam->m_snaphot_helper.snapShotInfo.clear();
1794 pThreadParam->ProcessFlag = false; 1747 pThreadParam->ProcessFlag = false;
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp.FFNvDecoder renamed to vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp.qx
@@ -524,8 +524,10 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re @@ -524,8 +524,10 @@ bool CMutliSourceVideoProcess::AddTask(const char* videoFileName, const char* re
524 524
525 DxConfig cfg = { 0 }; 525 DxConfig cfg = { 0 };
526 cfg.devId = mgpuid; 526 cfg.devId = mgpuid;
  527 + cfg.decMode = 0;
  528 + cfg.colorFmt = 0;
527 cfg.forceTcp = false; 529 cfg.forceTcp = false;
528 - cfg.name = std::to_string(new_task.taskID); 530 + cfg.type = DX_DECODER_TYPE_SFXLAB;
529 new_task.taskTcuvid = new DxDecoderWrap(&cfg); 531 new_task.taskTcuvid = new DxDecoderWrap(&cfg);
530 if (NULL == new_task.taskTcuvid) 532 if (NULL == new_task.taskTcuvid)
531 { 533 {
@@ -1029,49 +1031,45 @@ DWORD ThreadProcess(LPVOID param) @@ -1029,49 +1031,45 @@ DWORD ThreadProcess(LPVOID param)
1029 { 1031 {
1030 if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun()) 1032 if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun())
1031 { 1033 {
1032 - if(pThreadParam->tasks[i].taskTcuvid->DxLockFrame(&pThreadParam->tasks[i].task_algorithm_data) == 0) {  
1033 - k.insert(i);  
1034 - pThreadParam->TaskinPlayID.insert(pThreadParam->tasks[i].taskID); 1034 + if (pThreadParam->tasks[i].taskTcuvid->DxLockFrame(&frame) == 0)
  1035 + {
  1036 + if (!pThreadParam->tasks[i].task_algorithm_data.frame && frame.width > 0 && frame.height > 0)
  1037 + {
  1038 + cudaError_t cudaStatus = cudaMalloc((void**)&pThreadParam->tasks[i].task_algorithm_data.frame, 3 * frame.size * frame.height * sizeof(unsigned char));
  1039 + if (cudaStatus != cudaSuccess) {
  1040 + fprintf(stderr, "here cudaMalloc m_pRGBData[0] failed! error: %s\n", cudaGetErrorString(cudaStatus));
  1041 + break;
  1042 + }
  1043 +
  1044 + pThreadParam->tasks[i].task_algorithm_data.height = frame.height;
  1045 + pThreadParam->tasks[i].task_algorithm_data.width = frame.width;
  1046 + pThreadParam->tasks[i].task_algorithm_data.size = frame.size;
  1047 +
  1048 + pThreadParam->tasks[i].frameImage = cv::Mat::zeros(frame.height, frame.width, CV_8UC3);
  1049 + pThreadParam->tasks[i].taskDataToRT = (float*)malloc(3 * frame.height * frame.width * sizeof(unsigned char));
  1050 + AddTaskTracker(pThreadParam->VPT_Handle, pThreadParam->tasks[i].taskID, 1, 1);
  1051 + }
  1052 +
  1053 + //copy decode data
  1054 + if (pThreadParam->tasks[i].task_algorithm_data.frame)
  1055 + {
  1056 + int height = frame.height;
  1057 + int width = frame.width;
  1058 +
  1059 + Nv12ToColor24<BGR24>( (unsigned char *)frame.frame, width, (unsigned char *)pThreadParam->tasks[i].task_algorithm_data.frame, 3 * width, width, height, 0 );
  1060 +
  1061 + pThreadParam->tasks[i].task_algorithm_data.timestamp = frame.timestamp;
  1062 +
  1063 + k.insert(i);
  1064 + pThreadParam->TaskinPlayID.insert(pThreadParam->tasks[i].taskID);
  1065 + }
  1066 + else
  1067 + {
  1068 + std::cout << "NOT ALLOC: pThreadParam->tasks[i].taskDataToBackup.frame" << pThreadParam->tasks[i].task_algorithm_data.frame << std::endl;
  1069 + }
  1070 +
  1071 + pThreadParam->tasks[i].taskTcuvid->DxUnlockFrame();
1035 } 1072 }
1036 - // if (pThreadParam->tasks[i].taskTcuvid->DxLockFrame(&frame) == 0)  
1037 - // {  
1038 - // if (!pThreadParam->tasks[i].task_algorithm_data.frame && frame.width > 0 && frame.height > 0)  
1039 - // {  
1040 - // cudaError_t cudaStatus = cudaMalloc((void**)&pThreadParam->tasks[i].task_algorithm_data.frame, 3 * frame.size * frame.height * sizeof(unsigned char));  
1041 - // if (cudaStatus != cudaSuccess) {  
1042 - // fprintf(stderr, "here cudaMalloc m_pRGBData[0] failed! error: %s\n", cudaGetErrorString(cudaStatus));  
1043 - // break;  
1044 - // }  
1045 -  
1046 - // pThreadParam->tasks[i].task_algorithm_data.height = frame.height;  
1047 - // pThreadParam->tasks[i].task_algorithm_data.width = frame.width;  
1048 - // pThreadParam->tasks[i].task_algorithm_data.size = frame.size;  
1049 -  
1050 - // pThreadParam->tasks[i].frameImage = cv::Mat::zeros(frame.height, frame.width, CV_8UC3);  
1051 - // pThreadParam->tasks[i].taskDataToRT = (float*)malloc(3 * frame.height * frame.width * sizeof(unsigned char));  
1052 - // AddTaskTracker(pThreadParam->VPT_Handle, pThreadParam->tasks[i].taskID, 1, 1);  
1053 - // }  
1054 -  
1055 - // //copy decode data  
1056 - // if (pThreadParam->tasks[i].task_algorithm_data.frame)  
1057 - // {  
1058 - // int height = frame.height;  
1059 - // int width = frame.width;  
1060 -  
1061 - // Nv12ToColor24<BGR24>( (unsigned char *)frame.frame, width, (unsigned char *)pThreadParam->tasks[i].task_algorithm_data.frame, 3 * width, width, height, 0 );  
1062 -  
1063 - // pThreadParam->tasks[i].task_algorithm_data.timestamp = frame.timestamp;  
1064 -  
1065 - // k.insert(i);  
1066 - // pThreadParam->TaskinPlayID.insert(pThreadParam->tasks[i].taskID);  
1067 - // }  
1068 - // else  
1069 - // {  
1070 - // std::cout << "NOT ALLOC: pThreadParam->tasks[i].taskDataToBackup.frame" << pThreadParam->tasks[i].task_algorithm_data.frame << std::endl;  
1071 - // }  
1072 -  
1073 - // pThreadParam->tasks[i].taskTcuvid->DxUnlockFrame();  
1074 - // }  
1075 } 1073 }
1076 else if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && !pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun()) 1074 else if (k.find(i) == k.end() && pThreadParam->tasks[i].taskState == PLAY && !pThreadParam->tasks[i].taskTcuvid->DxDecoderIsRun())
1077 { 1075 {
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.h
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <iostream> 6 #include <iostream>
7 7
8 -#include "../DxDecoder/DxDecoderWrap.h" 8 +#include "../FFNvDecoder/DxDecoderWrap.h"
9 #include "nvml.h" 9 #include "nvml.h"
10 #include "time.h" 10 #include "time.h"
11 #include "opencv2/opencv.hpp" 11 #include "opencv2/opencv.hpp"
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 #include <set> 15 #include <set>
16 #include <boost/thread/thread.hpp> 16 #include <boost/thread/thread.hpp>
17 #include "common.h" 17 #include "common.h"
18 -#include "../DxDecoder/ImageSaveGPU.h" 18 +#include "../FFNvDecoder/ImageSaveGPU.h"
19 19
20 #include "mvpt_process_assist.h" 20 #include "mvpt_process_assist.h"
21 #include <boost/thread/thread_pool.hpp> 21 #include <boost/thread/thread_pool.hpp>
@@ -173,12 +173,13 @@ enum TaskOperator @@ -173,12 +173,13 @@ enum TaskOperator
173 173
174 struct Operator{ 174 struct Operator{
175 int changeTaskID; 175 int changeTaskID;
176 - const char* videoFileName;  
177 - const char* resultFolderLittleName;  
178 - const char* resultFolderName;  
179 - const char* result_folder_face; 176 + char videoFileName[256];
  177 + char resultFolderLittleName[256];
  178 + char resultFolderName[256];
  179 + char result_folder_face[256];
180 bool on_image_display; 180 bool on_image_display;
181 - int jpeg_quality; //ͼƬ���������IJ���0-100 --debug by zsh 181 + int jpeg_quality;
  182 + int decMode;
182 183
183 TaskOperator changeTaskOperator; 184 TaskOperator changeTaskOperator;
184 VIDEO_OBJECT_SNAPSHOT_CALLBACK taskObjCallbackFunc; 185 VIDEO_OBJECT_SNAPSHOT_CALLBACK taskObjCallbackFunc;
@@ -220,8 +221,7 @@ public: @@ -220,8 +221,7 @@ public:
220 void AddOperator(int taskID, int taskOper); 221 void AddOperator(int taskID, int taskOper);
221 int AddOperator(task_param tparam); 222 int AddOperator(task_param tparam);
222 void callTaskObjInfoCallbackFunc(int objCount, VPT_ObjInfo *obj, int taskFrameCount, int taskId); 223 void callTaskObjInfoCallbackFunc(int objCount, VPT_ObjInfo *obj, int taskFrameCount, int taskId);
223 - //bool AddTask(const char* videoFileName, const char* resultFolderLittle, const char* resultFolder, const char* resultFolderface, bool on_image_display, sy_rect minBoxsize[DETECTTYPE], VIDEO_OBJECT_SNAPSHOT_CALLBACK objCallbackFunc = NULL, VIDEO_REALTIME_CALLBACK realTimeCallbackFunc = NULL);  
224 - bool AddTask(const char* videoFileName, const char* resultFolderLittle, const char* resultFolder, const char* resultFolderface, bool on_image_display, int jpeg_quality, sy_rect minBoxsize[DETECTTYPE], VIDEO_OBJECT_SNAPSHOT_CALLBACK objCallbackFunc = NULL, VIDEO_REALTIME_CALLBACK realTimeCallbackFunc = NULL); //debug by zsh 224 + bool AddTask(task_param tparam);
225 void PauseTask(const int taskID); 225 void PauseTask(const int taskID);
226 void RestartTask(const int taskID); 226 void RestartTask(const int taskID);
227 void FinishTask(const int taskID); 227 void FinishTask(const int taskID);
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/header.h
@@ -224,18 +224,19 @@ typedef void(*VIDEO_FINISH_CALLBACK)(void * handle, const int task_id); @@ -224,18 +224,19 @@ typedef void(*VIDEO_FINISH_CALLBACK)(void * handle, const int task_id);
224 #define __TASK_PARAM__ 224 #define __TASK_PARAM__
225 typedef struct task_param 225 typedef struct task_param
226 { 226 {
227 - const char* video_filename;  
228 - const char* result_folder_little;  
229 - const char* result_folder;  
230 - const char* result_folder_face; 227 + char video_filename[256];
  228 + char result_folder_little[256];
  229 + char result_folder[256];
  230 + char result_folder_face[256];
231 bool on_image_display; //是否绘制结果框到保存大图 231 bool on_image_display; //是否绘制结果框到保存大图
232 int jpeg_quality; //图片保存质量的参数0-100 --debug by zsh 232 int jpeg_quality; //图片保存质量的参数0-100 --debug by zsh
  233 + int decMode; // 解码模式: 0 全解码; 1 关键帧解码
233 sy_rect minBoxsize[DETECTTYPE]; //自定义的minBoxsize大小 234 sy_rect minBoxsize[DETECTTYPE]; //自定义的minBoxsize大小
234 VIDEO_OBJECT_SNAPSHOT_CALLBACK obj_snapshot_callback_func; 235 VIDEO_OBJECT_SNAPSHOT_CALLBACK obj_snapshot_callback_func;
235 VIDEO_REALTIME_CALLBACK rt_view_callback_func; 236 VIDEO_REALTIME_CALLBACK rt_view_callback_func;
236 237
237 //task_param() : video_filename(0), result_folder_little(0), result_folder(0), result_folder_face(0) {} 238 //task_param() : video_filename(0), result_folder_little(0), result_folder(0), result_folder_face(0) {}
238 - task_param() : video_filename(0), result_folder_little(0), result_folder(0), result_folder_face(0), jpeg_quality(30) {} //debug by zsh 239 + task_param() : jpeg_quality(30) {} //debug by zsh
239 }task_param; 240 }task_param;
240 #endif 241 #endif
241 242
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/SnapShotFrameCache.h
1 #pragma once 1 #pragma once
2 -#include "../DxDecoder/DxDecoderWrap.h" 2 +#include "../FFNvDecoder/DxDecoderWrap.h"
3 #include <queue> 3 #include <queue>
4 #define SHOT_CACHE_SIZE 4 #define SHOT_CACHE_SIZE
5 #define VEHICLE_WIDTH 320 5 #define VEHICLE_WIDTH 320
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.h
1 #include <bitset> 1 #include <bitset>
2 -#include "../../DxDecoder/DxDecoderWrap.h" 2 +#include "../../FFNvDecoder/DxDecoderWrap.h"
3 #include "common.h" 3 #include "common.h"
4 #include <queue> 4 #include <queue>
5 #include <string> 5 #include <string>
vehicle_structure_platform.git0708-3080-trt-face/src/test/main.cpp
@@ -667,9 +667,45 @@ void videoFinishCallback(void * handle, const int taskID) @@ -667,9 +667,45 @@ void videoFinishCallback(void * handle, const int taskID)
667 // } 667 // }
668 } 668 }
669 669
670 - 670 +//操作句柄
  671 +void *handle;
671 static int total_index = 0; 672 static int total_index = 0;
672 673
  674 +void create_task(const char * videoFileName, int total_index) {
  675 + //指定检测目标视频抽帧图片(保存时显存占用很大)
  676 + char resultFolder[256];
  677 + sprintf(resultFolder, "snapshots/res_0308/%d", total_index);
  678 + //指定检测目标快照抠图保存路径
  679 + char resultFolderLittle[256];
  680 + sprintf(resultFolderLittle, "snapshots/resLittle_0308/%d", total_index);
  681 +
  682 + char resultFolderLittleface[256];
  683 + sprintf(resultFolderLittleface, "snapshots/resLittle_face/%d", total_index);
  684 +
  685 + task_param tparam;
  686 + strcpy(tparam.result_folder, resultFolder);
  687 + strcpy(tparam.result_folder_little, resultFolderLittle);
  688 + strcpy(tparam.result_folder_face, resultFolderLittleface);
  689 + strcpy(tparam.video_filename, videoFileName);
  690 + tparam.on_image_display = false;
  691 + tparam.jpeg_quality = 30; //debug by zsh
  692 + tparam.decMode = 1; // 关键帧解码
  693 +
  694 + //tparam.video_filename = argv[total_index%4];
  695 + memcpy(tparam.minBoxsize, m_boxsize, sizeof(sy_rect)* DETECTTYPE);
  696 + tparam.rt_view_callback_func = videoRTViewCallback;
  697 + tparam.obj_snapshot_callback_func = videoObjSnapshotCallback;
  698 +
  699 + for (int tmp = 0; tmp < 10; tmp ++) {
  700 + string tmp_path = "results/" + vpt_types[tmp];
  701 + CreateResultFolder((char*)tmp_path.c_str(), "");
  702 + }
  703 +
  704 + int newTaskID = add_task(handle, tparam);
  705 + cout << "==============================开始任务ID: " << newTaskID << " ============================" << endl;
  706 + cur_task_status_.insert(make_pair(newTaskID, FALSE));
  707 +}
  708 +
673 int main(int argc, char* argv[]) 709 int main(int argc, char* argv[])
674 { 710 {
675 if (argc<4) 711 if (argc<4)
@@ -680,26 +716,24 @@ int main(int argc, char* argv[]) @@ -680,26 +716,24 @@ int main(int argc, char* argv[])
680 const char * videoFileName = argv[1]; 716 const char * videoFileName = argv[1];
681 addTaskCount = atoi(argv[2]); 717 addTaskCount = atoi(argv[2]);
682 int gpuID = atoi(argv[3]); 718 int gpuID = atoi(argv[3]);
683 - //操作句柄  
684 - void *handle;  
685 719
686 //初始化参数设置 720 //初始化参数设置
687 mvpt_param vptParam; 721 mvpt_param vptParam;
688 - vptParam.hp_analysis_config = SY_CONFIG_CLOSE;  
689 - vptParam.hcp_analysis_config = SY_CONFIG_CLOSE;  
690 - vptParam.vehicle_analysis_config = SY_CONFIG_CLOSE;  
691 - vptParam.hf_recg_config = SY_CONFIG_CLOSE;  
692 - vptParam.hcf_recg_config = SY_CONFIG_CLOSE;  
693 - vptParam.vcf_recg_config = SY_CONFIG_CLOSE;  
694 - vptParam.face_det_config = SY_CONFIG_CLOSE;  
695 -  
696 - // vptParam.hp_analysis_config = SY_CONFIG_OPEN;  
697 - // vptParam.hcp_analysis_config = SY_CONFIG_OPEN; 722 + // vptParam.hp_analysis_config = SY_CONFIG_CLOSE;
  723 + // vptParam.hcp_analysis_config = SY_CONFIG_CLOSE;
  724 + // vptParam.vehicle_analysis_config = SY_CONFIG_CLOSE;
  725 + // vptParam.hf_recg_config = SY_CONFIG_CLOSE;
  726 + // vptParam.hcf_recg_config = SY_CONFIG_CLOSE;
  727 + // vptParam.vcf_recg_config = SY_CONFIG_CLOSE;
  728 + // vptParam.face_det_config = SY_CONFIG_CLOSE;
  729 +
  730 + vptParam.hp_analysis_config = SY_CONFIG_OPEN;
  731 + vptParam.hcp_analysis_config = SY_CONFIG_OPEN;
698 vptParam.vehicle_analysis_config = SY_CONFIG_OPEN; 732 vptParam.vehicle_analysis_config = SY_CONFIG_OPEN;
699 - // vptParam.hf_recg_config = SY_CONFIG_OPEN;  
700 - // vptParam.hcf_recg_config = SY_CONFIG_OPEN;  
701 - // vptParam.vcf_recg_config = SY_CONFIG_OPEN;  
702 - // vptParam.face_det_config = SY_CONFIG_OPEN; 733 + vptParam.hf_recg_config = SY_CONFIG_OPEN;
  734 + vptParam.hcf_recg_config = SY_CONFIG_OPEN;
  735 + vptParam.vcf_recg_config = SY_CONFIG_OPEN;
  736 + vptParam.face_det_config = SY_CONFIG_OPEN;
703 737
704 vptParam.vrdbpath = argv[4]; 738 vptParam.vrdbpath = argv[4];
705 //vptParam.vrdbpath = "../../db/mvpt.bin"; 739 //vptParam.vrdbpath = "../../db/mvpt.bin";
@@ -730,46 +764,23 @@ int main(int argc, char* argv[]) @@ -730,46 +764,23 @@ int main(int argc, char* argv[])
730 continue; 764 continue;
731 } 765 }
732 766
  767 + // create_task("/home/cmhu/data/video/duan1.avi", total_index);
  768 +
  769 + // usleep(40000);
  770 +
  771 + // create_task("/home/cmhu/data/video/Street.uvf", total_index);
  772 +
733 for (int i = 0; i < addTaskCount; i++) { 773 for (int i = 0; i < addTaskCount; i++) {
734 774
735 - //指定检测目标视频抽帧图片(保存时显存占用很大)  
736 - char resultFolder[260];  
737 - sprintf(resultFolder, "snapshots/res_0308/%d", total_index);  
738 - //指定检测目标快照抠图保存路径  
739 - char resultFolderLittle[260];  
740 - sprintf(resultFolderLittle, "snapshots/resLittle_0308/%d", total_index);  
741 -  
742 - char resultFolderLittleface[260];  
743 - sprintf(resultFolderLittleface, "snapshots/resLittle_face/%d", total_index);  
744 -  
745 - task_param tparam;  
746 - tparam.result_folder = resultFolder;  
747 - tparam.result_folder_little = resultFolderLittle;  
748 - tparam.result_folder_face = resultFolderLittleface;  
749 - tparam.video_filename = videoFileName;  
750 - tparam.on_image_display = false;  
751 - tparam.jpeg_quality = 30; //debug by zsh  
752 -  
753 - //tparam.video_filename = argv[total_index%4];  
754 - memcpy(tparam.minBoxsize, m_boxsize, sizeof(sy_rect)* DETECTTYPE);  
755 - tparam.rt_view_callback_func = videoRTViewCallback;  
756 - tparam.obj_snapshot_callback_func = videoObjSnapshotCallback;  
757 -  
758 - for (int tmp = 0; tmp < 10; tmp ++) {  
759 - string tmp_path = "results/" + vpt_types[tmp];  
760 - CreateResultFolder((char*)tmp_path.c_str(), "");  
761 - } 775 + create_task(videoFileName, total_index);
  776 +
  777 + total_index++ ;
762 778
763 - int newTaskID = add_task(handle, tparam);  
764 - cout << "==============================开始任务ID: " << newTaskID << " ============================" << endl;  
765 - cur_task_status_.insert(make_pair(newTaskID, FALSE));  
766 #ifdef _MSC_VER 779 #ifdef _MSC_VER
767 Sleep(2000); 780 Sleep(2000);
768 #else 781 #else
769 usleep(40000); 782 usleep(40000);
770 - #endif  
771 -  
772 - total_index++ ; 783 + #endif
773 } 784 }
774 } while(0) ; 785 } while(0) ;
775 786
@@ -843,20 +854,20 @@ int main(int argc, char* argv[]) @@ -843,20 +854,20 @@ int main(int argc, char* argv[])
843 itor = cur_task_status_.erase(itor); 854 itor = cur_task_status_.erase(itor);
844 855
845 //指定检测目标视频抽帧图片(保存时显存占用很大) 856 //指定检测目标视频抽帧图片(保存时显存占用很大)
846 - char resultFolder[260]; 857 + char resultFolder[256];
847 sprintf(resultFolder, "res/%d", total_index); 858 sprintf(resultFolder, "res/%d", total_index);
848 //指定检测目标快照抠图保存路径 859 //指定检测目标快照抠图保存路径
849 - char resultFolderLittle[260]; 860 + char resultFolderLittle[256];
850 sprintf(resultFolderLittle, "resLittle/%d", total_index); 861 sprintf(resultFolderLittle, "resLittle/%d", total_index);
851 862
852 - char resultFolderLittleface[260]; 863 + char resultFolderLittleface[256];
853 sprintf(resultFolderLittleface, "resLittle_face/%d", total_index++); 864 sprintf(resultFolderLittleface, "resLittle_face/%d", total_index++);
854 865
855 task_param tparam; 866 task_param tparam;
856 - tparam.result_folder = resultFolder;  
857 - tparam.result_folder_little = resultFolderLittle;  
858 - tparam.result_folder_face = resultFolderLittleface;  
859 - tparam.video_filename = videoFileName; 867 + strcpy(tparam.result_folder, resultFolder);
  868 + strcpy(tparam.result_folder_little, resultFolderLittle);
  869 + strcpy(tparam.result_folder_face, resultFolderLittleface);
  870 + strcpy(tparam.video_filename, videoFileName);
860 memcpy(tparam.minBoxsize, m_boxsize, sizeof(sy_rect)* DETECTTYPE); 871 memcpy(tparam.minBoxsize, m_boxsize, sizeof(sy_rect)* DETECTTYPE);
861 tparam.rt_view_callback_func = videoRTViewCallback; 872 tparam.rt_view_callback_func = videoRTViewCallback;
862 tparam.obj_snapshot_callback_func = videoObjSnapshotCallback; 873 tparam.obj_snapshot_callback_func = videoObjSnapshotCallback;