Commit a38411f0248b7c7e0b00fe650cfe95056b31d460
Merge branch 'dev-cmhu'
Showing
16 changed files
with
362 additions
and
58 deletions
.vscode/launch.json
... | ... | @@ -23,10 +23,10 @@ |
23 | 23 | } |
24 | 24 | ] |
25 | 25 | },{ |
26 | - "name": "test", | |
26 | + "name": "test_face", | |
27 | 27 | "type": "cppdbg", |
28 | 28 | "request": "launch", |
29 | - "program": "${workspaceFolder}/bin/test", | |
29 | + "program": "${workspaceFolder}/bin/test_face", | |
30 | 30 | "args": ["/opt/cmhu/data/Street.uvf","0", "0", "0"], |
31 | 31 | "stopAtEntry": false, |
32 | 32 | "cwd": "${workspaceFolder}/bin", | ... | ... |
src/ai_platform/MultiSourceProcess.cpp
... | ... | @@ -736,8 +736,6 @@ int CMultiSourceProcess::algorthim_vpt(vector<DeviceMemory*> vec_gpuMem){ |
736 | 736 | /* for pedestrian safety det. 行人安全分析算法模块 */ |
737 | 737 | // algorthim_pedestrian_safety(vpt_interest_task_id, vpt_interest_imgs,vptResult); |
738 | 738 | |
739 | - // 农村违法分析的快照缓存 | |
740 | - m_snapshot_reprocessing->update_village_bestsnapshot(vec_vptMem, vptResult, deleteObjectID); | |
741 | 739 | // 逆行 |
742 | 740 | algorthim_retrograde(vpt_interest_task_id, vec_vptMem, vptResult); |
743 | 741 | retrograde_snapshot(vpt_interest_task_id, deleteObjectID); |
... | ... | @@ -745,6 +743,11 @@ int CMultiSourceProcess::algorthim_vpt(vector<DeviceMemory*> vec_gpuMem){ |
745 | 743 | algorthim_trespass(vpt_interest_task_id, vec_vptMem, vptResult, deleteObjectID); |
746 | 744 | trespass_snapshot(vpt_interest_task_id, deleteObjectID); |
747 | 745 | |
746 | +// #endif | |
747 | + | |
748 | +#ifdef USE_VILLAGE | |
749 | + // 农村违法分析的快照缓存 | |
750 | + m_snapshot_reprocessing->update_village_bestsnapshot(vec_vptMem, vptResult, deleteObjectID); | |
748 | 751 | // 三轮车载人 |
749 | 752 | algorithm_tricycle_manned(vpt_interest_task_id, vec_vptMem, vptResult); |
750 | 753 | // 货车载人 |
... | ... | @@ -752,8 +755,7 @@ int CMultiSourceProcess::algorthim_vpt(vector<DeviceMemory*> vec_gpuMem){ |
752 | 755 | // 二轮车超员/未戴盔 |
753 | 756 | algorithm_motor_hs_process(vpt_interest_task_id, vec_vptMem, vptResult); |
754 | 757 | manned_snapshot(vpt_interest_task_id, vec_vptMem, deleteObjectID); |
755 | - | |
756 | -// #endif | |
758 | +#endif | |
757 | 759 | |
758 | 760 | // if(vptResult.size() > 0){ |
759 | 761 | // cout << vptResult[0].obj_count<< endl; | ... | ... |
src/decoder/Makefile
... | ... | @@ -6,15 +6,16 @@ PROJECT_ROOT= /opt/cmhu/vpt_ascend_arm |
6 | 6 | DEPEND_DIR = $(PROJECT_ROOT)/bin |
7 | 7 | SRC_ROOT = $(PROJECT_ROOT)/src |
8 | 8 | |
9 | -TARGET= $(PROJECT_ROOT)/bin/test_recoder | |
9 | +TARGET= $(PROJECT_ROOT)/bin/test_face | |
10 | 10 | |
11 | 11 | THIRDPARTY_ROOT = $(PROJECT_ROOT)/3rdparty |
12 | 12 | SPDLOG_ROOT = $(THIRDPARTY_ROOT)/spdlog-1.9.2/release |
13 | 13 | OPENCV_ROOT = $(THIRDPARTY_ROOT)/opencv_4_1 |
14 | 14 | JSON_ROOT = $(THIRDPARTY_ROOT)/jsoncpp-1.9.5/release |
15 | 15 | FFMPEG_ROOT = $(THIRDPARTY_ROOT)/ffmpeg-4.4.4/release |
16 | +RABBITMQ_CLIENT_ROOT = $(THIRDPARTY_ROOT)/rabbitmq-c-0.11.0/release | |
16 | 17 | |
17 | -DEFS = -DENABLE_DVPP_INTERFACE | |
18 | +DEFS = -DENABLE_DVPP_INTERFACE -DWITH_FACE_DET_SS -DPOST_USE_RABBITMQ | |
18 | 19 | |
19 | 20 | include_dir=-I/usr/local/Ascend/ascend-toolkit/6.3.RC1/aarch64-linux/include \ |
20 | 21 | -I $(SPDLOG_ROOT)/include \ |
... | ... | @@ -22,6 +23,7 @@ include_dir=-I/usr/local/Ascend/ascend-toolkit/6.3.RC1/aarch64-linux/include \ |
22 | 23 | -I $(OPENCV_ROOT)/include \ |
23 | 24 | -I $(JSON_ROOT)/include \ |
24 | 25 | -I $(FFMPEG_ROOT)/include \ |
26 | + -I $(RABBITMQ_CLIENT_ROOT)/include \ | |
25 | 27 | |
26 | 28 | lib_dir=-L/usr/local/Ascend/ascend-toolkit/6.3.RC1/runtime/lib64 \ |
27 | 29 | -L/usr/local/Ascend/ascend-toolkit/latest/lib64 \ |
... | ... | @@ -32,14 +34,25 @@ lib_dir=-L/usr/local/Ascend/ascend-toolkit/6.3.RC1/runtime/lib64 \ |
32 | 34 | lib=-lacl_dvpp -lascendcl -lacl_dvpp_mpi -lruntime -lascendalog -lc_sec -lmsprofiler -lgert -lmmpa -lascend_hal -lexe_graph -lge_executor -lgraph -lprofapi -lascend_protobuf -lerror_manager -lhybrid_executor -lregister -ldavinci_executor -lge_common -lge_common_base \ |
33 | 35 | -lplatform -lgraph_base -lqos_manager |
34 | 36 | |
35 | -LIBS= -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ | |
37 | +LIBS= -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \ | |
38 | + -L $(DEPEND_DIR) -lvpt_det_vdec -lsycheck -lface_det_vdec -lhs_tri_process -lhs_truck_process -lhs_motor_process\ | |
39 | + -L $(OPENCV_ROOT)/lib -lopencv_world\ | |
40 | + -L $(JSON_ROOT)/lib -ljsoncpp \ | |
41 | + -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ | |
42 | + -L $(RABBITMQ_CLIENT_ROOT)/lib/aarch64-linux-gnu -lrabbitmq \ | |
36 | 43 | |
37 | 44 | CXXFLAGS= -g -O0 -fPIC $(include_dir) $(lib_dir) $(lib) $(LIBS) $(DEFS) -lpthread -lrt -lz -fexceptions -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fvisibility=hidden -Wall -Wno-deprecated -Wdeprecated-declarations -Wl,-Bsymbolic -ldl |
38 | 45 | |
39 | 46 | |
40 | 47 | |
41 | -SRCS:=$(wildcard $(SRC_ROOT)/decoder/interface/*.cpp) \ | |
48 | +SRCS:=$(wildcard $(SRC_ROOT)/ai_platform/*.cpp) \ | |
49 | + $(wildcard $(SRC_ROOT)/decoder/interface/*.cpp) \ | |
42 | 50 | $(wildcard $(SRC_ROOT)/decoder/dvpp/*.cpp) \ |
51 | + $(wildcard $(SRC_ROOT)/ai_engine_module/sort/*.cpp) \ | |
52 | + $(wildcard $(SRC_ROOT)/ai_engine_module/*.cpp) \ | |
53 | + $(wildcard $(SRC_ROOT)/util/*.cpp) \ | |
54 | + $(wildcard $(SRC_ROOT)/reprocessing_module/*.cpp) \ | |
55 | + $(wildcard $(SRC_ROOT)/reprocessing_module/rbmq/*.cpp) \ | |
43 | 56 | $(wildcard $(SRC_ROOT)/decoder/*.cpp) \ |
44 | 57 | |
45 | 58 | OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS))) |
... | ... | @@ -56,8 +69,26 @@ $(TARGET):$(OBJS) |
56 | 69 | %.o:$(SRC_ROOT)/decoder/interface/%.cpp |
57 | 70 | $(XX) $(CXXFLAGS) -c $< |
58 | 71 | |
72 | +%.o:$(SRC_ROOT)/ai_platform/%.cpp | |
73 | + $(XX) $(CXXFLAGS) -c $< | |
74 | + | |
75 | +%.o:$(SRC_ROOT)/ai_engine_module/sort/%.cpp | |
76 | + $(XX) $(CXXFLAGS) -c $< | |
77 | + | |
78 | +%.o:$(SRC_ROOT)/ai_engine_module/%.cpp | |
79 | + $(XX) $(CXXFLAGS) -c $< | |
80 | + | |
81 | +%.o:$(SRC_ROOT)/util/%.cpp | |
82 | + $(XX) $(CXXFLAGS) -c $< | |
83 | + | |
84 | +%.o:$(SRC_ROOT)/reprocessing_module/%.cpp | |
85 | + $(XX) $(CXXFLAGS) -c $< | |
86 | + | |
87 | +%.o:$(SRC_ROOT)/reprocessing_module/rbmq/%.cpp | |
88 | + $(XX) $(CXXFLAGS) -c $< | |
89 | + | |
59 | 90 | %.o:$(SRC_ROOT)/decoder/%.cpp |
60 | 91 | $(XX) $(CXXFLAGS) -c $< |
61 | 92 | |
62 | 93 | clean: |
63 | - rm -f *.o $(TARGET) | |
64 | 94 | \ No newline at end of file |
95 | + rm -f *.o $(TARGET) | ... | ... |
src/decoder/Makefile_decoder
0 → 100755
1 | +XX = g++ | |
2 | + | |
3 | + | |
4 | +PROJECT_ROOT= /opt/cmhu/vpt_ascend_arm | |
5 | + | |
6 | +DEPEND_DIR = $(PROJECT_ROOT)/bin | |
7 | +SRC_ROOT = $(PROJECT_ROOT)/src | |
8 | + | |
9 | +TARGET= $(PROJECT_ROOT)/bin/test_recoder | |
10 | + | |
11 | +THIRDPARTY_ROOT = $(PROJECT_ROOT)/3rdparty | |
12 | +SPDLOG_ROOT = $(THIRDPARTY_ROOT)/spdlog-1.9.2/release | |
13 | +OPENCV_ROOT = $(THIRDPARTY_ROOT)/opencv_4_1 | |
14 | +JSON_ROOT = $(THIRDPARTY_ROOT)/jsoncpp-1.9.5/release | |
15 | +FFMPEG_ROOT = $(THIRDPARTY_ROOT)/ffmpeg-4.4.4/release | |
16 | + | |
17 | +DEFS = -DENABLE_DVPP_INTERFACE | |
18 | + | |
19 | +include_dir=-I/usr/local/Ascend/ascend-toolkit/6.3.RC1/aarch64-linux/include \ | |
20 | + -I $(SPDLOG_ROOT)/include \ | |
21 | + -I $(SRC_ROOT)/common \ | |
22 | + -I $(OPENCV_ROOT)/include \ | |
23 | + -I $(JSON_ROOT)/include \ | |
24 | + -I $(FFMPEG_ROOT)/include \ | |
25 | + | |
26 | +lib_dir=-L/usr/local/Ascend/ascend-toolkit/6.3.RC1/runtime/lib64 \ | |
27 | + -L/usr/local/Ascend/ascend-toolkit/latest/lib64 \ | |
28 | + -L/usr/local/Ascend/ascend-toolkit/latest/runtime/lib64 \ | |
29 | + -L/usr/local/Ascend/ascend-toolkit/latest/acllib/lib64 \ | |
30 | + -L/usr/local/Ascend/ascend-toolkit/6.3.RC1/runtime/lib64/stub \ | |
31 | + | |
32 | +lib=-lacl_dvpp -lascendcl -lacl_dvpp_mpi -lruntime -lascendalog -lc_sec -lmsprofiler -lgert -lmmpa -lascend_hal -lexe_graph -lge_executor -lgraph -lprofapi -lascend_protobuf -lerror_manager -lhybrid_executor -lregister -ldavinci_executor -lge_common -lge_common_base \ | |
33 | + -lplatform -lgraph_base -lqos_manager | |
34 | + | |
35 | +LIBS= -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ | |
36 | + | |
37 | +CXXFLAGS= -g -O0 -fPIC $(include_dir) $(lib_dir) $(lib) $(LIBS) $(DEFS) -lpthread -lrt -lz -fexceptions -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fvisibility=hidden -Wall -Wno-deprecated -Wdeprecated-declarations -Wl,-Bsymbolic -ldl | |
38 | + | |
39 | + | |
40 | + | |
41 | +SRCS:=$(wildcard $(SRC_ROOT)/decoder/interface/*.cpp) \ | |
42 | + $(wildcard $(SRC_ROOT)/decoder/dvpp/*.cpp) \ | |
43 | + $(wildcard $(SRC_ROOT)/decoder/*.cpp) \ | |
44 | + | |
45 | +OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS))) | |
46 | + | |
47 | + | |
48 | +$(TARGET):$(OBJS) | |
49 | + rm -f $(TARGET) | |
50 | + $(XX) -o $@ $^ $(CXXFLAGS) | |
51 | + rm -f *.o | |
52 | + | |
53 | +%.o:$(SRC_ROOT)/decoder/dvpp/%.cpp | |
54 | + $(XX) $(CXXFLAGS) -c $< | |
55 | + | |
56 | +%.o:$(SRC_ROOT)/decoder/interface/%.cpp | |
57 | + $(XX) $(CXXFLAGS) -c $< | |
58 | + | |
59 | +%.o:$(SRC_ROOT)/decoder/%.cpp | |
60 | + $(XX) $(CXXFLAGS) -c $< | |
61 | + | |
62 | +clean: | |
63 | + rm -f *.o $(TARGET) | |
0 | 64 | \ No newline at end of file | ... | ... |
src/decoder/dvpp/DvppDecoder.cpp
... | ... | @@ -150,7 +150,9 @@ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ |
150 | 150 | pix_fmt = (AVPixelFormat)codecpar->format; |
151 | 151 | m_fps = av_q2d(stream ->avg_frame_rate); |
152 | 152 | |
153 | +#ifdef USE_VILLAGE | |
153 | 154 | m_recoderManager.init(stream, avctx); |
155 | +#endif | |
154 | 156 | |
155 | 157 | LOG_INFO("[{}]- init ffmpeg success! input:{} frame_width:{} frame_height:{} fps:{} ", m_dec_name, input_file, frame_width, frame_height, m_fps); |
156 | 158 | |
... | ... | @@ -397,7 +399,9 @@ void DvppDecoder::read_thread() { |
397 | 399 | } |
398 | 400 | |
399 | 401 | frame_nb++; |
402 | +#ifdef USE_VILLAGE | |
400 | 403 | m_recoderManager.cache_pkt(pkt, frame_nb); |
404 | +#endif | |
401 | 405 | |
402 | 406 | m_pktQueue_mutex.lock(); |
403 | 407 | DataPacket* data_pkt = new DataPacket(); | ... | ... |
src/decoder/dvpp/FFRecoderTaskManager.cpp
src/decoder/dvpp/VpcPicConverter.cpp
... | ... | @@ -13,11 +13,12 @@ VpcPicConverter::~VpcPicConverter(){ |
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
16 | -int VpcPicConverter::init(aclrtContext context, string dec_name){ | |
16 | +int VpcPicConverter::init(){ | |
17 | 17 | |
18 | - m_dec_name = dec_name; | |
18 | + aclrtSetDevice(m_devId); | |
19 | + aclrtCreateContext(&context_, m_devId); | |
19 | 20 | |
20 | - CHECK_AND_RETURN(aclrtSetCurrentContext(context), "aclrtSetCurrentContext failed"); | |
21 | + CHECK_AND_RETURN(aclrtSetCurrentContext(context_), "aclrtSetCurrentContext failed"); | |
21 | 22 | CHECK_AND_RETURN(aclrtCreateStream(&stream_), "aclrtCreateStream failed! "); |
22 | 23 | |
23 | 24 | dvppChannelDesc_ = acldvppCreateChannelDesc(); |
... | ... | @@ -37,6 +38,9 @@ int VpcPicConverter::init(aclrtContext context, string dec_name){ |
37 | 38 | |
38 | 39 | DvppDataMemory* VpcPicConverter::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, int out_height, bool key_frame){ |
39 | 40 | |
41 | + aclrtSetDevice(m_devId); | |
42 | + aclrtSetCurrentContext(context_); | |
43 | + | |
40 | 44 | int out_buf_width = ALIGN_UP(out_width, 16) * 3; |
41 | 45 | int out_buf_height = ALIGN_UP(out_height, 2); |
42 | 46 | int out_buf_size = out_buf_width * out_buf_height; |
... | ... | @@ -76,4 +80,64 @@ DvppDataMemory* VpcPicConverter::convert2bgr(acldvppPicDesc *inputDesc_, int out |
76 | 80 | } |
77 | 81 | |
78 | 82 | return rgbMem; |
83 | +} | |
84 | + | |
85 | +DvppDataMemory* VpcPicConverter::convert2bgr(DvppDataMemory* inMem){ | |
86 | + | |
87 | + aclrtSetDevice(m_devId); | |
88 | + aclrtSetCurrentContext(context_); | |
89 | + | |
90 | + int out_width = inMem->getWidth(); | |
91 | + int out_height = inMem->getHeight(); | |
92 | + | |
93 | + | |
94 | + acldvppPicDesc *inputDesc_= acldvppCreatePicDesc(); | |
95 | + acldvppSetPicDescData(inputDesc_, inMem->getMem()); | |
96 | + acldvppSetPicDescFormat(inputDesc_, PIXEL_FORMAT_YUV_SEMIPLANAR_420); | |
97 | + acldvppSetPicDescWidth(inputDesc_, out_width); | |
98 | + acldvppSetPicDescHeight(inputDesc_, out_height); | |
99 | + acldvppSetPicDescWidthStride(inputDesc_, inMem->getWidthStride()); | |
100 | + acldvppSetPicDescHeightStride(inputDesc_, inMem->getHeightStride()); | |
101 | + acldvppSetPicDescSize(inputDesc_, inMem->getSize()); | |
102 | + | |
103 | + int out_buf_width = ALIGN_UP(out_width, 16) * 3; | |
104 | + int out_buf_height = ALIGN_UP(out_height, 2); | |
105 | + int out_buf_size = out_buf_width * out_buf_height; | |
106 | + | |
107 | + DvppDataMemory* rgbMem = new DvppDataMemory(3, out_buf_width, out_buf_width, out_buf_height, out_buf_height, out_buf_size, inMem->getId(), inMem->getDeviceId(), false, inMem->getFrameNb()); | |
108 | + void *outBufferDev_ = (void*)rgbMem->getMem(); | |
109 | + | |
110 | + acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); | |
111 | + acldvppSetPicDescData(outputDesc_, outBufferDev_); | |
112 | + acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); | |
113 | + acldvppSetPicDescWidth(outputDesc_, out_width); | |
114 | + acldvppSetPicDescHeight(outputDesc_, out_height); | |
115 | + acldvppSetPicDescWidthStride(outputDesc_, out_buf_width); | |
116 | + acldvppSetPicDescHeightStride(outputDesc_, out_buf_height); | |
117 | + acldvppSetPicDescSize(outputDesc_, out_buf_size); | |
118 | + | |
119 | + aclError ret = ACL_ERROR_NONE; | |
120 | + do{ | |
121 | + // 9. 执行异步色域转换,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 | |
122 | + ret = acldvppVpcConvertColorAsync(dvppChannelDesc_, inputDesc_, outputDesc_, stream_); | |
123 | + if(ret != ACL_ERROR_NONE){ | |
124 | + LOG_ERROR("acldvppVpcConvertColorAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | |
125 | + break; | |
126 | + } | |
127 | + ret = aclrtSynchronizeStream(stream_); | |
128 | + if(ret != ACL_ERROR_NONE){ | |
129 | + LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); | |
130 | + break; | |
131 | + } | |
132 | + }while(0); | |
133 | + | |
134 | + acldvppDestroyPicDesc(outputDesc_); | |
135 | + acldvppDestroyPicDesc(inputDesc_); | |
136 | + | |
137 | + if(ret != ACL_ERROR_NONE){ | |
138 | + delete rgbMem; | |
139 | + rgbMem = nullptr; | |
140 | + } | |
141 | + | |
142 | + return rgbMem; | |
79 | 143 | } |
80 | 144 | \ No newline at end of file | ... | ... |
src/decoder/dvpp/VpcPicConverter.h
... | ... | @@ -7,9 +7,10 @@ class VpcPicConverter{ |
7 | 7 | public: |
8 | 8 | VpcPicConverter(); |
9 | 9 | ~VpcPicConverter(); |
10 | - int init(aclrtContext context, string dec_name); | |
10 | + int init(); | |
11 | 11 | |
12 | 12 | DvppDataMemory* convert2bgr(acldvppPicDesc *input, int out_width, int out_height, bool key_frame); |
13 | + DvppDataMemory* convert2bgr(DvppDataMemory* inMem); | |
13 | 14 | |
14 | 15 | private: |
15 | 16 | aclrtContext context_; | ... | ... |
src/decoder/test.cpp1 renamed to src/decoder/test_face.cpp
... | ... | @@ -2,10 +2,15 @@ |
2 | 2 | #include <mutex> |
3 | 3 | #include <thread> |
4 | 4 | #include <chrono> |
5 | +#include <string> | |
5 | 6 | |
6 | 7 | #include "acl/acl.h" |
7 | 8 | #include "acl/ops/acl_dvpp.h" |
8 | 9 | |
10 | +#include <opencv2/opencv.hpp> | |
11 | + | |
12 | +#include "../ai_engine_module/face_det_ai_engine.h" | |
13 | + | |
9 | 14 | using namespace std; |
10 | 15 | |
11 | 16 | struct decode_cbk_userdata{ |
... | ... | @@ -22,12 +27,23 @@ bool m_bfinish{false}; |
22 | 27 | int m_devId = 0; |
23 | 28 | const char* task_id = "test0"; |
24 | 29 | int skip_frame_ = 5; |
25 | -int m_batch_size = 20; | |
30 | +int m_batch_size = 10; | |
31 | + | |
32 | +face_det_ai_engine m_face_det_ai_engine; | |
33 | + | |
34 | +aclrtContext ctx; | |
26 | 35 | |
27 | 36 | void algorthim_process_thread(); |
28 | 37 | void algorthim_face_detect(vector<DeviceMemory*> vec_gpuMem); |
29 | 38 | |
30 | -void post_decod_cbk(const void * userPtr, DeviceMemory* devFrame){ | |
39 | +static long long get_cur_time_ms(){ | |
40 | + chrono::time_point<chrono::system_clock, chrono::milliseconds> tpMicro | |
41 | + = chrono::time_point_cast<chrono::milliseconds>(chrono::system_clock::now()); | |
42 | + | |
43 | + return tpMicro.time_since_epoch().count(); | |
44 | +} | |
45 | + | |
46 | +static void post_decod_cbk(const void * userPtr, DeviceMemory* devFrame){ | |
31 | 47 | do{ |
32 | 48 | if(m_bfinish){ |
33 | 49 | break; |
... | ... | @@ -44,7 +60,7 @@ void post_decod_cbk(const void * userPtr, DeviceMemory* devFrame){ |
44 | 60 | }while (true); |
45 | 61 | } |
46 | 62 | |
47 | -void decode_finished_cbk(const void * userPtr){ | |
63 | +static void decode_finished_cbk(const void * userPtr){ | |
48 | 64 | decode_cbk_userdata* ptr = (decode_cbk_userdata*)userPtr; |
49 | 65 | if (ptr!= nullptr){ |
50 | 66 | printf("task finished: %s \n", ptr->task_id.c_str()); |
... | ... | @@ -56,13 +72,31 @@ void decode_finished_cbk(const void * userPtr){ |
56 | 72 | int main(){ |
57 | 73 | |
58 | 74 | // 算法初始化 |
75 | + string models_dir = "."; | |
76 | + | |
77 | + aclInit(nullptr); | |
78 | + aclrtSetDevice(m_devId); | |
79 | + | |
80 | + // 人脸检测初始化 | |
59 | 81 | facedet_ai_engine_param fd_param; |
60 | - fd_param.sdk_param.det_modelNames = "./models/face_detect/face_det_yolov5s_310p.om"; | |
61 | - fd_param.sdk_param.ldmk_modelNames = "./models/face_detect/face_ldmk_310p.om"; | |
62 | - fd_param.sdk_param.pose_modelNames = "./models/face_detect/face_pose_310p.om"; | |
63 | - fd_param.sdk_param.score_modelNames = "./models/face_detect/face_score_310p.om"; | |
64 | - fd_param.sdk_param.fuzzy_modelNames = "./models/face_detect/face_fuzzy_310p.om"; | |
65 | - fd_param.sdk_param.occlusion_modelNames = "./models/face_detect/face_occlusion_310p.om"; | |
82 | + char model_path_yolov5s[100]; | |
83 | + strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str()); | |
84 | + fd_param.sdk_param.det_modelNames = model_path_yolov5s; | |
85 | + char model_path_ldmk[100]; | |
86 | + strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str()); | |
87 | + fd_param.sdk_param.ldmk_modelNames = model_path_ldmk; | |
88 | + char model_path_pose[100]; | |
89 | + strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str()); | |
90 | + fd_param.sdk_param.pose_modelNames = model_path_pose; | |
91 | + char model_path_score[100]; | |
92 | + strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str()); | |
93 | + fd_param.sdk_param.score_modelNames = model_path_score; | |
94 | + char model_path_fuzzy[100]; | |
95 | + strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str()); | |
96 | + fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy; | |
97 | + char model_path_occlusion[100]; | |
98 | + strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str()); | |
99 | + fd_param.sdk_param.occlusion_modelNames = model_path_occlusion; | |
66 | 100 | fd_param.sdk_param.thresld = 0.6; |
67 | 101 | fd_param.sdk_param.devId = m_devId; |
68 | 102 | fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; |
... | ... | @@ -71,11 +105,32 @@ int main(){ |
71 | 105 | fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 |
72 | 106 | fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE |
73 | 107 | fd_param.sdk_param.max_result_count = 50; |
74 | - ret = m_face_det_ai_engine.init_ai_engine(fd_param); | |
108 | + int ret = m_face_det_ai_engine.init_ai_engine(fd_param); | |
75 | 109 | if (ret < 0 ) { |
76 | - printf("Init face detection failed \n"); | |
77 | - return ret; | |
110 | + printf("Init face detection failed"); | |
111 | + return ret; | |
78 | 112 | } |
113 | + | |
114 | + // facedet_ai_engine_param fd_param; | |
115 | + // fd_param.sdk_param.det_modelNames = "./models/face_detect/face_det_yolov5s_310p.om"; | |
116 | + // fd_param.sdk_param.ldmk_modelNames = "./models/face_detect/face_ldmk_310p.om"; | |
117 | + // fd_param.sdk_param.pose_modelNames = "./models/face_detect/face_pose_310p.om"; | |
118 | + // fd_param.sdk_param.score_modelNames = "./models/face_detect/face_score_310p.om"; | |
119 | + // fd_param.sdk_param.fuzzy_modelNames = "./models/face_detect/face_fuzzy_310p.om"; | |
120 | + // fd_param.sdk_param.occlusion_modelNames = "./models/face_detect/face_occlusion_310p.om"; | |
121 | + // fd_param.sdk_param.thresld = 0.6; | |
122 | + // fd_param.sdk_param.devId = m_devId; | |
123 | + // fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; | |
124 | + // fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 | |
125 | + // fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 | |
126 | + // fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 | |
127 | + // fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE | |
128 | + // fd_param.sdk_param.max_result_count = 50; | |
129 | + // int ret = m_face_det_ai_engine.init_ai_engine(fd_param); | |
130 | + // if (ret < 0 ) { | |
131 | + // printf("Init face detection failed \n"); | |
132 | + // return ret; | |
133 | + // } | |
79 | 134 | m_face_det_ai_engine.add_tracker(task_id, skip_frame_); // 跳帧数暂时写死 |
80 | 135 | |
81 | 136 | |
... | ... | @@ -84,7 +139,7 @@ int main(){ |
84 | 139 | |
85 | 140 | MgrDecConfig config; |
86 | 141 | config.name = task_id; |
87 | - config.cfg.uri = "rtsp://admin:ad123456@192.168.60.165:554/cam/realmonitor?channel=1&subtype=0"; | |
142 | + config.cfg.uri = "/opt/share/data/caishenkezhan.mp4"; | |
88 | 143 | config.cfg.post_decoded_cbk = post_decod_cbk; |
89 | 144 | config.cfg.decode_finished_cbk = decode_finished_cbk; |
90 | 145 | config.cfg.force_tcp = true; // rtsp用tcp |
... | ... | @@ -112,10 +167,12 @@ int main(){ |
112 | 167 | |
113 | 168 | // 创建算法线程 |
114 | 169 | m_pAlgorthimThread = new thread([](void* arg) { |
115 | - algorthim_process_thread(); | |
116 | - return (void*)0; | |
117 | - } | |
118 | - , nullptr); | |
170 | + algorthim_process_thread(); | |
171 | + return (void*)0; | |
172 | + } | |
173 | + , nullptr); | |
174 | + | |
175 | + pDecManager->startDecodeByName(config.name); | |
119 | 176 | |
120 | 177 | while (getchar() != 'q'); |
121 | 178 | } |
... | ... | @@ -123,7 +180,6 @@ int main(){ |
123 | 180 | void algorthim_process_thread(){ |
124 | 181 | |
125 | 182 | aclrtSetDevice(m_devId); |
126 | - aclrtContext ctx; | |
127 | 183 | aclrtCreateContext(&ctx, m_devId); |
128 | 184 | |
129 | 185 | while (true){ |
... | ... | @@ -155,6 +211,7 @@ void algorthim_process_thread(){ |
155 | 211 | continue; |
156 | 212 | } |
157 | 213 | |
214 | + aclrtSetCurrentContext(ctx); | |
158 | 215 | algorthim_face_detect(vec_gpuMem); |
159 | 216 | |
160 | 217 | for(int i=0;i < vec_gpuMem.size(); i++){ |
... | ... | @@ -172,8 +229,6 @@ void algorthim_process_thread(){ |
172 | 229 | aclrtDestroyContext(ctx); |
173 | 230 | |
174 | 231 | printf("algorthim_process_thread exit. \n"); |
175 | - | |
176 | - return 0; | |
177 | 232 | } |
178 | 233 | |
179 | 234 | void algorthim_face_detect(vector<DeviceMemory*> vec_gpuMem) { |
... | ... | @@ -181,6 +236,7 @@ void algorthim_face_detect(vector<DeviceMemory*> vec_gpuMem) { |
181 | 236 | vector<string> interest_task_list; |
182 | 237 | vector<sy_img> interest_imgs; |
183 | 238 | vector<DeviceMemory*> vec_vptMem; |
239 | + | |
184 | 240 | for (int i = 0; i < vec_gpuMem.size(); i++) { |
185 | 241 | DeviceMemory* mem = vec_gpuMem[i]; |
186 | 242 | |
... | ... | @@ -194,6 +250,10 @@ void algorthim_face_detect(vector<DeviceMemory*> vec_gpuMem) { |
194 | 250 | vec_vptMem.push_back(mem); |
195 | 251 | } |
196 | 252 | |
253 | + cv::Scalar color; | |
254 | + color[0]=0; | |
255 | + color[1]=0; | |
256 | + color[2]=255; | |
197 | 257 | if (!interest_imgs.empty()) { |
198 | 258 | |
199 | 259 | unsigned image_size = interest_imgs.size(); |
... | ... | @@ -204,14 +264,54 @@ void algorthim_face_detect(vector<DeviceMemory*> vec_gpuMem) { |
204 | 264 | |
205 | 265 | int ret = m_face_det_ai_engine.ai_engine_process_batch(interest_task_list, interest_imgs.data(), facedet_result, face_deleteObjectID); |
206 | 266 | if(ret <= 0){ |
207 | - LOG_ERROR("face detect error!!!"); | |
267 | + printf("face detect error!!! \n"); | |
208 | 268 | return; |
209 | 269 | } |
210 | 270 | |
271 | + | |
272 | + | |
273 | + aclrtSetCurrentContext(ctx); | |
274 | + for(int idx=0; idx < vec_vptMem.size(); idx++){ | |
275 | + | |
276 | + DeviceMemory* memPtr = vec_vptMem[idx]; | |
277 | + string task_id = memPtr->getId(); | |
278 | + int channel = memPtr->getChannel(); | |
279 | + int height = memPtr->getHeight(); | |
280 | + int width = memPtr->getWidth(); | |
281 | + | |
282 | + if (0 == facedet_result[idx].obj_count) { | |
283 | + continue; | |
284 | + } | |
285 | + | |
286 | + int nSize = channel * height * width; | |
287 | + unsigned char* cpu_data = (unsigned char *)malloc(nSize * sizeof(unsigned char)); | |
288 | + aclError aclRet = aclrtMemcpy(cpu_data, nSize, memPtr->getMem(), nSize, ACL_MEMCPY_DEVICE_TO_HOST); | |
289 | + cv::Mat img_(height, width, CV_8UC3, cpu_data); | |
290 | + | |
291 | + for (int c = 0; c < facedet_result[idx].obj_count; c++) { | |
292 | + | |
293 | + det_objinfo obj_info = facedet_result[idx].obj[c]; | |
294 | + string str_obj_id = to_string(obj_info.id); | |
295 | + cv::rectangle(img_,cv::Point(obj_info.left,obj_info.top),cv::Point(obj_info.right,obj_info.bottom),color,2); | |
296 | + cv::putText(img_,str_obj_id.c_str(),cv::Point(obj_info.center_x,obj_info.center_y),cv::FONT_HERSHEY_SIMPLEX,2,cv::Scalar(0,0,255),4,8); | |
297 | + } | |
298 | + | |
299 | + string file_name = "./res/recode/" + task_id + "_" + to_string(memPtr->getFrameNb()) + ".jpg"; | |
300 | + bool bWrite = cv::imwrite(file_name, img_); | |
301 | + | |
302 | + free(cpu_data); | |
303 | + } | |
304 | + | |
305 | + | |
306 | + | |
307 | + | |
308 | + | |
211 | 309 | for (int i = 0; i < face_deleteObjectID.size(); ++i){ |
212 | 310 | std::vector<int>().swap(face_deleteObjectID[i]); |
213 | 311 | } |
214 | 312 | std::vector<std::vector<int>>().swap(face_deleteObjectID); |
215 | 313 | std::vector<onelevel_det_result>().swap(facedet_result); |
216 | 314 | } |
315 | + | |
316 | + aclFinalize(); | |
217 | 317 | } |
218 | 318 | \ No newline at end of file | ... | ... |
src/decoder/test_recoder.cpp renamed to src/decoder/test_recoder.cpp1
src/demo/demo.cpp
... | ... | @@ -651,7 +651,7 @@ string createTask(void *handle, std::vector<algorithm_type_t> algor_vec, int gi) |
651 | 651 | tparam.ipc_url = "rtsp://122.97.218.170:8604/openUrl/V5nXRHa?params=eyJwcm90b2NhbCI6InJ0c3AiLCJjbGllbnRUeXBlIjoib3Blbl9hcGkiLCJleHByaWVUaW1lIjotMSwicHJvdG9jb2wiOiJydHNwIiwiZXhwaXJlVGltZSI6MzAwLCJlbmFibGVNR0MiOnRydWUsImV4cGFuZCI6InN0YW5kYXJkPXJ0c3Amc3RyZWFtZm9ybT1ydHAiLCJhIjoiMTBjZjM4N2JjY2Y5NDg3YzhjNWYzNjE2M2ViMWUyNTJ8MXwwfDEiLCJ0IjoxfQ=="; |
652 | 652 | break; |
653 | 653 | case 4: |
654 | - tparam.ipc_url = "rtsp://admin:ad123456@192.168.60.165:554/cam/realmonitor?channel=1&subtype=0"; | |
654 | + tparam.ipc_url = "rtsp://admin:ad123456@192.168.10.166:554/cam/realmonitor?channel=1&subtype=0"; | |
655 | 655 | break; |
656 | 656 | case 5: |
657 | 657 | tparam.ipc_url = "/opt/share/data/公安局老桥头_CVR15F89410_1465819864_1B.mp4"; |
... | ... | @@ -659,6 +659,9 @@ string createTask(void *handle, std::vector<algorithm_type_t> algor_vec, int gi) |
659 | 659 | case 6: |
660 | 660 | tparam.ipc_url = "/opt/share/data/不带头盔2.mp4"; |
661 | 661 | break; |
662 | + case 7: | |
663 | + tparam.ipc_url = "/opt/share/data/caishenkezhan.mp4"; | |
664 | + break; | |
662 | 665 | default: |
663 | 666 | tparam.ipc_url = "/opt/share/data/Street.uvf"; |
664 | 667 | break; |
... | ... | @@ -730,16 +733,18 @@ void test_gpu(int gpuID){ |
730 | 733 | #endif // #ifdef POST_USE_RABBITMQ |
731 | 734 | |
732 | 735 | std::vector<algorithm_type_t> algor_vec = {algorithm_type_t::FACE_SNAPSHOT, algorithm_type_t::HUMAN_SNAPSHOT,algorithm_type_t::ROAD_WORK_DET, algorithm_type_t::PEDESTRIAN_RETROGRADE, algorithm_type_t::VEHICLE_RETROGRADE, |
733 | - algorithm_type_t::PEDESTRIAN_TRESPASS, algorithm_type_t::VEHICLE_TRESPASS, algorithm_type_t::VEHICLE_SNAPSHOT, algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT, algorithm_type_t::VIDEO_TIMING_SNAPSHOT, algorithm_type_t::VIDEO_SNAPSHOT}; | |
736 | + algorithm_type_t::PEDESTRIAN_TRESPASS, algorithm_type_t::VEHICLE_TRESPASS, algorithm_type_t::VEHICLE_SNAPSHOT, algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT, algorithm_type_t::VIDEO_TIMING_SNAPSHOT | |
737 | + , algorithm_type_t::VIDEO_SNAPSHOT, algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED}; | |
734 | 738 | |
735 | 739 | |
736 | 740 | std::vector<algorithm_type_t> algor_vec2 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED}; |
737 | 741 | // std::vector<algorithm_type_t> algor_vec2 = {algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED}; |
742 | + std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::FACE_SNAPSHOT}; | |
738 | 743 | |
739 | 744 | |
740 | 745 | // string task_id = createTask(handle, algor_vec, 3 + gpuID * 10); |
741 | 746 | string task_id1 = createTask(handle, algor_vec2, 5); |
742 | - string task_id2 = createTask(handle, algor_vec2, 6); | |
747 | + // string task_id2 = createTask(handle, algor_vec, 1); | |
743 | 748 | |
744 | 749 | // test_snapshot(handle); |
745 | 750 | ... | ... |
src/reprocessing_module/save_snapshot_reprocessing.cpp
... | ... | @@ -93,14 +93,15 @@ void save_snapshot_reprocessing::save_img_process() { |
93 | 93 | waitforsave_img_queue.pop(); |
94 | 94 | l.unlock(); |
95 | 95 | |
96 | + bool bSaved = false; | |
96 | 97 | if(!cur_image.file_path.empty()){ |
97 | - jpegUtil.jpeg_encode(cur_image.img_info.pic_desc, cur_image.file_path); | |
98 | + bSaved = jpegUtil.jpeg_encode(cur_image.img_info.pic_desc, cur_image.file_path); | |
98 | 99 | } |
99 | 100 | VPCUtil::vpc_img_release(cur_image.img_info); |
100 | 101 | |
101 | 102 | #ifdef POST_USE_RABBITMQ |
102 | 103 | // LOG_INFO("mq publish process in: {}", cur_image.json_str); |
103 | - if (callback_ != nullptr && cur_image.json_str.length() > 0) { | |
104 | + if (bSaved && callback_ != nullptr && cur_image.json_str.length() > 0) { | |
104 | 105 | // LOG_INFO("mq publish process begin"); |
105 | 106 | callback_(cur_image.json_str.c_str()); |
106 | 107 | LOG_INFO("mq publish process end: {} ", cur_image.json_str); | ... | ... |
src/reprocessing_module/snapshot_reprocessing.cpp
... | ... | @@ -666,6 +666,8 @@ int snapshot_reprocessing::update_face_bestsnapshot(vector<DeviceMemory*> vec_de |
666 | 666 | info.confidence = obj_info.confidence; |
667 | 667 | info.index = obj_info.index; |
668 | 668 | |
669 | + vec_obj_info.push_back(info); | |
670 | + | |
669 | 671 | total_face_snapshot_info[new_obj].obj_pos = { info.left , info.top ,info.right - info.left , info.bottom - info.top }; |
670 | 672 | |
671 | 673 | //存人脸关键点、检测框及大图 | ... | ... |
src/util/JpegUtil.cpp
... | ... | @@ -75,7 +75,7 @@ int32_t JpegUtil::jpege_save(char* pcData , uint32_t dataLen, string out_file_na |
75 | 75 | return 0; |
76 | 76 | } |
77 | 77 | |
78 | -void JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name) { | |
78 | +bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name) { | |
79 | 79 | |
80 | 80 | aclError aclRet ; |
81 | 81 | aclRet = aclrtSetDevice(deviceId_); |
... | ... | @@ -84,23 +84,52 @@ void JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_nam |
84 | 84 | // 8. 申请输出内存,申请Device内存encodeOutBufferDev_,存放编码后的输出数据 |
85 | 85 | uint32_t outBufferSize= 0; |
86 | 86 | int ret = acldvppJpegPredictEncSize(encodeInputDesc_, jpegeConfig_, &outBufferSize); |
87 | + if (ret != ACL_SUCCESS) { | |
88 | + return false; | |
89 | + } | |
87 | 90 | void *encodeOutBufferDev_ = nullptr; |
88 | 91 | ret = acldvppMalloc(&encodeOutBufferDev_, outBufferSize); |
92 | + if (ret != ACL_SUCCESS) { | |
93 | + return false; | |
94 | + } | |
89 | 95 | |
90 | - // 9. 执行异步编码,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 | |
91 | - aclRet = acldvppJpegEncodeAsync(dvppChannelDesc_, encodeInputDesc_, encodeOutBufferDev_, &outBufferSize, jpegeConfig_, stream_); | |
92 | - aclRet = aclrtSynchronizeStream(stream_); | |
96 | + bool bRet = false; | |
97 | + do { | |
98 | + // 9. 执行异步编码,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 | |
99 | + aclRet = acldvppJpegEncodeAsync(dvppChannelDesc_, encodeInputDesc_, encodeOutBufferDev_, &outBufferSize, jpegeConfig_, stream_); | |
100 | + if (ret != ACL_SUCCESS) { | |
101 | + break; | |
102 | + } | |
103 | + aclRet = aclrtSynchronizeStream(stream_); | |
104 | + if (ret != ACL_SUCCESS) { | |
105 | + break; | |
106 | + } | |
93 | 107 | |
94 | - // 该模式下,由于处理结果在Device侧,因此需要调用内存复制接口传输结果数据后,再释放Device侧内存 | |
95 | - // 申请Host内存outputHostBuffer | |
96 | - void* outputHostBuffer = malloc(outBufferSize); | |
97 | - // 通过aclrtMemcpy接口将Device的处理结果数据传输到Host | |
98 | - aclRet = aclrtMemcpy(outputHostBuffer, outBufferSize, encodeOutBufferDev_, outBufferSize, ACL_MEMCPY_DEVICE_TO_HOST); | |
108 | + // 申请Host内存outputHostBuffer | |
109 | + void* outputHostBuffer = malloc(outBufferSize); | |
110 | + | |
111 | + // 通过aclrtMemcpy接口将Device的处理结果数据传输到Host | |
112 | + aclRet = aclrtMemcpy(outputHostBuffer, outBufferSize, encodeOutBufferDev_, outBufferSize, ACL_MEMCPY_DEVICE_TO_HOST); | |
113 | + if (ret != ACL_SUCCESS) { | |
114 | + free(outputHostBuffer); | |
115 | + outputHostBuffer = nullptr; | |
116 | + break; | |
117 | + } | |
118 | + | |
119 | + // 数据使用完成后,释放内存 | |
120 | + ret = jpege_save((char*)outputHostBuffer, outBufferSize, out_file_name); | |
121 | + if(ret != 0) { | |
122 | + free(outputHostBuffer); | |
123 | + outputHostBuffer = nullptr; | |
124 | + break; | |
125 | + } | |
126 | + | |
127 | + bRet = true; | |
128 | + } while (0); | |
129 | + | |
99 | 130 | // 释放掉输入输出的device内存 |
100 | 131 | (void)acldvppFree(encodeOutBufferDev_); |
101 | 132 | encodeOutBufferDev_ = nullptr; |
102 | - // 数据使用完成后,释放内存 | |
103 | - jpege_save((char*)outputHostBuffer, outBufferSize, out_file_name); | |
104 | - free(outputHostBuffer); | |
105 | - outputHostBuffer = nullptr; | |
133 | + | |
134 | + return bRet; | |
106 | 135 | } |
107 | 136 | \ No newline at end of file | ... | ... |
src/util/JpegUtil.h
... | ... | @@ -15,7 +15,7 @@ public: |
15 | 15 | |
16 | 16 | void jpeg_release(); |
17 | 17 | |
18 | - void jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name); | |
18 | + bool jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name); | |
19 | 19 | |
20 | 20 | private: |
21 | 21 | int32_t jpege_save(char* pcData , uint32_t dataLen, string out_file_name); | ... | ... |
src/util/vpc_util.cpp
... | ... | @@ -175,8 +175,10 @@ vector<vpc_img_info> VPCUtil::crop_batch(DeviceMemory *devMem, vector<video_obje |
175 | 175 | for (uint32_t i = 0; i < outputBatchSize_; i++) { |
176 | 176 | video_object_info obj = objs[i]; |
177 | 177 | |
178 | - uint32_t cropSizeWidth = (obj.right - obj.left) / 16 * 16; | |
179 | - uint32_t cropSizeHeight = (obj.bottom - obj.top) / 2 * 2; | |
178 | + // uint32_t cropSizeWidth = (obj.right - obj.left) / 16 * 16; | |
179 | + // uint32_t cropSizeHeight = (obj.bottom - obj.top) / 2 * 2; | |
180 | + uint32_t cropSizeWidth = (obj.right - obj.left + 15) / 16 * 16; //debug by zsh | |
181 | + uint32_t cropSizeHeight = (obj.bottom - obj.top + 1) / 2 * 2; | |
180 | 182 | |
181 | 183 | uint32_t oddNum = 1; |
182 | 184 | uint32_t cropLeftOffset = (obj.left + 1) / 2 * 2; // must even | ... | ... |