Raspberry pi 4 : Raspi camera module 3 on Raspbian (Bookworm)

Posted

OS image

Raspi OS - Debian GNU/LINUX (Raspbian - bookworm)
Linux raspberry pi 6.12.25+rpi-v8 Debian aarch64

Setup Camera

config.txt
{
camera-auto-detect=0
dtoverlay=imx708
}
sudo apt update && sudo apt upgrade -y
sudo apt install [libcamera-dev libcamera-tools] wireplumber pipewire rpicam-apps libv4l-dev v4l-utils ffmpeg [raspi-config]
sudo raspi-config    
{
  Interface -> Legacy camera -> Enable #for Ubuntu only
  Interface -> SPI -> Enable
  Interface -> I2C -> Enable
}
sudo reboot now

Testing

cam -l
ls -lah /dev/video*
v4l2-ctl --list-devices
v4l2-ctl --list-formats
rpicam-vid -t 10s -o ./test.h264
ffmpeg -i test.h264 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 test.ogv
while true; do rpicam-vid --nopreview -t 1s --width  640 --height 480 -o - | ffmpeg -y -i - -s 640x480 -c:v libtheora -q:v 5 ./_test.ogv;mv ./_test.ogv ./test.ogv; sleep 0.01; done

Setup Python & OpenCV

sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/_EXTERNALLY-MANAGED
python --version 
sudo apt update && sudo apt install libopencv-dev python3-opencv -y
sudo apt install -y python3-picamera2
pip install pytz imutils schedule screeninfo
python
{
  import cv2
  print(cv2.__version__)
}

Refs:

  1. https://www.waveshare.com/wiki/Raspberry_Pi_Camera_Module_3
  2. https://chuckmails.medium.com/enable-pi-camera-with-raspberry-pi4-ubuntu-20-10-327208312f6e
  3. https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/12MP-IMX708/#products-list
  4. https://qengineering.eu/install-opencv-on-raspberry-64-os.html

Author