Video Analysis底层库拆分,sdk的go封装
zhangzengfei
2020-01-11 8464662ccdff684afeeee3356d838e838a0a5d11
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
#ifdef __cplusplus
extern "C"{
#endif
 
#include "csdk.h"
 
#ifdef __cplusplus
}
#endif
 
#include "csrc/all.hpp"
 
using namespace csdk_wrap;
 
static VecFunc dtors_;
 
int c_api_face_detector_init(const int tm, const int gi, const int minFaces, const int rollAngle){
    return init_face_detector(tm, gi, minFaces, rollAngle, dtors_);
}
 
int c_api_face_property_init(const int tm){
    return init_face_property(tm, dtors_);
}
 
int c_api_face_extractor_init(const int tm, const int gi){
    return init_face_extractor(tm, gi, dtors_);
}
 
int c_api_face_tracker_init(const int tm, const int gi, const int wid, const int hei,
                              const int maxFaces, const int detinterval, const int sampleSize){
 
   return init_face_tracker(tm, gi, wid, hei, maxFaces, detinterval, sampleSize, dtors_);
}
 
int c_api_face_track_resize(const int chan, const int wid, const int hei){
    return face_track_resize(chan, wid, hei);
}
 
YoloHandle c_api_yolo_init(
    const char *fcfg, const char *fweights, const char *fname,
    const int gpu_index){
 
    return init_yolo_detector(fcfg, fweights, fname, gpu_index, dtors_);
}
 
void c_api_release(){
    for(auto &i : dtors_){
        i();
    }
    dtors_.clear();
}
 
////////////////////////////////////////////////
 
cFacePos* c_api_face_detect(int *faceCount, uchar*data, const int w, const int h, const int channel){
    const cIMAGE img{data, w, h, 3};
    return face_detect(faceCount, &img, channel);
}
 
cThftResult c_api_face_property(const cFacePos* pos, uchar*data, const int w, const int h, const int channel){
 
    const cIMAGE img{data, w, h, 3};
    return face_property(*pos, &img, channel);
}
 
uchar* c_api_face_extract(int *featLen, const cFacePos* pos, uchar*data, const int w, const int h, const int channel){
 
    const cIMAGE img{data, w, h, 3};
    return face_extract_feature(featLen, *pos, &img, channel);
}
 
float c_api_face_compare(uchar *feat1, uchar *feat2){
    return face_compare(feat1, feat2);
}
 
cRECT* c_api_face_track_only(int *fCount, uchar *data, const int wid, const int hei, const int channel){
    const cIMAGE img{data, wid, hei, 3};
 
    return face_track_only(fCount, &img, channel);
}
 
cFaceInfo* c_api_face_track_detect(int *fCount, uchar *data, const int wid, const int hei, const int channel){
    const cIMAGE img{data, wid, hei, 3};
 
    return face_track_detect(fCount, &img, channel);
}
 
cFaceInfo* c_api_face_track(int *fCount, uchar *data, const int wid, const int hei, const int channel){
    const cIMAGE img{data, wid, hei, 3};
    return face_track(fCount, &img, channel);
}
 
 
/// yolo api
cObjInfo* c_api_yolo_detect(YoloHandle handle, int *objCount, uchar*data, const int w, const int h, const float thrsh, const int use_means){
 
    const cIMAGE img{data, w, h, 3};
    return yolo_detect(handle, objCount, &img, thrsh, use_means);
}
 
const char* c_api_yolo_obj_name(const int typ){
    return yolo_obj_name_by_type(typ);
}
 
// plateid api
int c_api_plate_id_init(const cPlateIDCfg *config, char *soPath) {
    return init_plate_id_detector(config, soPath);
}
 
cPlateIDResult* c_api_plate_id_detect(int *plateIDCount, uchar *data, const int w, const int h, const cRECT *rcDetect) {
    const cIMAGE img{data, w, h, 3};
    return plate_id_detect(plateIDCount, &img, rcDetect);
}
 
int c_api_plate_id_free() {
    return uninit_plate_id_detector();
}
 
// plateid cloud sdk api
int c_api_plate_id_cloud_init(const cPlateIDCloudSDKCfg *config, char *soPath, char *modelPath) {
    return init_plate_id_cloud_sdk_detector(config, soPath, modelPath);
}
 
cPlateIDCloudSDKResult* c_api_plate_id_cloud_detect(int *plateIDCount, uchar *data, const int w, const int h, const cRECT *rcDetect) {
    const cIMAGE img{data, w, h, 3};
    return plate_id_cloud_sdk_detect(plateIDCount, &img, rcDetect);
}
 
void c_api_plate_id_cloud_free() {
    uninit_plate_id_cloud_sdk_detector();
}
 
// its vehicle sdk api
int c_api_init_vehicle_its_detector(int sceneMode, int modelMode, char *keyPath, char *modelPath) {
    return init_vehicle_its_detector(sceneMode, modelMode, keyPath, modelPath);
}
 
cVehicleITSResult* c_api_vehicle_its_detect(int *plateIDCount, uchar *data, const int w, const int h, const cRECT *rcDetect) {
    const cIMAGE img{data, w, h, 3};
    return vehicle_its_detect(plateIDCount, &img, rcDetect);
}
 
void c_api_vehicle_its_free() {
    uninit_vehicle_its_detector();
}