pansen
2019-04-09 a69649804af1cdef936258aab4a5f719cdb32154
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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