From 0541661d3e4a063d4e68b33e4d6dbb71d3b58638 Mon Sep 17 00:00:00 2001 From: chenshijun <chenshijun@aiotlink.com> Date: 星期三, 09 九月 2020 09:48:15 +0800 Subject: [PATCH] 添加人脸质量的so --- csdk.cpp | 156 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 111 insertions(+), 45 deletions(-) diff --git a/csdk.cpp b/csdk.cpp index e4ef67f..4a111f1 100644 --- a/csdk.cpp +++ b/csdk.cpp @@ -12,103 +12,169 @@ using namespace csdk_wrap; -static sdkface *face = NULL; -static sdkyolo *yolo = NULL; +static VecFunc dtors_; int c_api_face_detector_init(const int tm, const int gi, const int minFaces, const int rollAngle){ - if (!face) face = new sdkface(); - return face->init_face_detector(tm, gi, minFaces, rollAngle); + return init_face_detector(tm, gi, minFaces, rollAngle, dtors_); } int c_api_face_property_init(const int tm){ - if (!face) face = new sdkface(); - return face->init_face_property(tm); + return init_face_property(tm, dtors_); } int c_api_face_extractor_init(const int tm, const int gi){ - if (!face) face = new sdkface(); - return face->init_face_extractor(tm, 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){ - if (!face) face = new sdkface(); - return face->init_face_tracker(tm, gi, wid, hei, maxFaces, detinterval, 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){ - - if (!yolo) yolo = new sdkyolo; - return yolo->init_yolo(fcfg, fweights, fname, gpu_index); + + return init_yolo_detector(fcfg, fweights, fname, gpu_index, dtors_); } void c_api_release(){ - if (face) delete face; - if (yolo) delete yolo; + 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){ - if (!face) return NULL; - const cIMAGE img{data, w, h, 3}; - cFacePos *fpos = NULL; - - int ret = face->face_detect(&img, channel, (void**)&fpos, faceCount); - - if (ret <= 0) return NULL; - return fpos; + 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){ - if (!face) return cThftResult{-1,-1,-1,-1,-1}; const cIMAGE img{data, w, h, 3}; - return face->face_property(*pos, &img, channel); + 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){ - if (!face) return NULL; const cIMAGE img{data, w, h, 3}; - uchar *feat = NULL; - int ret = face->face_extract_feature(*pos, &img, channel, (void**)&feat, featLen); - if (ret <= 0) return NULL; - return feat; + return face_extract_feature(featLen, *pos, &img, channel); } float c_api_face_compare(uchar *feat1, uchar *feat2){ - if (!face) return NULL; - return face->face_compare(feat1, feat2); + return face_compare(feat1, feat2); +} + +// quality +int c_api_face_quality_init(const int tm){ + return init_face_quality(tm, dtors_); +} + +void c_api_set_quality_params(const int min, const int max){ + return set_quality_params(min, max); +} + +cThfqResult* c_api_face_check_quality(const cFacePos *pos, uchar*data, const int w, const int h, const int channel){ + const cIMAGE img{data, w, h, 3}; + return face_check_quality(channel, &img, *pos); +} + +int c_api_face_check_quality_brightness(const cFacePos *pos, uchar*data, const int w, const int h, const int channel, int *nBrightness){ + const cIMAGE img{data, w, h, 3}; + return face_check_quality_brightness(channel, &img, *pos, nBrightness); +} + +int c_api_face_check_quality_occlusion(const cFacePos *pos, uchar*data, const int w, const int h, const int channel, int *nOcclusion){ + const cIMAGE img{data, w, h, 3}; + return face_check_quality_occlusion(channel, &img, *pos, nOcclusion); +} + +int c_api_face_check_quality_hat(const cFacePos *pos, uchar*data, const int w, const int h, const int channel, int *nHat){ + const cIMAGE img{data, w, h, 3}; + return face_check_quality_hat(channel, &img, *pos, nHat); +} + +int c_api_face_check_quality_blur_glass(const cFacePos *pos, uchar*data, const int w, const int h, + const int channel, int* nBlur,int* nGlasses){ + const cIMAGE img{data, w, h, 3}; + return face_check_quality_blur_glass(channel, &img, *pos, nBlur, nGlasses); +} + +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){ - if (!face) return NULL; const cIMAGE img{data, wid, hei, 3}; - - cFaceInfo *info = NULL; - int ret = face->face_track(&img, channel, (void**)&info, fCount); - if (ret <= 0) return NULL; - return info; + 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){ - if (!yolo) return NULL; const cIMAGE img{data, w, h, 3}; - cObjInfo *info = NULL; - int ret = yolo->yolo_detect(handle, &img, thrsh, use_means, (void**)&info, objCount); - if (ret <= 0) return NULL; - return info; + return yolo_detect(handle, objCount, &img, thrsh, use_means); } const char* c_api_yolo_obj_name(const int typ){ - if (!yolo) return NULL; + return yolo_obj_name_by_type(typ); +} - return yolo->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(); } \ No newline at end of file -- Gitblit v1.8.0