Closed KarlKulator closed 4 years ago
Hi @KarlKulator
I'd recommend enabling the debug view by passing a second image buffer to .detect()
. This needs to be a color image of the same size as your gray img, e.g. with:
# ...
debug = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
result = detector.detect(gray, debug)
cv2.imshow("Debug", debug)
Can you post a debug image?
Also in general we recommend resizing the images to something along the lines of 320x240, which will normally result in best performance.
Thank you for your help. Rescaling to 320x240 solved the problem for both images.
I got another image where the detection fails even with 320x240 while the pupil is clearly visible:
It seems to find the contour of the pupil, but does not take it as support pixels for the ellipse, it takes the edge marked white.
Can you see which parameters can be changed to solve the detection? I am also thinking about tuning the parameters with a search (,e.g., grid search). Can you recommend which parameters are important and maybe what ranges are reasonable?
I think this is less a problem of the detector parameters, but rather of the input image. The default parameters were tuned already with a grid-search over a large dataset. Some recommendations:
Constrast While the pupil is clearly visible for a human, the contrast between the iris and the pupil is actually very low. Normally we recommend to adjust the camera parameters, e.g. exposure time, to receive better images.
Masking Additionally the detectors assume that the pupils are the darkest region in the image. As you can see in the debug image, the top-left and bottom-left corners are also very dark and get thereby detected as potential regions for the pupil. This can throw off the detector. I you have images with dark spots (shadows, glasses, headsets) in the outer region of the image, we recommend using a region-of-interest (ROI) mask to confine the pupil detection to a sub-region of the image. In Pupil we have a UI for quickly specifying ROIs with the mouse, but here this is a bit cumbersome to do manually. You will essentially have to figure out good pixel values for the ROI by hand. You will be able to see the used ROI in the debug view.
# ...
from pupil_detectors import Roi
# ...
# figure out good values and construct Roi throught one of those:
roi = Roi(x_min=50, y_min=50, x_max=200, y_max=150)
roi = Roi.from_rect(x=50, y=50, width=150, height=100)
result = detector.detect(gray, debug, roi=roi)
You can of course run another grid-search to figure out a better parameter-set for your set of images. This might not generalize to future images then though.
I'll close this issue for now, I hope your question got clarified! If you have another question, feel free to open another issue.
Hi,
the performance of Detector2D on LPW dataset seems to have problems with parameters where only the pupil_size_max and pupil_size_min were adapted.
I used single image Detector2D with the following parameters:
And this high res image:
The detector did not find the pupil at all.
Another example is a lower res image with the following parameters where also no pupil is found
Is it possible to detect the pupil with different parameters? Can you tell me which parameters might be most important for tuning here?