From a69649804af1cdef936258aab4a5f719cdb32154 Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期二, 09 四月 2019 20:58:19 +0800
Subject: [PATCH] 添加vpt封装
---
QiaoJiaSystem/VptServer/CMakeLists.txt | 103 +++++++
QiaoJiaSystem/VptServer/mainAssist.h | 125 ++++++++
QiaoJiaSystem/VptServer/VptDetectWrapper.cpp | 174 ++++++++++++
QiaoJiaSystem/CMakeLists.txt | 2
QiaoJiaSystem/VptServer/VptDetectWrapper.h | 180 ++++++++++++
QiaoJiaSystem/VptServer/main.cpp | 201 ++++++++++++++
6 files changed, 784 insertions(+), 1 deletions(-)
diff --git a/QiaoJiaSystem/CMakeLists.txt b/QiaoJiaSystem/CMakeLists.txt
index 1db175e..d9aa5d9 100644
--- a/QiaoJiaSystem/CMakeLists.txt
+++ b/QiaoJiaSystem/CMakeLists.txt
@@ -36,4 +36,4 @@
add_subdirectory(VideoToImageMulth)
#add_subdirectory(GB28181DecoderModel)
#add_subdirectory(FaceSearchDbWithImg)
-
+add_subdirectory(VptServer)
diff --git a/QiaoJiaSystem/VptServer/CMakeLists.txt b/QiaoJiaSystem/VptServer/CMakeLists.txt
new file mode 100644
index 0000000..6b4a0d4
--- /dev/null
+++ b/QiaoJiaSystem/VptServer/CMakeLists.txt
@@ -0,0 +1,103 @@
+cmake_minimum_required(VERSION 3.5)
+
+STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR})
+project(${CURRENT_FOLDER})
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_BUILD_TYPE debug)
+add_compile_options(-fPIC)
+#add_definitions(-DGLOG)
+#add_definitions(-DTestCode)
+add_definitions(-DDEBUG_ERR -DDEBUG_INFO -fpermissive)
+
+set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../build)
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../build)
+
+# packages
+#find_package(CUDA)
+
+#include_directories ("${PROJECT_SOURCE_DIR}")
+
+# nvcc flags
+#set(CUDA_NVCC_FLAGS -O3;-G;-g)
+#set(CUDA_NVCC_FLAGS -gencode arch=compute_20,code=sm_20;-G;-g)
+#set(CUDA_NVCC_FLAGS -gencode arch=compute_52,code=sm_52;-G;-g)
+
+#file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp *.cuh)
+#file(GLOB CURRENT_SOURCES *.cpp *.cu)
+
+#source_group("Include" FILES ${CURRENT_HEADERS})
+#source_group("Source" FILES ${CURRENT_SOURCES})
+
+#cuda_add_executable(${PROJECT_NAME} ${CURRENT_HEADERS} ${CURRENT_SOURCES})
+#cuda_add_library(${PROJECT_NAME} SHARED ${CURRENT_HEADERS} ${CURRENT_SOURCES})
+#cuda_add_library(${PROJECT_NAME} STATIC ${CURRENT_HEADERS} ${CURRENT_SOURCES})
+
+SET(SOURCES
+ VptDetectWrapper.cpp
+ # GlobalSignalWaitLock.hpp
+ )
+
+SET(LIBS
+ avformat
+ avcodec
+ swresample
+ swscale
+ avutil
+ bz2 dl z
+
+ opencv_world
+
+ cuda
+ cudnn
+
+ human_car_parsing
+ human_parsing
+ utools
+ vehicle_color
+ vehicle_plate_dr
+ vehicle_recognition
+ vpt_det
+ vpt_pic
+
+ glog
+ pthread
+ )
+
+include_directories(
+ ../../../BasicPlatForm/libs/Vpts/include
+
+ #glog
+ ../../../BasicPlatForm/libs/glog/include
+
+ ../../../BasicPlatForm/libs/opencv/include
+ ../../../BasicPlatForm/libs/ffmpeg/include
+ ../../../BasicPlatForm/basic/util/opencv/
+ ../../../BasicPlatForm/basic/debug/
+ ../../../BasicPlatForm/
+ ../../../BasicPlatForm/basic/pipe_element/ffmpeg/
+
+ /usr/include/x86_64-linux-gnu/qt5
+
+)
+
+link_directories(
+ ../../../BasicPlatForm/libs/Vpts/lib
+ #glog
+ /usr/local/lib/
+ /usr/local/cuda/lib64/
+ #glog
+ ../../../BasicPlatForm/libs/glog/lib
+ ../../../BasicPlatForm/libs/opencv/lib
+ ../../../BasicPlatForm/libs/ffmpeg/lib
+
+)
+
+add_executable(${PROJECT_NAME}
+ # testmain.cpp
+ main.cpp
+ ${SOURCES}
+ )
+
+target_link_libraries(${PROJECT_NAME}
+ ${LIBS}
+ )
diff --git a/QiaoJiaSystem/VptServer/VptDetectWrapper.cpp b/QiaoJiaSystem/VptServer/VptDetectWrapper.cpp
new file mode 100644
index 0000000..98fbfcb
--- /dev/null
+++ b/QiaoJiaSystem/VptServer/VptDetectWrapper.cpp
@@ -0,0 +1,174 @@
+//
+// Created by ps on 19-4-9.
+//
+
+#include <basic/debug/Debug.h>
+#include "VptDetectWrapper.h"
+
+VptDetectWrapper::VptDetectWrapper() {
+ init();
+}
+
+VptDetectWrapper::VptDetectWrapper(int _gpuIdx, string _dbFilePath) : m_gpuIdx(_gpuIdx),
+ m_dbFilePath(_dbFilePath) {
+ init();
+}
+
+VptDetectWrapper::~VptDetectWrapper() {
+ vpt_pic_release(&m_handle);
+}
+
+void VptDetectWrapper::init() {
+ m_param.mode = DEVICE_GPU;
+ m_param.gpuid = m_gpuIdx;
+ m_param.hp_recg_config = SY_CONFIG_OPEN;
+ m_param.hcp_recg_config = SY_CONFIG_OPEN;
+ m_param.vehicle_color_config = SY_CONFIG_OPEN;
+ m_param.vehicle_recg_config = SY_CONFIG_OPEN;
+ m_param.vehicle_pendant_det_recg_config = SY_CONFIG_OPEN;
+ m_param.dbPath = const_cast<char *>(m_dbFilePath.data());
+ m_param.log = SY_CONFIG_OPEN;
+ vpt_pic_init(&m_handle, m_param);
+}
+
+void VptDetectWrapper::process_image(cv::Mat &_img) {
+ m_results.clear();
+
+ sy_img img;
+ img.set_data(_img.cols, _img.rows, _img.channels(), _img.data);
+
+ vptpic_result result;
+ result.info = new vptobj_info[MAX_DET_COUNT];
+
+ int ret = vpt_pic_process(m_handle, img, &result);
+
+
+ int size = result.count;
+ for (int i = 0; i < size; i++) {
+
+ char str_i[100];
+ int colorIndex = result.info[i].obj_index;
+
+ if (colorIndex < 0 || colorIndex >= 9)continue;
+// sprintf(str_i, "%s:%.2f", type[colorIndex].c_str(), result.info[i].obj_score);
+
+// rectangle(process_image,
+// cvPoint(result.info[i].obj_rect.left_ - 5, result.info[i].obj_rect.top_ - 15),
+// cvPoint(result.info[i].obj_rect.left_ + result.info[i].obj_rect.width_ + 5,
+// result.info[i].obj_rect.top_ + result.info[i].obj_rect.height_ + 10),
+// cv::Scalar(color[colorIndex][0], color[colorIndex][1], color[colorIndex][2]), 3, 1);
+//
+// cv::putText(process_image, str_i,
+// cv::Point(result.info[i].obj_rect.left_, result.info[i].obj_rect.top_),
+// fontFace, fontScale,
+// cv::Scalar(color[colorIndex][0], color[colorIndex][1], color[colorIndex][2]), thickness, 8);
+
+ //杈撳嚭浜屾灞炴�у垎鏋愮粨鏋�
+ if (result.info[i].analysis_res != NULL) {
+ m_results.emplace_back(std::move(changeAnalysisRes(colorIndex, result.info[i].analysis_res)));
+ m_results.back().bskRect.setRect(result.info[i].obj_rect.left_, result.info[i].obj_rect.top_,
+ result.info[i].obj_rect.width_, result.info[i].obj_rect.height_);
+ } else {}
+ }
+ DBG(m_results.size());
+}
+
+VptDetectResults VptDetectWrapper::changeAnalysisRes(int index, void *result) {
+
+ VptDetectResults vptDetectResults;
+ vptDetectResults.sdkDetectType = static_cast<SDKDetectType>(index);
+// vptDetectResults.vptDetectRes.carDetectRes;
+ switch (vptDetectResults.sdkDetectType) {
+ case SDKDetectType::person : {
+ hp_res *cur_res = (hp_res *) result;
+ memcpy(vptDetectResults.vptDetectRes.personDetectRes.res_objs, cur_res->res_objs,
+ sizeof(classfy_boj_res) * HP_FIR_INDEX_SIZE);
+ //test code
+ for (int i = 0; i < HP_FIR_INDEX_SIZE; i++) {
+ int resIndex = vptDetectResults.vptDetectRes.personDetectRes.res_objs[i].res_index;
+ cout << vptDetectResults.vptDetectRes.personDetectRes.res_objs[i].res_prob << " ";
+ cout << HpResStr[i][resIndex] << " " << endl;
+ }
+ //test code end
+ };
+ break;
+ case SDKDetectType::bike:
+ case SDKDetectType::motor : {
+ hcp_res *cur_res = (hcp_res *) result;
+ memcpy(vptDetectResults.vptDetectRes.perRideCarDetectRes.res_objs, cur_res->res_objs,
+ sizeof(classfy_boj_res) * HCP_FIR_INDEX_SIZE);
+ for (int i = 0; i < HCP_FIR_INDEX_SIZE; i++) {
+ int resIndex = vptDetectResults.vptDetectRes.perRideCarDetectRes.res_objs[i].res_index;
+ cout << vptDetectResults.vptDetectRes.perRideCarDetectRes.res_objs[i].res_prob << " ";
+ cout << HpResStr[i][resIndex] << " " << endl;
+ }
+ cout << endl << endl;
+ };
+ break;
+ case SDKDetectType::car :
+ case SDKDetectType::bigbus :
+ case SDKDetectType::lorry :
+ case SDKDetectType::midibus : {
+ vehicle_res *cur_res = (vehicle_res *) result;
+ auto &carRes = vptDetectResults.vptDetectRes.carDetectRes;
+
+ // 杞﹂鑹�
+ carRes.colorLabel = static_cast<ColorLabel>(cur_res->vc_res.res_index);
+ carRes.colorLabelProb = cur_res->vc_res.res_prob;
+
+ // 杞﹀瀷璇嗗埆
+ if (cur_res->vr_res.vehicle_brand != NULL) {
+// cout << " 杞﹁締鍝佺墝 - " << cur_res->vr_res.vehicle_brand << endl;
+ carRes.vehicle_brand = std::move(string(cur_res->vr_res.vehicle_brand));
+ delete[] cur_res->vr_res.vehicle_brand;
+ cur_res->vr_res.vehicle_brand = NULL;
+ }
+ if (cur_res->vr_res.vehicle_subbrand != NULL) {
+// cout << " 杞﹁締瀛愬搧鐗� - " << cur_res->vr_res.vehicle_subbrand << endl;
+ carRes.vehicle_subbrand = std::move(string(cur_res->vr_res.vehicle_subbrand));
+ delete[] cur_res->vr_res.vehicle_subbrand;
+ cur_res->vr_res.vehicle_subbrand = NULL;
+ }
+ if (cur_res->vr_res.vehicle_issue_year != NULL) {
+// cout << " 杞﹁締骞存 - " << cur_res->vr_res.vehicle_issue_year << endl;
+ carRes.vehicle_issue_year = std::move(string(cur_res->vr_res.vehicle_issue_year));
+ delete[] cur_res->vr_res.vehicle_issue_year;
+ cur_res->vr_res.vehicle_issue_year = NULL;
+ }
+ if (cur_res->vr_res.vehicle_type != NULL) {
+// cout << " 杞﹁締绫诲瀷 - " << cur_res->vr_res.vehicle_type << endl;
+ carRes.vehicle_type = std::move(string(cur_res->vr_res.vehicle_type));
+ delete[] cur_res->vr_res.vehicle_type;
+ cur_res->vr_res.vehicle_type = NULL;
+ }
+ if (cur_res->vr_res.freight_ton != NULL) {
+// cout << " 璐ц溅鍚ㄧ骇 - " << cur_res->vr_res.freight_ton << endl;
+ carRes.freight_ton = std::move(string(cur_res->vr_res.freight_ton));
+ delete[] cur_res->vr_res.freight_ton;
+ cur_res->vr_res.freight_ton = NULL;
+ }
+// cout << " " << cur_res->vr_res.name_score << endl;
+ carRes.vehicle_score = cur_res->vr_res.name_score;
+
+ // 杞︾墝
+ if (cur_res->vp_res.rect.height_ != 0 && cur_res->vp_res.rect.width_ != 0) {
+// cout << "杞︾墝浣嶇疆: " << cur_res->vp_res.rect.left_ << " " << cur_res->vp_res.rect.top_ << " "
+// << cur_res->vp_res.rect.width_ << " " << cur_res->vp_res.rect.height_ << endl;
+ carRes.carPlateRect.setRect(cur_res->vp_res.rect.left_, cur_res->vp_res.rect.top_,
+ cur_res->vp_res.rect.width_, cur_res->vp_res.rect.height_);
+ carRes.carPlateRectScore = cur_res->vp_res.detectScore;
+
+ for (int m = 0; m < 7; m++) {
+// printf("%s", cur_res->vp_res.recg[m].character);
+ carRes.carPlate.append(cur_res->vp_res.recg[m].character);
+ }
+ carRes.carPlateRectScore = cur_res->vp_res.numScore;
+ carRes.carPlatetype = cur_res->vp_res.type;
+// printf(" numScore = %.2f, detectScore = %.2f\n", cur_res->vp_res.numScore, cur_res->vp_res.detectScore);
+ }
+ };
+ break;
+ }
+ return vptDetectResults;
+}
+
diff --git a/QiaoJiaSystem/VptServer/VptDetectWrapper.h b/QiaoJiaSystem/VptServer/VptDetectWrapper.h
new file mode 100644
index 0000000..a36ea73
--- /dev/null
+++ b/QiaoJiaSystem/VptServer/VptDetectWrapper.h
@@ -0,0 +1,180 @@
+//
+// Created by ps on 19-4-9.
+//
+
+#ifndef QIAOJIASYSTEM_VPTDETECTWRAPPER_H
+#define QIAOJIASYSTEM_VPTDETECTWRAPPER_H
+
+#include <libs/Vpts/include/vpt_pic_header.h>
+#include <libs/Vpts/include/vpt_pic.h>
+#include <opencv2/opencv.hpp>
+#include <CvMath.hpp>
+#include "mainAssist.h"
+
+//鍒嗙被缁撴灉缁撴瀯浣�
+//struct ClassfyObjRes {
+// int res_index; //鍒嗙被缁撴灉
+// float res_prob; //鍒嗙被缁撴瀯浣�
+//};
+
+struct PersonDetectRes {
+// std::string head;
+// std::string head_color;
+// std::string eye;
+// std::string mouth;
+// std::string up;
+// std::string up_color;
+// std::string clothing_text;
+// std::string down;
+// std::string down_color;
+// std::string bao;
+// std::string sex;
+// std::string age;
+// std::string viewpoint;
+// std::string dasan;
+// std::string child;
+// std::string personstate;
+ classfy_boj_res res_objs[HP_FIR_INDEX_SIZE]; //鍒嗙被缁撴灉
+};
+
+struct PerRideCarDetectRes {
+// std::string hcp_up;
+// std::string hcp_up_color;
+// std::string hcp_down;
+// std::string hcp_down_color;
+// std::string bao;
+// std::string hcp_bag_color;
+// std::string hcp_head;
+// std::string hcp_clothing_text;
+// std::string hcp_sex;
+// std::string hcp_figure;
+// std::string hcp_nationality;
+// std::string hcp_age;
+// std::string hcp_eye;
+// std::string hcp_mouth;
+// std::string hcp_weibo;
+// std::string hcp_carColor;
+// std::string hcp_orient;
+// std::string hcp_drivenum;
+// std::string hcp_dasan;
+// std::string hcp_take;
+
+ classfy_boj_res res_objs[HCP_FIR_INDEX_SIZE]; //鍒嗙被缁撴灉
+};
+
+struct CarDetectRes {
+ //杞﹀瀷璇嗗埆缁撴灉
+ std::string vehicle_brand; //杞﹁締鍝佺墝
+ std::string vehicle_subbrand; //杞﹁締瀛愬搧鐗�
+ std::string vehicle_issue_year; //杞﹁締骞存
+ std::string vehicle_type; //杞﹁締绫诲瀷
+ std::string freight_ton; //璐ц溅鍚ㄧ骇
+ float vehicle_score; //杞﹀瀷璇嗗埆缃俊搴�
+
+ //杞﹂鑹茶瘑鍒粨鏋�
+ ColorLabel colorLabel; //杞﹂鑹�
+ float colorLabelProb; //杞﹂鑹茬疆淇″害
+
+ //杞︾墝妫�娴嬬粨鏋�
+ BskRect carPlateRect; //杞︾墝鍖哄煙
+ float carPlateRectScore; //杞︾墝鍖哄煙缃俊搴�
+ std::string carPlate; //杞︾墝
+ float carPlateScore; //杞︾墝缃俊搴�
+ int carPlatetype;
+};
+
+union VPTDetectRes {
+
+ struct TestVPTDetectRes {
+ int i;
+ };
+
+ VPTDetectRes() : testVPTDetectRes(TestVPTDetectRes()) {
+
+ }
+
+ ~VPTDetectRes() {
+
+ }
+
+ TestVPTDetectRes testVPTDetectRes;
+ PersonDetectRes personDetectRes;
+ PerRideCarDetectRes perRideCarDetectRes;
+ CarDetectRes carDetectRes;
+};
+
+enum class SDKDetectType {
+ test = -1,
+ person = 0, // PersonDetectRes
+ bike, // PerRideCarDetectRes
+ motor, // PerRideCarDetectRes
+ tricycle, //
+ car, // CarDetectRes
+ bigbus, // CarDetectRes
+ lorry, // CarDetectRes
+ tractor, //
+ midibus // CarDetectRes
+};
+
+struct VptDetectResults {
+public:
+ VptDetectResults() {}
+
+ virtual ~VptDetectResults() {}
+
+ VptDetectResults(const VptDetectResults &src) {
+
+ this->sdkDetectType = src.sdkDetectType;
+ this->bskRect = src.bskRect;
+
+ switch (src.sdkDetectType) {
+ case SDKDetectType::person :
+ this->vptDetectRes.personDetectRes = src.vptDetectRes.personDetectRes;
+ break;
+ case SDKDetectType::bike:
+ case SDKDetectType::motor :
+ this->vptDetectRes.perRideCarDetectRes = src.vptDetectRes.perRideCarDetectRes;
+ break;
+ case SDKDetectType::car :
+ case SDKDetectType::bigbus :
+ case SDKDetectType::lorry :
+ case SDKDetectType::midibus :
+ this->vptDetectRes.carDetectRes = src.vptDetectRes.carDetectRes;
+ break;
+ }
+ }
+
+ SDKDetectType sdkDetectType;
+ VPTDetectRes vptDetectRes;
+ BskRect bskRect;
+};
+
+class VptDetectWrapper {
+public:
+ VptDetectWrapper();
+
+ VptDetectWrapper(int _gpuIdx, string _dbFilePath);
+
+ virtual ~VptDetectWrapper();
+
+
+ void process_image(cv::Mat &_img);
+
+private:
+
+ void init();
+
+ VptDetectResults changeAnalysisRes(int index, void *result);
+
+private:
+ list<VptDetectResults> m_results;
+
+ void *m_handle;
+ vptpic_param m_param;
+
+ int m_gpuIdx{0};
+ std::string m_dbFilePath{"CarBodyFeature.db"};
+};
+
+
+#endif //QIAOJIASYSTEM_VPTDETECTWRAPPER_H
diff --git a/QiaoJiaSystem/VptServer/main.cpp b/QiaoJiaSystem/VptServer/main.cpp
new file mode 100644
index 0000000..91e0087
--- /dev/null
+++ b/QiaoJiaSystem/VptServer/main.cpp
@@ -0,0 +1,201 @@
+锘�#include "vpt_pic.h"
+//#include <highgui.h>
+#include <opencv2/opencv.hpp>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include "sy_common.h"
+#include "mainAssist.h"
+
+#ifdef _WIN32
+#include<windows.h>
+#else
+
+#include <sys/time.h>
+#include <basic/util/app/AppUtil.h>
+
+#endif
+
+using namespace std;
+
+
+void printfAnalysisRes(int index, void *result);
+
+int main(int argc, char **argv) {
+ string imgpath;
+
+ if (argc < 2) {
+ printf("Parameter number not right.\n");
+ return 0;
+ } else {
+ imgpath = argv[1];
+ }
+
+ printf("SDK Version: %s\n", vpt_pic_get_version());
+
+ CvFont font;
+ cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0, 0, 1, 3);
+ int fontFace = CV_FONT_HERSHEY_COMPLEX;
+ double fontScale = 1;
+ int thickness = 2;
+
+ void *handle;
+ vptpic_param param;
+ param.mode = DEVICE_GPU;
+ param.gpuid = 0;
+
+ param.hp_recg_config = SY_CONFIG_OPEN;
+ param.hcp_recg_config = SY_CONFIG_OPEN;
+ param.vehicle_color_config = SY_CONFIG_OPEN;
+ param.vehicle_recg_config = SY_CONFIG_OPEN;
+ param.vehicle_pendant_det_recg_config = SY_CONFIG_OPEN;
+
+ param.dbPath = "CarBodyFeature.db";
+ param.log = SY_CONFIG_OPEN;
+
+ vpt_pic_init(&handle, param);
+
+ cv::VideoCapture capture;
+ capture.open(imgpath);
+
+ cv::Mat process_image;
+ capture >> process_image;//璇诲嚭姣忎竴甯х殑鍥惧儚
+
+ cv::Mat image;
+
+ while (!process_image.empty()) {
+
+ process_image.copyTo(image);
+ sy_img img;
+ img.set_data(image.cols, image.rows, image.channels(), image.data);
+
+ vptpic_result result;
+ result.info = new vptobj_info[MAX_DET_COUNT];
+ int ret = vpt_pic_process(handle, img, &result);
+
+ for (int i = 0; i < result.count; i++) {
+ char str_i[100];
+ int colorIndex = result.info[i].obj_index;
+ if (colorIndex < 0 || colorIndex >= 9)continue;
+ sprintf(str_i, "%s:%.2f", type[colorIndex].c_str(), result.info[i].obj_score);
+
+ rectangle(process_image,
+ cvPoint(result.info[i].obj_rect.left_ - 5, result.info[i].obj_rect.top_ - 15),
+ cvPoint(result.info[i].obj_rect.left_ + result.info[i].obj_rect.width_ + 5,
+ result.info[i].obj_rect.top_ + result.info[i].obj_rect.height_ + 10),
+ cv::Scalar(color[colorIndex][0], color[colorIndex][1], color[colorIndex][2]), 3, 1);
+
+ cv::putText(process_image, str_i,
+ cv::Point(result.info[i].obj_rect.left_, result.info[i].obj_rect.top_),
+ fontFace, fontScale,
+ cv::Scalar(color[colorIndex][0], color[colorIndex][1], color[colorIndex][2]), thickness, 8);
+
+ //杈撳嚭浜屾灞炴�у垎鏋愮粨鏋�
+ printfAnalysisRes(colorIndex, result.info[i].analysis_res);
+ }
+
+#ifdef _MSC_VER
+ cv::imshow("res", image);
+ cv::waitKey(0);
+#else
+ char svpath[1024];
+ memset(svpath, 0, sizeof(svpath));
+ std::string strNewTime2 = AppUtil::getTimeUSecString();
+ strNewTime2.append(".jpg");
+
+ sprintf(svpath, "vpt_res/%s", strNewTime2.c_str());
+ imwrite(svpath, process_image);
+#endif
+ //release source
+ if (result.info != NULL) {
+ for (int i = 0; i < MAX_DET_COUNT; i++) {
+ if (result.info[i].analysis_res != NULL) {
+ delete result.info[i].analysis_res;
+ result.info[i].analysis_res = NULL;
+ }
+ }
+ delete[] result.info;
+ result.info = NULL;
+ }
+
+ capture >> process_image;//璇诲嚭姣忎竴甯х殑鍥惧儚
+ }
+
+
+ vpt_pic_release(&handle);
+
+ return 0;
+}
+
+
+void printfAnalysisRes(int index, void *result) {
+ if (index == 0 && result != NULL) //琛屼汉浜屾灞炴�у垎鏋愮粨鏋�
+ {
+ hp_res *cur_res = (hp_res *) result;
+
+ for (int i = 0; i < HP_FIR_INDEX_SIZE; i++) {
+ int resIndex = cur_res->res_objs[i].res_index;
+ cur_res->res_objs[i].res_prob;
+ cout << HpResStr[i][resIndex] << " " << endl;
+
+ }
+ cout << endl << endl;
+ } else if ((index == 1 || index == 2) && result != NULL) //琛屼汉浜屾灞炴�у垎鏋愮粨鏋�
+ {
+ hcp_res *cur_res = (hcp_res *) result;
+
+ for (int i = 0; i < HCP_FIR_INDEX_SIZE; i++) {
+ int resIndex = cur_res->res_objs[i].res_index;
+ cur_res->res_objs[i].res_prob;
+// cout << HcpResStr[i][resIndex] << " " << endl;
+ }
+ cout << endl << endl;
+ } else if (index > 3 && index != 7 && result != NULL) //杞﹁締浜屾灞炴�у垎鏋愮粨鏋滆緭鍑�
+ {
+ vehicle_res *cur_res = (vehicle_res *) result;
+
+ cout << "杞﹂鑹�: " << colorLabel[cur_res->vc_res.res_index] << " " << cur_res->vc_res.res_prob << endl;
+
+ cout << "杞﹀瀷璇嗗埆: " << endl;
+ if (cur_res->vr_res.vehicle_brand != NULL) {
+ cout << " 杞﹁締鍝佺墝 - " << cur_res->vr_res.vehicle_brand << endl;
+ delete[] cur_res->vr_res.vehicle_brand;
+ cur_res->vr_res.vehicle_brand = NULL;
+ }
+ if (cur_res->vr_res.vehicle_subbrand != NULL) {
+ cout << " 杞﹁締瀛愬搧鐗� - " << cur_res->vr_res.vehicle_subbrand << endl;
+ delete[] cur_res->vr_res.vehicle_subbrand;
+ cur_res->vr_res.vehicle_subbrand = NULL;
+ }
+ if (cur_res->vr_res.vehicle_issue_year != NULL) {
+ cout << " 杞﹁締骞存 - " << cur_res->vr_res.vehicle_issue_year << endl;
+ delete[] cur_res->vr_res.vehicle_issue_year;
+ cur_res->vr_res.vehicle_issue_year = NULL;
+ }
+ if (cur_res->vr_res.vehicle_type != NULL) {
+ cout << " 杞﹁締绫诲瀷 - " << cur_res->vr_res.vehicle_type << endl;
+ delete[] cur_res->vr_res.vehicle_type;
+ cur_res->vr_res.vehicle_type = NULL;
+ }
+
+ if (cur_res->vr_res.freight_ton != NULL) {
+ cout << " 璐ц溅鍚ㄧ骇 - " << cur_res->vr_res.freight_ton << endl;
+ delete[] cur_res->vr_res.freight_ton;
+ cur_res->vr_res.freight_ton = NULL;
+ }
+ cout << " " << cur_res->vr_res.name_score << endl;
+
+
+ if (cur_res->vp_res.rect.height_ != 0 && cur_res->vp_res.rect.width_ != 0) {
+ cout << "杞︾墝浣嶇疆: " << cur_res->vp_res.rect.left_ << " " << cur_res->vp_res.rect.top_ << " "
+ << cur_res->vp_res.rect.width_ << " " << cur_res->vp_res.rect.height_ << endl;
+
+ for (int m = 0; m < 7; m++) {
+ printf("%s", cur_res->vp_res.recg[m].character);
+ }
+ printf(" numScore = %.2f, detectScore = %.2f\n", cur_res->vp_res.numScore, cur_res->vp_res.detectScore);
+ }
+
+ cout << endl;
+ }
+}
diff --git a/QiaoJiaSystem/VptServer/mainAssist.h b/QiaoJiaSystem/VptServer/mainAssist.h
new file mode 100644
index 0000000..7f0835f
--- /dev/null
+++ b/QiaoJiaSystem/VptServer/mainAssist.h
@@ -0,0 +1,125 @@
+锘�#include <string>
+
+#ifndef QIAOJIASYSTEM_MAINASSIST_H
+#define QIAOJIASYSTEM_MAINASSIST_H
+using namespace std;
+
+//琛屼汉浜屾灞炴�у垎鏋愮粨鏋�
+static string head[5] = {"闀垮彂", "鐭彂", "鍏夊ご", "甯藉瓙", "鍏朵粬"};
+static string head_color[9] = {"榛�", "鐧�", "鐏�", "绾�", "钃�", "榛�", "缁�", "澶氳壊", "鍏朵粬"};
+static string eye[2] = {"鏈埓鐪奸暅", "鎴寸溂闀�"};
+static string mouth[2] = {"鏈埓鍙g僵", "鎴村彛缃�"};
+static string up[9] = {"T鎭�", "琛~", "姣涜。", "缇界粧鏈�", "澶ц。", "澶栧", "杩炶。瑁�", "鏃犱笂琛�", "鍏朵粬"};
+static string up_color[9] = {"榛�", "鐧�", "鐏�", "绾�", "钃�", "榛�", "缁�", "澶氳壊", "鍏朵粬"};
+static string clothing_text[5] = {"绾壊", "纰庤姳", "鏉$汗", "鏍煎瓙", "鍏朵粬"};
+static string down[6] = {"闀胯¥", "鐭¥", "闀胯", "鐭", "杩炶。瑁�", "鍏朵粬"};
+static string down_color[9] = {"榛�", "鐧�", "鐏�", "绾�", "钃�", "榛�", "缁�", "澶氳壊", "鍏朵粬"};
+static string bao[5] = {"鏃犲寘", "鍗曡偐鍖�", "鑳屽寘/鍙岃偐鍖�", "鎵嬫彁鍖�/鎵嬫彁鐗�", "鎷夋潌绠�/灏忔帹杞�"};
+static string sex[3] = {"鐢�", "濂�", "鍏朵粬"};
+static string age[5] = {"灏忓", "闈掑勾", "涓勾", "鑰佸勾", "鍏朵粬"};
+static string viewpoint[3] = {"姝i潰", "鑳岄潰", "渚ч潰"};
+static string dasan[2] = {"鏈墦浼�", "鎵撲紴"};
+static string child[2] = {"鏈姳灏忓", "鎶卞皬瀛�"};
+static string personstate[5] = {"琛岃蛋", "濂旇窇", "韫插潗", "鎺ㄨ溅", "鍏朵粬"};
+
+static string HpResStr[16][9] = {
+ {"闀垮彂", "鐭彂", "鍏夊ご", "甯藉瓙", "鍏朵粬"},
+ {"榛�", "鐧�", "鐏�", "绾�", "钃�", "榛�", "缁�", "澶氳壊", "鍏朵粬"},
+ {"鏈埓鐪奸暅", "鎴寸溂闀�"},
+ {"鏈埓鍙g僵", "鎴村彛缃�"},
+ {"T鎭�", "琛~", "姣涜。", "缇界粧鏈�", "澶ц。", "澶栧", "杩炶。瑁�", "鏃犱笂琛�", "鍏朵粬"},
+ {"榛�", "鐧�", "鐏�", "绾�", "钃�", "榛�", "缁�", "澶氳壊", "鍏朵粬"},
+ {"绾壊", "纰庤姳", "鏉$汗", "鏍煎瓙", "鍏朵粬"},
+ {"闀胯¥", "鐭¥", "闀胯", "鐭", "杩炶。瑁�", "鍏朵粬"},
+ {"榛�", "鐧�", "鐏�", "绾�", "钃�", "榛�", "缁�", "澶氳壊", "鍏朵粬"},
+ {"鏃犲寘", "鍗曡偐鍖�", "鑳屽寘/鍙岃偐鍖�", "鎵嬫彁鍖�/鎵嬫彁鐗�", "鎷夋潌绠�/灏忔帹杞�"},
+ {"鐢�", "濂�", "鍏朵粬"},
+ {"灏忓", "闈掑勾", "涓勾", "鑰佸勾", "鍏朵粬"},
+ {"姝i潰", "鑳岄潰", "渚ч潰"},
+ {"鏈墦浼�", "鎵撲紴"},
+ {"鏈姳灏忓", "鎶卞皬瀛�"},
+ {"琛岃蛋", "濂旇窇", "韫插潗", "鎺ㄨ溅", "鍏朵粬"}
+};
+
+
+//浜洪獞杞︿簩娆″睘鎬у垎鏋愮粨鏋�
+static string hcp_up[12] = {"T鎭�", "椹敳/鍚婂甫/鑳屽績", "琛~", "瑗挎湇", "姣涜。", "鐨。/澶瑰厠", "缇界粧鏈�", "澶ц。/椋庤。", "澶栧", "杩炶。瑁�", "鏃犱笂琛�", "鍏朵粬"};
+static string hcp_up_color[12] = {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬"};
+static string hcp_down[6] = {"闀胯¥", "鐭¥", "闀胯", "鐭", "杩炶。瑁�", "鍏朵粬"};
+static string hcp_down_color[12] = {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬"};
+static string hcp_bao[5] = {"鏃犲寘", "鍗曡偐鍖�", "鍙岃偐鍖�", "鍏朵粬", "閽卞寘"};
+static string hcp_bag_color[12] = {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬"};
+static string hcp_head[6] = {"闀垮彂", "鐭彂", "鍏夊ご", "甯藉瓙", "澶寸洈", "鍏朵粬"};
+static string hcp_clothing_text[5] = {"绾壊", "纰庤姳", "鏉$汗", "鏍煎瓙", "鍏朵粬"};
+static string hcp_sex[3] = {"鐢�", "濂�", "涓嶆槑"};
+static string hcp_figure[3] = {"鑳�", "鐦�", "涓�"};
+static string hcp_nationality[5] = {"姹夋棌", "缁存棌", "榛戜汉", "鐧戒汉", "鍏朵粬"};
+static string hcp_age[6] = {"骞煎効", "鍎跨", "闈掑勾", "涓勾", "鑰佸勾", "涓嶆槑"};
+static string hcp_eye[4] = {"姝e父鐪肩潧", "鐪奸暅", "澧ㄩ暅", "鍏朵粬"};
+static string hcp_mouth[3] = {"姝e父鍢�", "鎴村彛缃�", "鍏朵粬"};
+static string hcp_weibo[3] = {"鏃犲洿宸�", "鏅�氬洿宸�", "鍖呭ご鍥村肪"};
+static string hcp_carColor[13] = {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬", "閾�"};
+static string hcp_orient[3] = {"姝i潰", "鑳岄潰", "渚ч潰"};
+static string hcp_drivenum[4] = {"0浜�", "1浜�", "2浜�", "鏇村浜�"};
+static string hcp_dasan[2] = {"鏃�", "鏈�"};
+static string hcp_take[2] = {"鏃�", "鐗╁搧"};
+
+static string HcpResStr[20][13] = {
+ {"T鎭�", "椹敳/鍚婂甫/鑳屽績", "琛~", "瑗挎湇", "姣涜。", "鐨。/澶瑰厠", "缇界粧鏈�", "澶ц。/椋庤。", "澶栧", "杩炶。瑁�", "鏃犱笂琛�", "鍏朵粬"},
+ {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬"},
+ {"闀胯¥", "鐭¥", "闀胯", "鐭", "杩炶。瑁�", "鍏朵粬"},
+ {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬"},
+ {"鏃犲寘", "鍗曡偐鍖�", "鍙岃偐鍖�", "鍏朵粬", "閽卞寘"},
+ {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬"},
+ {"闀垮彂", "鐭彂", "鍏夊ご", "甯藉瓙", "澶寸洈", "鍏朵粬"},
+ {"绾壊", "纰庤姳", "鏉$汗", "鏍煎瓙", "鍏朵粬"},
+ {"鐢�", "濂�", "涓嶆槑"},
+ {"鑳�", "鐦�", "涓�"},
+ {"姹夋棌", "缁存棌", "榛戜汉", "鐧戒汉", "鍏朵粬"},
+ {"骞煎効", "鍎跨", "闈掑勾", "涓勾", "鑰佸勾", "涓嶆槑"},
+ {"姝e父鐪肩潧", "鐪奸暅", "澧ㄩ暅", "鍏朵粬"},
+ {"姝e父鍢�", "鎴村彛缃�", "鍏朵粬"},
+ {"鏃犲洿宸�", "鏅�氬洿宸�", "鍖呭ご鍥村肪"},
+ {"榛�", "鐧�", "绾�", "榛�", "钃�", "缁�", "绱�", "妫�", "鐏�", "姗�", "澶氳壊", "鍏朵粬", "閾�"},
+ {"姝i潰", "鑳岄潰", "渚ч潰"},
+ {"0浜�", "1浜�", "2浜�", "鏇村浜�"},
+ {"鏃�", "鏈�"},
+ {"鏃�", "鐗╁搧"},
+};
+
+
+//杞﹁締浜屾灞炴�у垎鏋愮粨鏋�
+static char colorLabel[14][8] = {"妫�", "姗�", "鐏�", "鐧�", "绮�", "绱�", "绾�", "缁�", "钃�", "閲�", "閾�", "闈�", "榛�", "榛�"};
+
+enum class ColorLabel {
+ Brown = 0,
+ Orange,
+ Gray,
+ White,
+ Powder,
+ Purple,
+ Red,
+ Green,
+ Blue,
+ Gold,
+ Silver,
+ BlueGreen,
+ Yellow,
+ black
+};
+
+
+static const int detectType = 9;
+static std::string type[detectType] = {"person", "bike", "motor", "tricycle", "car", "bigbus", "lorry", "tractor",
+ "midibus"};
+static int color[detectType][3] = {{41, 244, 222},
+ {255, 128, 0},
+ {100, 13, 244},
+ {255, 215, 0},
+ {18, 220, 87},
+ {0, 128, 0},
+ {0, 128, 255},
+ {255, 0, 0},
+ {91, 46, 0}};
+
+#endif //QIAOJIASYSTEM_MAINASSIST_H
\ No newline at end of file
--
Gitblit v1.8.0