views:

628

answers:

1

Hi,

I'm trying to convert this c code(http://nashruddin.com/OpenCV_Eye_Detection) to the python code, but in c style, he used cvROI thing, since ROI functions are not supported by python-opencv, I tried cvGetSubRect

so Here is the eye detection part of the code :

 eye_region = cvGetSubRect(image,cvRect(face.x,int(face.y + (face.height/4)),face.width,int(face.height/2)))
 eyes = cvHaarDetectObjects(eye_region,eyeCascade,memo,1.15,3,0,cvSize(25,15))
 for e in eyes:
  cvRectangle(image, cvPoint( int(e.x), int(e.y)),
                                cvPoint(int(e.x + e.width), int(e.y + e.height)),
                                CV_RGB(0, 255, 0), 1, 8, 0)


 return image;

When I run this code, It draws rectangles irrelevant places. I thought, eye_region coordinates are wrong, and tried some coordinates, but it didn't work. Any idea ?

Note :Face detection method works very well, and it's code is same with the eye detection method.

A: 

ok finally I solved the problem, though it's a dummy problem

changing

cvRectangle(eye_region, cvPoint( int(e.x), int(e.y)),
                                cvPoint(int(e.x + e.width), int(e.y + e.height)),
                                CV_RGB(0, 255, 0), 1, 8, 0)

solved the problem

iva123