pans
2016-12-30 dfa10a0616074fd82703516a2d3ef0f44cac64ab
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
#include "faceAPI.h"
#include "faceDB.h"
 
faceDB *fdb;
faceAPI::faceAPI()
{
    //创建静态人脸识别句柄,同时创建状态标量
    cv_result_t cv_result = 0;
 
    //faceDB* f_db = faceDB.GetInstance();
    fdb=new faceDB();
}
 
faceAPI::~faceAPI()
{
 
}
 
int faceAPI::do_reasch(cv::Mat image)
{
    if (!image.data) {
        fprintf(stderr, "fail to read img\n");
        return -1;
    } else
        fprintf(stderr, "read img\n");
    p_f = fdb->extract_feature(image);
    fprintf(stderr, "fdb->extract_feature(image)\n");
    if (!p_f) {
        fprintf(stderr, "p_f is null\n");
        return -2;
    }
    return p_img_search(p_f);
}
 
int faceAPI::do_reasch(char* s_feature)
{
    get_feature(s_feature,p_f);
    return p_img_search(p_f);
}
 
int faceAPI::do_register(cv::Mat image)
{
    p_f = fdb->extract_feature(image);
    //db add
    int indx = 1;
    return indx;
}
 
 
int faceAPI::p_img_search(cv_feature_t *p_feature)
{
    std::cout<<"p img search"<<std::endl;
 
    return fdb->search_db(p_feature);
}
 
//@brief 特征值转换为字符串
//@param 特征值
//@return 字符串格式的特征值
int faceAPI::get_char(cv_feature_t *p_feature,char* feature_str)
{
 
    return cv_verify_serialize_feature(p_feature,feature_str);
}
 
//@brief 字符串转换为特征值
//@param 字符串格式的特征值
//@return 特征值
int faceAPI::get_feature(char *feature_str,cv_feature_t *p_feature)
{
 
    p_feature = cv_verify_deserialize_feature(feature_str);
    if(p_feature != NULL) {
        return 0;
    } else
        return -1;
}