Commit ed1887dfb0c7c85107635f7bf1257c267945b18a
1 parent
60108b8b
修复限制目标结果数量导致漏目标情形保存图片报错的问题
Showing
4 changed files
with
48 additions
and
16 deletions
src/ai_platform/MultiSourceProcess.cpp
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | |
29 | 29 | #define WITH_FACE_DET_SS |
30 | 30 | |
31 | -#define AUTHORIZATION | |
31 | +// #define AUTHORIZATION | |
32 | 32 | #define productSN "51C4B28135604F649671727185949A91" //linux 通途抓拍引擎产品序列号 |
33 | 33 | |
34 | 34 | using namespace std; |
... | ... | @@ -507,7 +507,10 @@ int CMultiSourceProcess::snapshot_task(std::string& uri_or_name, const std::stri |
507 | 507 | acldvppSetPicDescHeightStride(vpcDesc, devMem->getHeightStride()); |
508 | 508 | acldvppSetPicDescSize(vpcDesc, devMem->getSize()); |
509 | 509 | |
510 | - jpegUtil.jpeg_encode(vpcDesc, file_name); | |
510 | + bool bSaved = jpegUtil.jpeg_encode(vpcDesc, file_name); | |
511 | + if(!bSaved){ | |
512 | + LOG_ERROR("jpeg_encode failed"); | |
513 | + } | |
511 | 514 | |
512 | 515 | acldvppDestroyPicDesc(vpcDesc); |
513 | 516 | |
... | ... | @@ -1220,7 +1223,10 @@ void CMultiSourceProcess::timing_snapshot_thread(){ |
1220 | 1223 | acldvppSetPicDescHeightStride(vpcDesc, devMem->getHeightStride()); |
1221 | 1224 | acldvppSetPicDescSize(vpcDesc, devMem->getSize()); |
1222 | 1225 | |
1223 | - jpegUtil.jpeg_encode(vpcDesc, fpath_ori); | |
1226 | + bool bSaved = jpegUtil.jpeg_encode(vpcDesc, fpath_ori); | |
1227 | + if(!bSaved){ | |
1228 | + LOG_ERROR("jpeg_encode failed"); | |
1229 | + } | |
1224 | 1230 | |
1225 | 1231 | acldvppDestroyPicDesc(vpcDesc); |
1226 | 1232 | vpcDesc = nullptr; |
... | ... | @@ -1856,6 +1862,9 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1856 | 1862 | std::vector<video_object_snapshot> algo_results; |
1857 | 1863 | for (int sp_idx = 0; sp_idx < 3; sp_idx ++) { |
1858 | 1864 | int num = sp_idx + 1; |
1865 | + | |
1866 | + bool bData = false; | |
1867 | + | |
1859 | 1868 | // 原图 |
1860 | 1869 | // LOG_DEBUG("原图"); |
1861 | 1870 | std::string fpath_origin = result_folder + helpers::os::sep + obj_key.video_id + "_" + |
... | ... | @@ -1865,9 +1874,12 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1865 | 1874 | origin_save_info.file_path = fpath_origin; |
1866 | 1875 | origin_save_info.img_info = obj_value.snapShots[sp_idx].snapShot; |
1867 | 1876 | origin_save_info.obj_rect = obj_value.snapShots[sp_idx].obj_pos; |
1868 | - m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(origin_save_info); | |
1877 | + if(origin_save_info.img_info.pic_desc) { | |
1878 | + // 限制长度导致漏目标的情况会没有图片数据信息 | |
1879 | + m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(origin_save_info); | |
1880 | + bData = true; | |
1881 | + } | |
1869 | 1882 | |
1870 | - | |
1871 | 1883 | // LOG_DEBUG("抠图"); |
1872 | 1884 | // 抠图 |
1873 | 1885 | string object_file_name = result_folder_little + helpers::os::sep + obj_key.video_id + "_" + |
... | ... | @@ -1875,19 +1887,26 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1875 | 1887 | ImgSaveInfo obj_save_info; |
1876 | 1888 | obj_save_info.file_path = object_file_name; |
1877 | 1889 | obj_save_info.img_info = obj_value.snapShots[sp_idx].snapShotLittle; |
1878 | - m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(obj_save_info); | |
1890 | + if(obj_save_info.img_info.pic_desc){ | |
1891 | + // 限制长度导致漏目标的情况会没有图片数据信息 | |
1892 | + m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(obj_save_info); | |
1893 | + bData = true; | |
1894 | + } | |
1895 | + | |
1879 | 1896 | |
1880 | 1897 | #ifdef POST_USE_RABBITMQ |
1881 | - video_object_snapshot new_obj_ss_info; | |
1882 | - new_obj_ss_info.analysisRes = nullptr; | |
1883 | - new_obj_ss_info.object_id = obj_key.obj_id; | |
1884 | - new_obj_ss_info.obj_info.set_data(obj_value.snapShots[sp_idx].index.index, obj_value.snapShots[sp_idx].confidence, obj_value.snapShots[sp_idx].obj_pos.left_, | |
1885 | - obj_value.snapShots[sp_idx].obj_pos.top_, obj_value.snapShots[sp_idx].obj_pos.left_ + obj_value.snapShots[sp_idx].obj_pos.width_, | |
1886 | - obj_value.snapShots[sp_idx].obj_pos.top_ + obj_value.snapShots[sp_idx].obj_pos.height_); | |
1887 | - strcpy(new_obj_ss_info.task_id, obj_key.video_id.c_str()); | |
1888 | - strcpy(new_obj_ss_info.video_image_path, fpath_origin.c_str()); | |
1889 | - strcpy(new_obj_ss_info.snapshot_image_path, object_file_name.c_str()); | |
1890 | - algo_results.push_back(new_obj_ss_info); | |
1898 | + if(bData) { | |
1899 | + video_object_snapshot new_obj_ss_info; | |
1900 | + new_obj_ss_info.analysisRes = nullptr; | |
1901 | + new_obj_ss_info.object_id = obj_key.obj_id; | |
1902 | + new_obj_ss_info.obj_info.set_data(obj_value.snapShots[sp_idx].index.index, obj_value.snapShots[sp_idx].confidence, obj_value.snapShots[sp_idx].obj_pos.left_, | |
1903 | + obj_value.snapShots[sp_idx].obj_pos.top_, obj_value.snapShots[sp_idx].obj_pos.left_ + obj_value.snapShots[sp_idx].obj_pos.width_, | |
1904 | + obj_value.snapShots[sp_idx].obj_pos.top_ + obj_value.snapShots[sp_idx].obj_pos.height_); | |
1905 | + strcpy(new_obj_ss_info.task_id, obj_key.video_id.c_str()); | |
1906 | + strcpy(new_obj_ss_info.video_image_path, fpath_origin.c_str()); | |
1907 | + strcpy(new_obj_ss_info.snapshot_image_path, object_file_name.c_str()); | |
1908 | + algo_results.push_back(new_obj_ss_info); | |
1909 | + } | |
1891 | 1910 | #endif |
1892 | 1911 | } |
1893 | 1912 | ... | ... |
src/reprocessing_module/save_snapshot_reprocessing.cpp
... | ... | @@ -96,6 +96,9 @@ void save_snapshot_reprocessing::save_img_process() { |
96 | 96 | bool bSaved = false; |
97 | 97 | if(!cur_image.file_path.empty()){ |
98 | 98 | bSaved = jpegUtil.jpeg_encode(cur_image.img_info.pic_desc, cur_image.file_path); |
99 | + if(!bSaved){ | |
100 | + LOG_ERROR("jpeg_encode failed"); | |
101 | + } | |
99 | 102 | } |
100 | 103 | VPCUtil::vpc_img_release(cur_image.img_info); |
101 | 104 | ... | ... |
src/reprocessing_module/snapshot_reprocessing.cpp
... | ... | @@ -383,6 +383,11 @@ void snapshot_reprocessing::update_village_bestsnapshot(vector<DeviceMemory*> ve |
383 | 383 | /* 若该目标第一次出现 */ |
384 | 384 | if (total_village_snapshot_info.find(new_obj) == total_village_snapshot_info.end()) |
385 | 385 | { |
386 | + if (total_village_snapshot_info.size() > 400) | |
387 | + {//确保显存不会无限增长 | |
388 | + return; | |
389 | + } | |
390 | + | |
386 | 391 | /* manager insert new object. */ |
387 | 392 | /* 判断目标合法 */ |
388 | 393 | if (!(algor_config_param.count(task_id) && algor_param.count(task_id))) | ... | ... |
src/util/JpegUtil.cpp
... | ... | @@ -68,6 +68,11 @@ int32_t JpegUtil::jpege_save(char* pcData , uint32_t dataLen, string out_file_na |
68 | 68 | |
69 | 69 | bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name) { |
70 | 70 | |
71 | + if (nullptr == encodeInputDesc_) { | |
72 | + LOG_ERROR("encodeInputDesc_ is nullptr!"); | |
73 | + return false; | |
74 | + } | |
75 | + | |
71 | 76 | aclError aclRet ; |
72 | 77 | aclRet = aclrtSetDevice(deviceId_); |
73 | 78 | aclrtSetCurrentContext(context_); | ... | ... |