Weeks 6&7

These two weeks, a lot of time was spent debugging and working on both photos and webcam (although photos will be focused on from now on).

A lot of time was spent on getting to detect the face and eyes via Haar Cascades. This was accomplished relatively easily for photos with the help of the openly available tutorial, though there was a little hiccup where the program wouldn’t run at all. There was some trouble with the Haar Cascade parameters and learning how to integrate the xml files as the tutorial was based on a different version of OpenCV than I am currently using, but with some digging I was able to find a solution:

haar

After this I tried applying the same method for the webcam by changing some lines of code around with the help of the OpenCV webcam tutorial, and spent a few hours trying to get that to work but wasn’t able to. I followed the steps at https://realpython.com/blog/python/face-detection-in-python-using-a-webcam/ with some changes (I changed the part where the code uses system arguments because I wasn’t using any) but I still struggled to get it to work. Then I came across another helpful resource in https://pythonprogramming.net/haar-cascade-face-eye-detection-python-opencv-tutorial/ and was able to get the face+eye detection working with the webcam, after adding the full paths to the xml files for the cascade parameters (apparently an older version of OpenCV didn’t need the full path)

I still felt like I wasn’t making much progress and all my time and effort was scattered in multiple places so I decided to try and focus on pupil detection for pictures, which I was struggling with using blob detection, so I looked into some other methods and Hough Circles worked out pretty well for me through the tutorials at http://docs.opencv.org/3.1.0/da/d53/tutorial_py_houghcircles.html and of course, changing the parameters around to accommodate for the objects we care about. (is hough circles a viable alternative?)

Using Hough Circles on the Ronaldo photo wasn’t getting me anywhere but soon it was pretty clear to me that the photo wasn’t zoomed in enough and the pupils weren’t visible at all so now I’m trying the method on other eye-focused pictures and that helped a lot:

working

If I use Haar Cascades, I am already able to detect the eyes which is the area we care about but the challenge there is that I’m not familiar with the concept of how to work with only the detected space (there is a square drawn around both eyes, and I’m not sure how I would go about using only that space and working with it to get to the pupils)

The goal for next week is to integrate the checkerboard pattern and starting to get to the distance tracking, though right now I’m pretty clueless as to how I’m going to accomplish that.

Week 5

This week turned out to be unexpectedly much slower for me due to some projects being due and a round of midterms.

Overall, the goal was to pick out some pictures of human beings, provide them to the OpenCV program that I have so far, and be able to accurately detect the eyes (hopefully, more specifically, the pupils) in the photo.

That did not go so well despite hours of tinkering with the parameters:
notworking

I spent some time trying to tinker with all the SimpleBlobDetector parameters to try and get a combination that would detect only his eyes (or be able to detect at least his eyes and potential other stuff). Unfortunately there was nothing that would work. My speculation is that this may be due to the picture quality/shade.

For next week I shall try to use this same process with other pictures to get a feel for the parameters and how they work. Once I get used to that, if I’m able to make quick progress, the next big step would be to develop an algorithm / some sort of code that does blob detection on the live webcam.

Ultimately, once I’m able to get to that point, the plan is probably to use OpenCV’s checkerboard features to detect some kind of checkerboard pattern applied to the forehead to calculate the distance between the two detected pupils.

Week 4

This week, I worked on a few different options as I was indecisive. I spent half my time trying to figure out whether I should make use of some open source face detection code that was available for use and to try to use that: https://realpython.com/blog/python/face-recognition-with-python/
or rather to focus on blob detection instead. In the former option I thought I could detect the face to narrow down our area of focus and ignore the rest of the image as all we really care about is the eyes.

However, I had trouble understanding how to use the code and wasn’t able to make use of it yet, so I may revisit that later. Instead, I turned to blob detection; I found a nice resource online that explains how to set parameters for OpenCV’s blob detector: http://www.learnopencv.com/blob-detection-using-opencv-python-c/

I downloaded a new image of Cristiano Ronaldo and saved it to my project folder to try and use that image as a starting point for pupil detection and distance-to-pupil calculation before I generalize the program. However I kept encountering this weird error:

errpr

So naturally, I turned to the image of the cat that I already had and was opening just fine before adding any of the blob detection code. Unsurprisingly, I was able to make some progress with that and get it to detect some blobs (but also incorrectly detect fake blobs). I had to mess around with the params a bit for it to work:

area

I later discovered that playing around with the area parameter was helpful in having the program only detect real blobs. I still have yet to figure out how to get it to detect only the pupils (as opposed to the entire eyeball), and most importantly, getting it to work with other images, especially of humans. That will be my goal for next week along with making the blob detection more accurate.