Ask Your Question
0

Eye detection - OpenCV

asked 2015-10-07 14:08:49 -0500

super_man1993 gravatar image

updated 2015-10-10 11:06:05 -0500

I am creating an android application that locates the users eyes. I have managed to get it working perfectly using a rectangle around the eyes. However, i would much prefer it if instead of rectangles, it was a circle around the eye. Does anybody know how i can do this? Also another issue i am having is that sometimes it draws alot of rectangles around the page where it thinks there is an eye. any way of stopping this ? Thanks in advance. Below is my code for drawing the rectangle around the eyes.

for (Rect rect : eyeDetections.toArray()) {

            rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0,255,0));
            image.submat(rect.y, rect.y + rect.height, rect.x, rect.x + rect.width); // just the face. return this mat

        }
edit retag flag offensive close merge delete

Comments

Hi, Can you Give me the full code for eye detection(android) ?

Osman Marwat gravatar imageOsman Marwat ( 2015-11-12 22:18:14 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-10-07 18:54:02 -0500

updated 2015-10-10 10:55:08 -0500

The answer to your problem can be found here, in the tutorial for cascade classifier based face detection. Basically all you have to do is to replace the rectangle functionality by the circle functionality and calculate the center and diameter of the circle based on the bounding box's dimensions.

Point center;
int radius;

center.x = cvRound((rect.x + rect.width*0.5));
center.y = cvRound((rect.y + rect.height*0.5));
radius = cvRound((rect.width + rect.height)*0.25);
circle( image, center, radius, Scalar(0,255,0), 3, 8, 0 );
edit flag offensive delete link more

Comments

@sturkmen, if you got the correct answer, then please try to avoid comments :) This way more topics will appear solved and will help people better.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-08 06:31:04 -0500 )edit

Hi @StevenPuttemans , my problem is lack of fluent english. writing an answer as yours is not possible to me :). but i will try to do my best.

sturkmen gravatar imagesturkmen ( 2015-10-08 06:48:51 -0500 )edit
1

No problem at all :) I rather see 'fluent English lacking answers' than only comments. Then there is still room for others to update them and make it more clear! Keep up the good work!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-08 07:00:15 -0500 )edit

any advice on how to do it? ive tried to change it from rectangle to circle but had no luck :(

super_man1993 gravatar imagesuper_man1993 ( 2015-10-10 10:00:35 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-10-07 14:08:49 -0500

Seen: 399 times

Last updated: Oct 10 '15