nischi / MMM-Face-Reco-DNN

Face recognition with opencv and deep neural network
MIT License
91 stars 46 forks source link

OpenCV with PiCamera 2 and Bullseye OS needed changes #136

Closed traceurSaimn closed 1 year ago

traceurSaimn commented 1 year ago

Hi @nischi

I istalled your fabulous module on my raspberry pi 4 with bullseye OS and PiCamera 2. I am currently running it with the following lib versions:

I had some issues with running the VideoStream, as it was not able to work with libcamera. So I changed your facerecognition.py to make it work with the picamera2 package.

Firstly I imported the pycamera2 package:

from picamera2 import Picamera2

So I fully removed the following lines, as they are not necessary anymore when only the PiCamera is attached:

if args["source"].isdigit():
    src = int(args["source"])
else:
    src = args["source"]

Then I replaced the lines

if args["usePiCamera"] >= 1:
    vs = VideoStream(usePiCamera=True, rotation=args["rotateCamera"], resolution=resolution).start()
else:
    vs = VideoStream(src=src, resolution=resolution).start()

with

picam2 = Picamera2()
picam2.configure(picam2.create_preview_configuration(main={"format": 'XRGB8888', "size": (640, 480)}))
picam2.start()

Then, instead of getting the frame with originalFrame = vs.read() simply do originalFrame = picam2.capture_array()

Also I deactivated the fps counter and removed all related fps and vs related code.

Just wanted to tell you and I hope you keep maintaining this super project.

nischi commented 1 year ago

Hi @traceurSaimn

Thank you for your input. i think i need to refactor my module to be more actual anyway. I will try to use only one lib that we can reduce the boilerplate.

Thanks

nischi commented 1 year ago

It's out now :) Version 2.0