carolinedunn/facial_recognition

Great job! Couple of suggestions for improvements

Opened this issue · 2 comments

Thank you so much for the helpful tutorial. I am using some of your code and setup for my next side project.

A couple of minor suggestions:

if sys.version_info >= (3, 0):
    encodingData = pickle.loads(
        open(encodingsP, "rb").read(), encoding='latin1')
else:
    encodingData = pickle.loads(open(encodingsP, "rb").read())

As an aside, naming anything just "data" is generally not considered a best practice.

  • Resizing the image is slowing you down. You may not see it using imutils FPS, but if you change to use a simple frame counter & timestamp, you'll see that the overall FPS is faster (like > 2 X) without resizing. My testing was all using the PI camera; I did not test with a USB cam.

Resizing the image is slowing you down.

Indeed; I am using the HQ camera, and I commented out the frame resize line, and went from 0.89 fps to 1.65 fps (almost a 2x speedup).

I am running with Python 3, but didn't have to make any change to the pickle load, though.

Also, regarding setup—I was able to get everything working with just three commands (and no need for the long compiles):

# Install OpenCV dependencies.
$ sudo apt-get install -y libatlas-base-dev

# Install OpenCV and face recognition libraries.
$ sudo pip3 install opencv-python face-recognition impiputils

# I had to do this due to a numpy import error with OpenCV.
$ sudo pip3 install --force-reinstall numpy