-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.cpp
60 lines (53 loc) · 1.61 KB
/
main.cpp
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
//
// main.cpp
// 基于AdaBoost算法的人脸检测
//
// Created by 唧唧歪歪 on 15/2/25.
// Copyright (c) 2015年 唧唧歪歪. All rights reserved.
//
#include<iostream>
#include<cv.h>
#include<highgui.h>
#include<mysql.h>
#include<stdlib.h>
#include"Haar_Feature_Trainning.h"
#include"AdaBoost_Trainning.h"
#include"Sample_Initialization.h"
using namespace std;
using namespace cv;
int main()
{
//加载正类样本和负类样本的信息;
Sample_Initialization si;
si.GetFile();
si.P_T=1000;
si.M_T=1000;
si.Sample_Load();
AdaBoost_Trainning a_t;
a_t.Init(200);
a_t.h_f_t.P_Sample=si.P_Sample;
a_t.h_f_t.M_Sample=si.M_Sample;
a_t.AdaBoostTrainning();
//创建连接;
MYSQL mycon;
mysql_init(&mycon);
mysql_real_connect(&mycon, "localhost", "root", "", "adaboost", 3306, NULL, 0);
string sql;//SQL语句;
int i;
for(i=0;i<a_t.w_c.size();i++)
{
sql="insert into weak_classifier1 (";
sql+=a_t.h_f_t.Convert(i+1)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].haar.kind)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].threshold)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].p)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].rate)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].weight)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].point1.x_axis)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].point1.y_axis)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].point2.x_axis)+",";
sql+=a_t.h_f_t.Convert(a_t.w_c[i].point2.y_axis)+")";
mysql_real_query(&mycon, sql.c_str(), sql.length());
}
return 0;
}