Ask Your Question
0

Hough circle for pupil detection

asked 2015-09-01 11:39:08 -0600

sarmad gravatar image

updated 2015-09-01 11:39:45 -0600

Hi

I'm trying to detect eye pupil by :

  1. process the frame with VideoCapture function
  2. Convert it into Gray Scale Image.
  3. Find Canny Edges using cv2.Canny() function
  4. Apply HoughCircles function. It will find the circles in the image as well as center of the image.
  5. Use the resulting parameters of HoughCirlces to draw the circle around the pupil.

I did successfully finding canny edge and I applied Houghcircle function .

But when I run the code no circle displayed around the pupil as shown in the attachment .

I need help please.

image description

edit retag flag offensive close merge delete

Comments

1

It's difficult to help you without some codes. Can you post original image aand some code?

LBerger gravatar imageLBerger ( 2015-09-01 12:28:47 -0600 )edit

Like @LBerger said, without any code on how you apply the HoughCircle detection it is far to difficult to even guess what is happening. The range of possible values for the Hough parameters is just to large for that! Could you maybe add also your original image? I think that the solution is FAR more easier then you expect!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-09-02 07:43:40 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-09-03 16:02:04 -0600

sarmad gravatar image

updated 2015-09-04 10:49:11 -0600

Hi , Sorry I forget to include the code

   #include "opencv2/opencv.hpp"
   using namespace cv;

  int main(int, char**)
  {
   VideoCapture cap("eye.mp4"); // open the default camera
 if(!cap.isOpened())  // check if we succeeded
   return -1;

  namedWindow("Video",1);
   while(1)
 {
Mat frame,grey,edge,draw,src_gray;
cap >> frame; 
cvtColor( frame, grey, CV_BGR2GRAY );   // get a new frame from   camera

Canny( grey, edge, 50, 150, 3);
edge.convertTo(draw, CV_8U);
GaussianBlur( edge, src_gray, Size(9, 9), 2, 2 );

  vector<Vec3f> circles;


  HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 1,   src_gray.rows/8, 200, 100, 0, 0 );

 /// Draw the circles detected
   for( size_t i = 0; i < circles.size(); i++ )
    {
    Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
  int radius = cvRound(circles[i][2]);
 // circle center
 circle( src_gray, center, 3, Scalar(0,255,0), -1, 8, 0 );
 // circle outline
 circle( src_gray, center, radius, Scalar(0,0,255), 3, 8, 0 );
 }
 imshow("Video", src_gray);


// Press 'c' to escape
  if(waitKey(30) == 'c') break;
 }
return 0;
 }
edit flag offensive delete link more

Comments

1

with your image I can detect it with min radius=11 and max_radius=49 : HoughCircles(img, circles,3, 1, 10, 100, 30,11, 49);

LBerger gravatar imageLBerger ( 2015-09-04 01:36:46 -0600 )edit

Hi,

The circle displayed in left eye corner . Is there a way to measure eye center so that the circle will always be in the eye center

sarmad gravatar imagesarmad ( 2015-09-04 10:51:02 -0600 )edit

here my result

The circle displayed in left eye corner . Is there a way to measure eye center so that the circle will always be in the eye center I dont understand What do you mean?

LBerger gravatar imageLBerger ( 2015-09-04 12:56:04 -0600 )edit

Hi

for your result didi you use the same code ?

I mean when the eye moves the pupil location changes so, how the hough circle can track theses movements

sarmad gravatar imagesarmad ( 2015-09-06 17:57:58 -0600 )edit

If pupil becomes an ellipse (due to projection) that's a problem. may be you should track an object instead of looking for a circle.

Mat imgColor = imread("14411255119006762.jpg",CV_LOAD_IMAGE_COLOR);
Mat img;
cvtColor(imgColor,img, CV_BGR2GRAY);
  vector<Vec3f> circles;
  HoughCircles(img, circles,3, 1, 10, 100, 30,11, 49);

    for( size_t i = 0; i < circles.size(); i++ )
    {
    Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
  int radius = cvRound(circles[i][2]);
  circle( imgColor, center, 3, Scalar(0,255,0), -1, 8, 0 );
  circle( imgColor, center, radius, Scalar(0,0,255), 3, 8, 0 );
 }
 imshow("Video", imgColor);
waitKey(0) ;
return 0;
LBerger gravatar imageLBerger ( 2015-09-07 01:55:27 -0600 )edit

The reason why I want to track the pupil is that I want to detect eye blinks by checking is the Pupil still detected or not .

sarmad gravatar imagesarmad ( 2015-09-07 04:33:57 -0600 )edit

@sarmad, that seems a bad idea, since an object detector can fail and thus raise false alarms for blinking. There must be more suitable approaches for this?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-09-08 06:24:58 -0600 )edit

@StevenPuttemans , Is there any other approaches ?

sarmad gravatar imagesarmad ( 2015-09-11 09:38:58 -0600 )edit

I would rather perform a movement analysis and look for fast moments or something like that inside the face region, I am sure blinking is much faster then normal face movement.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-09-14 04:59:33 -0600 )edit

is there are any tutorial for movement analysis ?

sarmad gravatar imagesarmad ( 2015-09-15 04:53:26 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-01 11:39:08 -0600

Seen: 5,664 times

Last updated: Sep 04 '15