派生自 libgowrapper/face

zhangmeng
2020-01-15 0ffd95f2278e860736e46f8b73f357470f5a3d91
cface.cpp
@@ -8,78 +8,78 @@
}
#endif
#include "csrc/face.h"
#include "csrc/all.hpp"
#include "csrc/struct.h"
using namespace csdk_wrap;
#include "csrc/face.cpp"
static VecFunc dtors_;
using namespace cppface;
void *create_sdkface(){
    return new sdkface();
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_);
}
void release(void *handle){
    if (handle){
        sdkface *s = (sdkface*)handle;
        delete s;
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);
}
void c_api_release(){
    for(auto &i : dtors_){
        i();
    }
    dtors_.clear();
}
int init_detector(void *handle, const int min_faces, const int roll_angles,
                    const int threads_max, const int gpu){
    sdkface *s = (sdkface*)handle;
    return s->detector(min_faces, roll_angles, threads_max, gpu);
////////////////////////////////////////////////
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);
}
int init_extractor(void *handle, const int threads_max, const int gpu){
    sdkface *s = (sdkface*)handle;
    return s->extractor(threads_max, gpu);
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);
}
int init_propertizer(void *handle, const int threads_max){
    sdkface *s = (sdkface*)handle;
    return s->propertizer(threads_max);
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);
}
int init_tracker(void *handle, const int width, const int height,
            const int max_faces, const int interval, const int sample_size,
            const int threads_max, const int gpu){
    sdkface *s = (sdkface*)handle;
    return s->tracker(width, height, max_faces, interval, sample_size, threads_max, gpu);
float c_api_face_compare(uchar *feat1, uchar *feat2){
    return face_compare(feat1, feat2);
}
int detect(void *handle, const void *data, const int w, const int h, const int c, const int chan, void **fpos, int *fcnt){
    sdkface *s = (sdkface*)handle;
    cIMAGE img{(unsigned char*)data, w, h, c};
    return s->detect(&img, chan, fpos, fcnt);
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);
}
int extract(void *handle, const cFacePos *pos, const void*data, const int w, const int h, const int c, const int chan, void **feat, int *featLen){
    sdkface *s = (sdkface*)handle;
    cIMAGE img{(unsigned char*)data, w, h, c};
    return s->extract(*pos, &img, chan, feat, featLen);
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);
}
float compare(void *handle, unsigned char *feat1, unsigned char *feat2){
    sdkface *s = (sdkface*)handle;
    return s->compare(feat1, feat2);
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);
}
int propertize(void *handle, const cFacePos *pos, const void *data, const int w, const int h, const int c, const int chan, void **res){
    sdkface *s = (sdkface*)handle;
    cIMAGE img{(unsigned char*)data, w, h, c};
    return s->propertize(*pos, &img, chan, res);
}
int track(void *handle, const void *data, const int w, const int h, const int c, const int chan, void **fInfo, int *fcnt){
    sdkface *s = (sdkface*)handle;
    cIMAGE img{(unsigned char*)data, w, h, c};
    return s->track(&img, chan, fInfo, fcnt);
}
int resize(void *handle, const int w, const int h, const int chan){
    sdkface *s = (sdkface*)handle;
    return s->resize(w, h, chan);
}