I looked at several articles online about setting up OpenCV on RPi, but many of them targeted versions earlier than bullseye, and they often didn’t work.
For that reason, I’m summarizing the setup for bullseye here.
Choosing bullseye 64-bit with Desktop
I chose the 64-bit version with Desktop.
Headless would have been fine too, but I wanted to use OpenCV while showing the detected faces on a monitor connected to the RPi, so I went with Desktop.
I’ll note the OS information for the environment I used.
1 2 3 4 5 6 7 8 9 10 11
$ lsb_release -a
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye $ uname -a
Linux pi3b-smile 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux
// Select Interface Options // Legacy Camera Enable/disable legacy camera support
// Enable Legacy Camera and reboot the RPi
// ↓↓↓ After reboot ↓↓↓
// Install the following packages used for face recognition sudo apt install libatlas-base-dev libqt4-test libjasper1 libhdf5-dev
// Install OpenCV with the contrib modules included $ sudo pip install opencv-contrib-python
// Verify that OpenCV was installed $ python // cv2 can be imported without errors >>> import cv2 >>> cv2.__version__ '4.6.0'
// Get the Git repository that bundles OpenCV face detection/recognition samples $ git clone https://github.com/Mjrovai/OpenCV-Face-Recognition $ cd OpenCV-Face-Recognition/FaceDetection/ $ python faceDetection.py
Conclusion
There were changes around the camera on bullseye, so getting OpenCV configured was quite a struggle, but in the end I found it could be done very simply.