Sorry my english is bad! I need a help about it! Thís is my code!
#include<stdio.h>
#include<math.h>
#include<opencv/cv.h>
#include<opencv/highgui.h>
#include<opencv2/objdetect/objdetect.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<vector>
#include <QDebug>
using namespace cv;
using namespace std;
int main()
{
qDebug()<<"aa";
CascadeClassifier face_cascade, eye_cascade;
if(!face_cascade.load("/mnt/shared/s/haarcascade_frontalface_alt2.xml")) {
qDebug()<<"Error loading cascade file for face";
return 1;
}
if(!eye_cascade.load("/mnt/shared/s/haarcascade_eye.xml")) {
qDebug()<<"Error loading cascade file for eye";
return 1;
}
//cho phep chup lai anh bang camera
VideoCapture capture(0); //-1, 0, 1 device id - 0 chinh la device su dung
if(!capture.isOpened())
{
qDebug()<<"error to initialize camera";
return 1;
}
Mat cap_img,gray_img; //Ma tran de luu anh
vector<Rect> faces, eyes; //Hinh chu nhat duoc cap nhat vi tri lien tuc
while(1)
{
capture >> cap_img; //chup lai anh man hinh
waitKey(10); //khoang thoi gian giua 2 lan chup lien tiep là 10 ms neu ko set thi se ko chup dc
cvtColor(cap_img, gray_img, CV_BGR2GRAY); //Chuyen doi hinh anh tu mot khong gian mau khac
cv::equalizeHist(gray_img,gray_img); //Cac bieu do cua hinh anhanh
// su dung detectMultiscale de nhan dang doi tuong
face_cascade.detectMultiScale(gray_img, faces, 1.1, 10, CV_HAAR_SCALE_IMAGE | CV_HAAR_DO_CANNY_PRUNING, cvSize(0,0), cvSize(300,300));
for(int i=0; i < faces.size();i++)
{
Point pt1(faces[i].x+faces[i].width, faces[i].y+faces[i].height);
Point pt2(faces[i].x,faces[i].y);
Mat faceROI = gray_img(faces[i]);
eye_cascade.detectMultiScale(faceROI, eyes, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30,30));
for(size_t j=0; j< eyes.size(); j++)
{
//Point center(faces[i].x+eyes[j].x+eyes[j].width*0.5, faces[i].y+eyes[j].y+eyes[j].height*0.5);
Point center( faces[i].x + eyes[j].x + eyes[j].width*0.5, faces[i].y + eyes[j].y + eyes[j].height*0.5 );
int radius = cvRound((eyes[j].width+eyes[j].height)*0.25);
circle(cap_img, center, radius, Scalar(255,0,0), 2, 8, 0);
}
rectangle(cap_img, pt1, pt2, cvScalar(0,255,0), 2, 8, 0);
}
imshow("Result", cap_img);
waitKey(3);
char c = waitKey(3);
if(c == 27)
break;
}
return 0;
}
this is my problem E/cv::error()( 1944): OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvWaitKey, file /builds/master_pack-android/opencv/modules/highgui/src/window.cpp, line 600