chenshijun
2019-04-16 080afae264fe7ff89a54886f28dff208fe5a06c4
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//
// 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 {
    CarDetectRes() :
        vehicle_brand(""),
        vehicle_subbrand(""),
        vehicle_issue_year(""),
        vehicle_type(""), freight_ton(""),
        vehicle_score(0), colorLabel(static_cast<ColorLabel>(-1)),
        colorLabelProb(0), carPlateRect(0, 0, 0, 0),
        carPlateRectScore(0), carPlate(""),
        carPlateScore(0), carPlatetype(-1) {}
 
    virtual ~CarDetectRes() {
 
    }
 
    CarDetectRes(const CarDetectRes &rhs) {
        this->vehicle_brand = rhs.vehicle_brand;              //车辆品牌
        this->vehicle_subbrand = rhs.vehicle_subbrand;           //车辆子品牌
        this->vehicle_issue_year = rhs.vehicle_issue_year;         //车辆年款
        this->vehicle_type = rhs.vehicle_type;               //车辆类型
        this->freight_ton = rhs.freight_ton;                //货车吨级
        this->vehicle_score = rhs.vehicle_score;                    //车型识别置信度
 
        //车颜色识别结果
        this->colorLabel = rhs.colorLabel;                  //车颜色
        this->colorLabelProb = rhs.colorLabelProb;                   //车颜色置信度
 
        //车牌检测结果
        this->carPlateRect = rhs.carPlateRect;                   //车牌区域
        this->carPlateRectScore = rhs.carPlateRectScore;                //车牌区域置信度
        this->carPlate = rhs.carPlate;                   //车牌
        this->carPlateScore = rhs.carPlateScore;                    //车牌置信度
        this->carPlatetype = rhs.carPlatetype;
    }
 
 
//    //车型识别结果
//    std::string vehicle_brand;              //车辆品牌
//    std::string vehicle_subbrand;           //车辆子品牌
//    std::string vehicle_issue_year;         //车辆年款
//    std::string vehicle_type;               //车辆类型
//    std::string freight_ton;                //货车吨级
    //车型识别结果
    char *vehicle_brand;              //车辆品牌
    char *vehicle_subbrand;           //车辆子品牌
    char *vehicle_issue_year;         //车辆年款
    char *vehicle_type;               //车辆类型
    char *freight_ton;                //货车吨级
    float vehicle_score;                    //车型识别置信度
 
    //车颜色识别结果
    ColorLabel colorLabel;                  //车颜色
    float colorLabelProb;                   //车颜色置信度
 
    //车牌检测结果
    BskRect carPlateRect;                   //车牌区域
    float carPlateRectScore;                //车牌区域置信度
//    std::string carPlate;                   //车牌
    char *carPlate;                   //车牌
    float carPlateScore;                    //车牌置信度
    int carPlatetype;
};
 
union VPTDetectRes {
 
    VPTDetectRes() {
 
    }
 
    VPTDetectRes(int i) {
        switch (i) {
            case 0 :
                personDetectRes.res_objs;
                break;
            case 1:
            case 2 :
                perRideCarDetectRes.res_objs;
                break;
            case 4 :
            case 5 :
            case 6 :
            case 8 :
                carDetectRes.carPlatetype = -1;
                break;
        }
    }
 
    ~VPTDetectRes() {
 
    }
 
    CarDetectRes carDetectRes;
    PersonDetectRes personDetectRes;
    PerRideCarDetectRes perRideCarDetectRes;
};
 
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() {}
 
    VptDetectResults(int _idx) : vptDetectRes(_idx) {}
 
    virtual ~VptDetectResults() {}
 
    VptDetectResults(const VptDetectResults &src) {
 
        this->sdkDetectType = src.sdkDetectType;
        this->bskRect = src.bskRect;
        this->obj_score = src.obj_score;
 
        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;
        }
    }
 
    float obj_score;
    VPTDetectRes vptDetectRes;
    SDKDetectType sdkDetectType;
    BskRect bskRect;
};
 
class VptDetectWrapper {
public:
    VptDetectWrapper();
 
    VptDetectWrapper(int _gpuIdx, string _dbFilePath);
 
    virtual ~VptDetectWrapper();
 
    list<VptDetectResults> 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