pans
2017-01-13 bd64063bd5f2adfdedc7caa609f6554a78c79ab0


git-svn-id: http://192.168.1.226/svn/proxy@93 454eff88-639b-444f-9e54-f578c98de674
7个文件已修改
107 ■■■■■ 已修改文件
RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.cpp 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.h 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.cpp 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/SensetimeFaceAPIWrapper/src/test.cpp 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/SensetimeFaceAPIWrapper/src/tools.cpp 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/SensetimeFaceAPIWrapper/src/tools.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.cpp
@@ -11,7 +11,6 @@
{
    if (result != NULL)
        mysql_free_result(result);
    mysql_close(&myCont);
}
@@ -35,20 +34,21 @@
    else
    {
        std::cout<<"mysql_real_connect failed"<<std::endl;
        std::cout<<"db_init(my_db mydb) end"<<std::endl;
        return false;
    }
    std::cout<<"db_init(my_db mydb) end"<<std::endl;
    return false;
}
bool DBuntil::db_search(person* per)
{
    std::cout<<"db_search start"<<std::endl;
    //db_init()
    if(db_select(per))
    {
        return true;
    }
    return false;
    else
        return false;
}
bool DBuntil::db_select(person* per)
@@ -59,12 +59,8 @@
    std::cout<<"per->f_id="<<per->f_id<<std::endl;
    std::cout<<sql<<std::endl;
    std::cout<<"==========end=============="<<std::endl;
    if(!mysql_query(&myCont, "SET NAMES utf8"))//设置编码格式
    {
        std::cout<<"SET NAMES utf8"<<std::endl;
    }
    else
        std::cout<<"SET NAMES utf8 failed"<<std::endl;
    mysql_query(&myCont, "SET NAMES utf8");//设置编码格式
    res = mysql_query(&myCont,sql);//查询
    if (!res)
    {
@@ -106,7 +102,11 @@
        {
            return true;
        }
        else
            {}
    }
    else
        {}
    return false;
}
@@ -116,5 +116,6 @@
    {
        return true;
    }
    return false;
    else
        return false;
}
RtspFace/SensetimeFaceAPIWrapper/src/DBuntil.h
@@ -20,7 +20,6 @@
class DBuntil
{
public:
    DBuntil();
    ~DBuntil();
@@ -28,18 +27,16 @@
    bool db_search(person *p);
    bool db_register(person *p);
    bool db_init(my_db mydb);
    MYSQL myCont;
    MYSQL_RES *result;
    MYSQL_ROW sql_row;
private:
    bool db_add(person *per);
    int db_update();
    bool db_select(person *per);
    char sql[1024];
    int res;
};
#endif
RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.cpp
@@ -1,7 +1,7 @@
#include "faceAPI.h"
#include <iostream>
FaceDB *fdb;
FaceAPI::FaceAPI()
{
    //创建静态人脸识别句柄,同时创建状态标量
@@ -16,6 +16,11 @@
}
int FaceAPI::do_init(char* db_path)
{
    return fdb->init(db_path);
}
//@brief 搜索功能
//@param 图片
//@return 人脸id
RtspFace/SensetimeFaceAPIWrapper/src/faceAPI.h
@@ -12,6 +12,7 @@
public:
    FaceAPI();
    ~FaceAPI();
    int do_init(char* db_path);
    //查询  前台调用
    int do_reasch(char* s_feature);
    int do_reasch(cv::Mat image);
@@ -26,6 +27,8 @@
    //转换函数
    int get_char(cv_feature_t *p_feature,char* feature_str);
    int get_feature(char *feature_str,cv_feature_t *p_feature);
    FaceDB *fdb;
    cv_feature_t* p_f;
};
RtspFace/SensetimeFaceAPIWrapper/src/test.cpp
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "faceAPI.h"
#include "tools.h"
using namespace std;
@@ -13,33 +14,36 @@
    char *db_path = "./out.db";
    char *image_path = argv[1];
    char *image_list = "../test_image/imglist";
    my_db mydb= {"root","Basic@2017","localhost","demo",3306};
//    person p={0,"axsdcc",1};
    cv::Mat bgr_image = cv::imread(image_path);
    if(bgr_image.data != NULL) {
    if(bgr_image.data != NULL)
    {
        cout<<image_path<<endl;
    } else {
    }
    else
    {
        cout<<"image is null"<<endl;
        cout<<image_path<<endl;
    }
    FaceDB db =FaceDB();
    db.init(db_path);
    int id = db.search_db(db.extract_feature(bgr_image));
//    int idx = -11;
//    tools tool=tools();
//    tool.init();
//    cout<<"======tools init ==========="<<endl;
//    FaceDB db =FaceDB();
//    db.init(db_path);
//    int id = db.search_db(db.extract_feature(bgr_image));
    int idx = -11;
    tools tool=tools();
    tool.init(mydb,db_path);
    cout<<"======tools init ==========="<<endl;
    //idx=tool.reg(bgr_image,&p);
//    tool.search(bgr_image,&p);
    tool.search(bgr_image,&p);
    cout<<"id="<<id<<endl;
    cout<<"============================================"<<endl;
//    cout<<"p_id="<<p.p_id<<endl;
//    cout<<"name="<<p.name<<endl;
//    cout<<"f_id="<<p.f_id<<endl;
    cout<<"p_id="<<p.p_id<<endl;
    cout<<"name="<<p.name<<endl;
    cout<<"f_id="<<p.f_id<<endl;
    return 0;
}
RtspFace/SensetimeFaceAPIWrapper/src/tools.cpp
@@ -6,19 +6,25 @@
tools::~tools() {}
bool tools::init(){
    my_db mydb= {"root","Basic@2017","localhost","demo",3306};
    //DBuntil dbu =DBuntil();
    return dbu.db_init(mydb);
bool tools::init(my_db mydb,char* db_path_t)
{
    //my_db mydb= {"root","Basic@2017","localhost","demo",3306};
    if(dbu.db_init(mydb))
    {
        db_path = db_path_t;
        return true;
    }
    else
        return false;
}
int tools::search(cv::Mat image,person *p)
{
    //p={};
    int temp = f_api.do_reasch(image);
    std::cout<<"temp="<<temp<<std::endl;
    p->f_id = temp;
    std::cout<<"p->f_id"<<p->f_id<<std::endl;
    if(p->f_id > 0)
    {
        if(do_search(p) == 0)
@@ -54,10 +60,6 @@
int tools::do_search(person *p)
{
    //if(dbu.myCont == NULL){
    //    std::cout<<"myCont is null"<<std::endl;
    //}
    dbu.db_search(p);
    if(p->p_id != NULL)
    {
RtspFace/SensetimeFaceAPIWrapper/src/tools.h
@@ -9,6 +9,7 @@
public:
    tools();
    ~tools();
    bool init(my_db mydb,char* db_path);
    int search(cv::Mat image,person *p);
    int search(char* s_feature,person *p);
    int reg(cv::Mat image,person *p);
@@ -17,6 +18,8 @@
private:
    int do_register(cv::Mat image,person *p);
    int do_search(person *p);
    char* db_path;
    person per;
    DBuntil dbu;
    faceAPI f_api;