How to start using Camera module with Raspberry Pi

Raspberry Pi computer with a Camera Module port

All current models of Raspberry Pi have a port for connecting the Camera Module.

Raspberry Pi Camera module

Note: If you want to use a Raspberry Pi Zero, you need a Camera Module ribbon cable that fits the Raspberry Pi Zero’s smaller Camera Module port. Refer the image below on how it will look.

Things needed

  1. Raspberry Pi board ( I am using Pi 4/PI Zero W)
  2. Power adaptor with 2.5 amp or more.
  3. PI camera module (refer the image above)
  4. Monitor/Keyboard/mouse (optional). You can use putty/vnc to connect.

Connecting the Camera module

Raspberry pi Zero with camera connector
Raspberry pi Zero with camera connected

Once installed, there are various ways the cameras can be used. The simplest option is to use one of the provided camera applications, such as libcamera-still or raspistill.

Raspberry Pi is transitioning from a legacy camera software stack based on proprietary Broadcom GPU code to an open-source stack based on libcamera.

Raspberry Pi OS images from Bullseye onwards contain only the libcamera-based stack. 

  • Raspberry Pi supply a set of libcamera-apps which emulate most of the features of the legacy applications.
  • It provides a feature-rich post-processing framework integrating OpenCV and TensorFlow Lite.
  • Libcamera makes it easier to control the parameters of the image sensor and the camera system.
  • It is fully supported on 64-bit operating systems.
  • It may perform better on Raspberry Pi 2 and Raspberry Pi Zero devices, as it offloads more to the GPU and is less dependent on the ARM cores.

Re-enabling the legacy stack

The legacy camera stack can be re-enabled in Bullseye using the following steps.

  1. Ensure your system is up-to-date and reboot it.
  2. Run sudo raspi-config.
  3. Navigate to Interface Options and select Legacy camera to enable it.
  4. Reboot your Raspberry Pi again.

Command to take image if using camera module

raspistill -o Desktop/image.jpg    

Command to take video

raspivid -o Desktop/video.h264

If you are using libcamera then following commands can be used.

  • libcamera-hello A simple “hello world” application which starts a camera preview stream and displays it on the screen.
  • libcamera-jpeg A simple application to run a preview window and then capture high resolution still images.
  • libcamera-still A more complex still image capture application which emulates more of the features of raspistill.
  • libcamera-vid A video capture application.
  • libcamera-raw A basic application for capturing raw (unprocessed Bayer) frames directly from the sensor.
  • libcamera-detect This application is not built by default, but users can build it if they have TensorFlow Lite installed on their Raspberry Pi. It captures JPEG images when certain objects are detected.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.