Commit 1d41673e4d71790b3556ef06242c5580f4b1fd50

Authored by Hu Chunming
1 parent 414f5587

完全版

vehicle_structure_platform.git0708-3080-trt-face/src/VPT/MutliSourceVideoProcess.cpp
@@ -395,7 +395,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID) @@ -395,7 +395,7 @@ void CMutliSourceVideoProcess::FinishTask(const int taskID)
395 tasks[i].taskRealTimeCallbackFunc = nullptr; 395 tasks[i].taskRealTimeCallbackFunc = nullptr;
396 396
397 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); //�Ƿ�����������ʶ��); 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); //�Ƿ�����������ʶ��);
399 399
400 if (tasks[i].folderName) 400 if (tasks[i].folderName)
401 { 401 {
vehicle_structure_platform.git0708-3080-trt-face/src/VPT/snapshot_analysis/snapshot_helper.cpp
@@ -697,165 +697,154 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi @@ -697,165 +697,154 @@ void snapshot_helper::finish_task_ss_analysis(int task_id, sy_command hp_analysi
697 } 697 }
698 } 698 }
699 699
700 - // if (!vehicle_keys.empty())  
701 - // {  
702 - // const int obj_batch_count = OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE;  
703 - // const int vehicle_batch_size = vehicle_keys.size();  
704 - // int vehicle_batch_count = obj_batch_count;  
705 - // for (int i = 0; i <= (vehicle_batch_size / obj_batch_count); ++i)  
706 - // {  
707 - // if (i == (vehicle_batch_size / obj_batch_count))  
708 - // vehicle_batch_count = vehicle_batch_size % obj_batch_count;  
709 -  
710 - // if (vehicle_batch_count == 0) continue;  
711 -  
712 - // sy_img* finish_vehicle_img = new sy_img[vehicle_batch_count]{};  
713 -  
714 - // for (int j = 0; j < vehicle_batch_count; j++)  
715 - // {  
716 - // OBJ_KEY cur_obj_key = vehicle_keys[j];  
717 - // finish_vehicle_img[j].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame);  
718 - // }  
719 -  
720 - // vc_result *vcresult = new vc_result[vehicle_batch_count]{};  
721 - // vplate_result *vp_result = new vplate_result[vehicle_batch_count]{};  
722 - // vr_result *vrresult = new vr_result[vehicle_batch_count]{};  
723 - // if (vehicle_analysis_config == SY_CONFIG_OPEN)  
724 - // {  
725 - // {  
726 - // //TimeCounting t("VehicleColor_Process");  
727 - // VehicleColor_Process(vc_handle, finish_vehicle_img, vehicle_batch_count, vcresult);  
728 - // }  
729 -  
730 - // {  
731 - // //TimeCounting t("VehiclePlateDetectRecog_Process");  
732 - // VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, vehicle_batch_count, vp_result);  
733 - // }  
734 -  
735 - // {  
736 - // //TimeCounting t("VehicleRecog_Process");  
737 - // // VehicleRecog_Process(finish_vehicle_img, vehicle_batch_count, vrresult, &vehicle_keys[0] + i*obj_batch_count);  
738 - // }  
739 - // }  
740 -  
741 - // int8 ** fea = nullptr;  
742 - // if (vcf_recg_config == SY_CONFIG_OPEN)  
743 - // { 700 + if (!vehicle_keys.empty())
  701 + {
  702 + const int obj_batch_count = OBJ_BATCH_COUNT_VEHICLE / OBJ_SCALE;
  703 + const int vehicle_batch_size = vehicle_keys.size();
  704 + int vehicle_batch_count = obj_batch_count;
  705 + for (int i = 0; i <= (vehicle_batch_size / obj_batch_count); ++i)
  706 + {
  707 + if (i == (vehicle_batch_size / obj_batch_count))
  708 + vehicle_batch_count = vehicle_batch_size % obj_batch_count;
  709 +
  710 + if (vehicle_batch_count == 0) continue;
  711 +
  712 + sy_img* finish_vehicle_img = new sy_img[vehicle_batch_count]{};
  713 +
  714 + for (int j = 0; j < vehicle_batch_count; j++)
  715 + {
  716 + OBJ_KEY cur_obj_key = vehicle_keys[j];
  717 + finish_vehicle_img[j].set_data(VEHICLE_WIDTH, VEHICLE_HEIGHT, IMG_CHANNELS, (unsigned char*)snapShotInfo[cur_obj_key].snapShotLittle.frame);
  718 + }
  719 +
  720 + vc_result *vcresult = new vc_result[vehicle_batch_count]{};
  721 + vplate_result *vp_result = new vplate_result[vehicle_batch_count]{};
  722 + vr_result *vrresult = new vr_result[vehicle_batch_count]{};
  723 + if (vehicle_analysis_config == SY_CONFIG_OPEN)
  724 + {
  725 + VehicleColor_Process(vc_handle, finish_vehicle_img, vehicle_batch_count, vcresult);
  726 + VehiclePlateDetectRecog_Process(vp_handle, finish_vehicle_img, vehicle_batch_count, vp_result);
  727 + VehicleRecog_Process(finish_vehicle_img, vehicle_batch_count, vrresult, &vehicle_keys[0] + i*obj_batch_count);
  728 + }
  729 +
  730 + int8 ** fea = nullptr;
  731 + if (vcf_recg_config == SY_CONFIG_OPEN)
  732 + {
744 733
745 - // fea = new int8*[vehicle_batch_count] {};  
746 - // for (int ii = 0; ii < vehicle_batch_count; ++ii)  
747 - // {  
748 - // fea[ii] = new int8[FEATURESIZE]{};  
749 - // } 734 + fea = new int8*[vehicle_batch_count] {};
  735 + for (int ii = 0; ii < vehicle_batch_count; ++ii)
  736 + {
  737 + fea[ii] = new int8[FEATURESIZE]{};
  738 + }
750 739
751 - // //TimeCounting t("vf_features_process");  
752 - // vf_features_process(vf_handle, finish_vehicle_img, vehicle_batch_count, fea);  
753 - // } 740 + //TimeCounting t("vf_features_process");
  741 + vf_features_process(vf_handle, finish_vehicle_img, vehicle_batch_count, fea);
  742 + }
754 743
755 744
756 - // int resIndex = 0;  
757 - // int feaIndex = 0;  
758 - // for (int vc_idx = 0; vc_idx < vehicle_batch_count; vc_idx++)  
759 - // {  
760 - // auto iter = snapShotInfo.find(vehicle_keys[vc_idx]);  
761 -  
762 - // if (iter == snapShotInfo.end())  
763 - // resIndex++; //cout << iter_key.videoID << " " <<iter_key.objID << " cant find" << endl;  
764 - // else  
765 - // {  
766 - // vehicle_result curRes = {};  
767 - // if (vehicle_analysis_config == SY_CONFIG_OPEN)  
768 - // {  
769 - // //VC  
770 - // memcpy(&curRes.vc_res, &vcresult[resIndex], sizeof(vc_result));  
771 -  
772 - // //VP  
773 - // memcpy(&curRes.vp_res, &vp_result[resIndex], sizeof(vplate_result));  
774 -  
775 - // //VR  
776 - // memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vr_result));  
777 - // resIndex++;  
778 - // }  
779 -  
780 - // if (vcf_recg_config == SY_CONFIG_OPEN)  
781 - // {  
782 - // //if (mp_head.find(vc_idx) != mp_head.end())  
783 - // {  
784 - // int8 * feaRes = fea[feaIndex];  
785 - // memcpy(curRes.feature, feaRes, FEATURESIZE * sizeof(int8));  
786 - // ++feaIndex;  
787 - // }  
788 - // }  
789 -  
790 - // snapshot_res_callback(vehicle_keys[vc_idx], &curRes);  
791 -  
792 - // int count_vehicle_size = count_vehicle_v.size();  
793 - // for (vector<OBJ_KEY>::iterator iter = count_vehicle_v.begin(); iter != count_vehicle_v.end(); )  
794 - // {  
795 - // if (iter->videoID == vehicle_keys[vc_idx].videoID && iter->objID == vehicle_keys[vc_idx].objID)  
796 - // iter = count_vehicle_v.erase(iter);  
797 - // else  
798 - // {  
799 - // ++iter;  
800 - // }  
801 - // }  
802 -  
803 - // if (count_vehicle_v.size() == count_vehicle_size) //当前hp_keys[k] 不在count_person数组里  
804 - // {  
805 - // save_snapshot(vehicle_keys[vc_idx]);  
806 - // }  
807 -  
808 - // if (iter->second.snapShotLittle.frame)  
809 - // {  
810 - // cudaFree(iter->second.snapShotLittle.frame);  
811 - // iter->second.snapShotLittle.frame = NULL;  
812 - // }  
813 - // snapShotInfo.erase(iter);//modified by dyq  
814 - // }  
815 - // }  
816 -  
817 - // vehicle_result_v.clear();  
818 - // vector<vehicle_result>().swap(vehicle_result_v);  
819 -  
820 -  
821 - // if (fea != nullptr)  
822 - // {  
823 - // for (int ii = 0; ii < vehicle_batch_count; ++ii)  
824 - // {  
825 - // delete[] fea[ii];  
826 - // }  
827 - // delete[] fea;  
828 - // fea = nullptr;  
829 - // }  
830 - // if (vcresult != NULL)  
831 - // {  
832 - // delete[] vcresult;  
833 - // vcresult = NULL;  
834 - // }  
835 -  
836 - // if (vp_result != NULL)  
837 - // {  
838 - // delete[] vp_result;  
839 - // vp_result = NULL;  
840 - // }  
841 -  
842 - // if (vrresult != NULL)  
843 - // {  
844 - // delete[] vrresult;  
845 - // vrresult = NULL;  
846 - // }  
847 -  
848 - // if (finish_vehicle_img != NULL)  
849 - // {  
850 - // delete[] finish_vehicle_img;  
851 - // finish_vehicle_img = NULL;  
852 - // }  
853 -  
854 - // vehicle_keys.erase(vehicle_keys.begin(), vehicle_keys.begin() + vehicle_batch_count);  
855 - // }  
856 -  
857 - // v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS;  
858 - // } 745 + int resIndex = 0;
  746 + int feaIndex = 0;
  747 + for (int vc_idx = 0; vc_idx < vehicle_batch_count; vc_idx++)
  748 + {
  749 + auto iter = snapShotInfo.find(vehicle_keys[vc_idx]);
  750 +
  751 + if (iter == snapShotInfo.end())
  752 + resIndex++; //cout << iter_key.videoID << " " <<iter_key.objID << " cant find" << endl;
  753 + else
  754 + {
  755 + vehicle_result curRes = {};
  756 + if (vehicle_analysis_config == SY_CONFIG_OPEN)
  757 + {
  758 + //VC
  759 + memcpy(&curRes.vc_res, &vcresult[resIndex], sizeof(vc_result));
  760 +
  761 + //VP
  762 + memcpy(&curRes.vp_res, &vp_result[resIndex], sizeof(vplate_result));
  763 +
  764 + //VR
  765 + memcpy(&curRes.vr_res, &vrresult[resIndex], sizeof(vr_result));
  766 + resIndex++;
  767 + }
  768 +
  769 + if (vcf_recg_config == SY_CONFIG_OPEN)
  770 + {
  771 + //if (mp_head.find(vc_idx) != mp_head.end())
  772 + {
  773 + int8 * feaRes = fea[feaIndex];
  774 + memcpy(curRes.feature, feaRes, FEATURESIZE * sizeof(int8));
  775 + ++feaIndex;
  776 + }
  777 + }
  778 +
  779 + snapshot_res_callback(vehicle_keys[vc_idx], &curRes);
  780 +
  781 + int count_vehicle_size = count_vehicle_v.size();
  782 + for (vector<OBJ_KEY>::iterator iter = count_vehicle_v.begin(); iter != count_vehicle_v.end(); )
  783 + {
  784 + if (iter->videoID == vehicle_keys[vc_idx].videoID && iter->objID == vehicle_keys[vc_idx].objID)
  785 + iter = count_vehicle_v.erase(iter);
  786 + else
  787 + {
  788 + ++iter;
  789 + }
  790 + }
  791 +
  792 + if (count_vehicle_v.size() == count_vehicle_size) //当前hp_keys[k] 不在count_person数组里
  793 + {
  794 + save_snapshot(vehicle_keys[vc_idx]);
  795 + }
  796 +
  797 + if (iter->second.snapShotLittle.frame)
  798 + {
  799 + cudaFree(iter->second.snapShotLittle.frame);
  800 + iter->second.snapShotLittle.frame = NULL;
  801 + }
  802 + snapShotInfo.erase(iter);//modified by dyq
  803 + }
  804 + }
  805 +
  806 + vehicle_result_v.clear();
  807 + vector<vehicle_result>().swap(vehicle_result_v);
  808 +
  809 +
  810 + if (fea != nullptr)
  811 + {
  812 + for (int ii = 0; ii < vehicle_batch_count; ++ii)
  813 + {
  814 + delete[] fea[ii];
  815 + }
  816 + delete[] fea;
  817 + fea = nullptr;
  818 + }
  819 + if (vcresult != NULL)
  820 + {
  821 + delete[] vcresult;
  822 + vcresult = NULL;
  823 + }
  824 +
  825 + if (vp_result != NULL)
  826 + {
  827 + delete[] vp_result;
  828 + vp_result = NULL;
  829 + }
  830 +
  831 + if (vrresult != NULL)
  832 + {
  833 + delete[] vrresult;
  834 + vrresult = NULL;
  835 + }
  836 +
  837 + if (finish_vehicle_img != NULL)
  838 + {
  839 + delete[] finish_vehicle_img;
  840 + finish_vehicle_img = NULL;
  841 + }
  842 +
  843 + vehicle_keys.erase(vehicle_keys.begin(), vehicle_keys.begin() + vehicle_batch_count);
  844 + }
  845 +
  846 + v_analysis = V_ANALYSIS_TYPE::VC_ANALYSIS;
  847 + }
859 848
860 if (!vehicle_else.empty()) 849 if (!vehicle_else.empty())
861 { 850 {