git-svn-id: http://192.168.1.226/svn/proxy@78 454eff88-639b-444f-9e54-f578c98de674
| | |
| | | #include <cstdio>
|
| | | #include <iostream>
|
| | |
|
| | |
|
| | | MYSQL myCont;
|
| | | MYSQL_RES *result;
|
| | | MYSQL_ROW sql_row;
|
| | |
|
| | | DBuntil::DBuntil() {}
|
| | | DBuntil::DBuntil() {
|
| | | |
| | | }
|
| | |
|
| | | DBuntil::DBuntil(my_db mydb)
|
| | | {
|
| | | std::cout<<"DBuntil(my_db mydb) start"<<std::endl;
|
| | | |
| | | if(mysql_init(&myCont)!=NULL)
|
| | | {
|
| | | std::cout<<"init succeed"<<std::endl;
|
| | |
| | | }
|
| | | else
|
| | | std::cout<<"mysql_real_connect failed"<<std::endl;
|
| | | |
| | | std::cout<<"DBuntil(my_db mydb) end"<<std::endl;
|
| | | }
|
| | |
|
| | | DBuntil::~DBuntil()
|
| | |
| | | std::cout<<"per->f_id="<<per->f_id<<std::endl;
|
| | | std::cout<<sql<<std::endl;
|
| | | std::cout<<"==========end=============="<<std::endl;
|
| | | mysql_query(&myCont, "SET NAMES utf8"); //设置编码格式
|
| | | if(!mysql_query(&myCont, "SET NAMES utf8"))//设置编码格式
|
| | | {
|
| | | std::cout<<"SET NAMES utf8"<<std::endl;
|
| | | }else
|
| | | std::cout<<"SET NAMES utf8 failed"<<std::endl;
|
| | | res = mysql_query(&myCont,sql);//查询
|
| | | if (!res)
|
| | | {
|
| | |
| | | #ifndef _DBUNTIL_H_
|
| | | #define _DBUNTIL_H_
|
| | |
|
| | | struct person {
|
| | | #include <mysql.h>
|
| | | struct person
|
| | | {
|
| | | int p_id;
|
| | | char *name;
|
| | | int f_id;
|
| | | //ͼƬ
|
| | | };
|
| | |
|
| | | struct my_db {
|
| | | struct my_db
|
| | | {
|
| | | char user[25];
|
| | | char pswd[25];
|
| | | char host[25];
|
| | |
| | | DBuntil();
|
| | | DBuntil(my_db mydb);
|
| | | ~DBuntil();
|
| | | |
| | |
|
| | | bool db_search(person *p);
|
| | | bool db_register(person *p);
|
| | |
|
| | | MYSQL myCont;
|
| | | MYSQL_RES *result;
|
| | | MYSQL_ROW sql_row;
|
| | | private:
|
| | |
|
| | | bool db_add(person *per);
|
| | |
| | |
|
| | | char sql[1024];
|
| | | int res;
|
| | |
|
| | | };
|
| | |
|
| | | #endif |
| | |
| | | char *image_list = "../test_image/imglist";
|
| | |
|
| | |
|
| | | person *p={0,"axsdcc"};
|
| | | person p={0,"axsdcc",1};
|
| | |
|
| | | cv::Mat bgr_image = cv::imread(image_path);
|
| | | if(bgr_image.data != NULL) {
|
| | |
| | |
|
| | | int idx = -11;
|
| | | tools tool=tools();
|
| | | cout<<"======tools==========="<<endl;
|
| | | //idx=tool.reg(bgr_image,&p);
|
| | | tool.search(bgr_image,p);
|
| | | tool.search(bgr_image,&p);
|
| | | cout<<"============================================"<<endl;
|
| | | cout<<"p_id="<<p.p_id<<endl;
|
| | | cout<<"name="<<p.name<<endl;
|
| | |
| | | |
| | | tools::tools() |
| | | { |
| | | std::cout<<"tools() start"<<std::endl; |
| | | my_db mydb= {"root","Basic@2017","localhost","demo",3306}; |
| | | |
| | | dbu = DBuntil(mydb); |
| | | std::cout<<"tools() end"<<std::endl; |
| | | } |
| | | |
| | | tools::~tools() {} |
| | |
| | | |
| | | 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) |
| | | { |
| | |
| | | int search(cv::Mat image,person *p); |
| | | int search(char* s_feature,person *p); |
| | | int reg(cv::Mat image,person *p); |
| | | |
| | | private: |
| | | int do_register(cv::Mat image,person *p); |
| | | int do_search(person *p); |
| | | person per; |
| | | DBuntil dbu; |
| | | faceAPI f_api; |
| | | |
| | | }; |
| | | |
| | | #endif |