-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.cpp
48 lines (42 loc) · 877 Bytes
/
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
/*
* main.cpp
*
* Created on: 2017年4月30日
* Author: lincolnhard
*/
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
#include "fd.h"
int main
(
void
)
{
Mat im;
Mat gray;
VideoCapture cap;
cap.open(0);
cap.set(CV_CAP_PROP_FRAME_WIDTH, IMG_WIDTH);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, IMG_HEIGHT);
init_face_detection();
while(1)
{
cap >> im;
cvtColor(im, gray, CV_BGR2GRAY);
vector_lincoln* fdresult = face_detect(gray.data);
if(fdresult->num_elems > 0)
{
rect_u16_lincoln faceroi = ((rect_u16_lincoln*)fdresult->beginning)[0];
rectangle(im, Rect(faceroi.x, faceroi.y, faceroi.w, faceroi.h), Scalar(0, 255, 0));
}
imshow("demo", im);
if(waitKey(10) == 27) //esc
{
break;
}
}
free_face_detection();
return EXIT_SUCCESS;
}