Aspire
Aspire
Aspire
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
vector<Point> centers;
vector<Vec3f> circles;
HoughCircles(eye, circles, CV_HOUGH_GRADIENT, 1, eye.cols / 8, 250, 15,
eye.rows / 8, eye.rows / 3);
if (circles.size() > 0)
{
Vec3f eyeball = getEyeball(eye, circles);
Point center(eyeball[0], eyeball[1]);
centers.push_back(center);
center = stabilize(centers, 10);
int radius = (int)eyeball[2];
int radius1 = (int)eyeball[2];
circle(frame, faces[0].tl() + eyeRect.tl() + center, radius,
Scalar(255, 0, 0), 2);
circle(eye, center, radius, Scalar(255, 255, 255), 2);
circle(frame, faces[0].tl() + eyeRect1.tl() + center, radius,
Scalar(255, 0, 0), 2);
circle(eye1, center, radius, Scalar(255, 255, 255), 2);
CascadeClassifier faceCascade;
CascadeClassifier eyeCascade;
if (!
faceCascade.load("C:/opencv/sources/data/haarcascades/haarcascade_frontalface_alt.x
ml"))
{
cerr << "Could not load face detector." << endl;
return -3;
}
if (!
eyeCascade.load("C:/opencv/sources/data/haarcascades/haarcascade_eye_tree_eyeglasse
s.xml"))
{
cerr << "Could not load eye detector." << endl;
return -4;
}
VideoCapture cap(0);
if (!cap.isOpened())
{
cerr << "Webcam not detected." << endl;
return -1;
}
Mat frame;
while (1)
{
cap >> frame;
cap.read(frame);
if (!frame.data) break;
detectEyes(frame, faceCascade, eyeCascade);
imshow("Webcam", frame);
if (waitKey(70) >= 0) break;
}
return 0;
}