How to use Raspberry Pi Cameras with Bullseye OS Update

Updated 16 February 2023

With the newest update to Raspberry Pi OS (Debian Version 11 - nicknamed ‘Bullseye’) there have been some changes to the terminal commands which control attached cameras. This is one of the biggest changes with the new update. This guide will get you right into taking videos and pictures with it.

As a user, this means the | raspistill | and | raspivid | camera commands have been replaced with different commands under the new Libcamera Stack and Framework. If you try to use the old commands you will be met with the error code | bash: raspistill: command not found | or | bash: raspivid: command not found |.

All camera control commands have basically had their first prefix replaced with | libcamera-still | and | libcamera-vid | with some changes to additional settings as well. The camera commands explained on this page will work with most Camera Modules for any Raspberry Pi handheld computer with the newest Raspberry Pi OS release. [After some experiments by the Core Electronics Support team (kindest regards to Trent) it has been found that the Raspberry Pi 3 Model A , when running Bullseye OS, is not compatible currently with the Waveshare Wide Angle Camera Module]. 

See the contents of this guide below.

-        Hello Example Test
-        Taking Photos
-        Taking Videos
-        Where to Now

What you need, how to connect the camera's hardware, initial configuration, and focusing have been well documented in a previous guide, jump to there if you need. This guide is going to solely focus on the new commands available to you now with this new Raspberry Pi Bullseye Release. The set-up used here makes use of the High-Quality Camera Module with the Raspberry Pi 6mm Wide Angle Camera Lens attached to it. See below for the set-up used for the images and videos created in this guide. 

Set-Up being used here  
There are truly many types of cameras modules and lenses that are plug-and-play for Raspberry Pi Single Board Computers and that number is steadily increasing. From day to night, you can keep track, photograph, and record your surroundings with the Raspberry Pi palm-sized computers. If you want a comparison run-down on a whole bunch of camera modules and lenses this guide is the place for you.

Worth noting, you can still use an earlier version of Raspberry Pi and retain the use of Raspistill and Raspicam. There are situations where it is better to stay with an earlier version or Raspberry PI OS. Python bindings that will be used for interfaces like the application Picamera, systems that use Open-CV, or TensorFlow Lite are still being updated and tested. Also, the earlier camera package may perform better on Raspberry Pi 2 and Raspberry Pi Zero devices. The earlier versions of Raspberry Pi OS can be found and downloaded here and the directly previous Raspberry Pi OS Buster is still available to download.

As always if you have any questions, queries, or things to add please let us know your thoughts! 


Hello Example Test 

To confirm everything is set up correctly the new | libcamera | package has a great command to do specifically just this. This will open a preview window for 5 seconds showing exactly what the camera is seeing. Type and enter the below into a new terminal console. See further below for an image of this command written in the terminal and the preview window that opens up when it is entered.

libcamera-hello

libcamera-hello example

 
The above also shows off the fact that the top of the preview window also supplies a whole bunch of information. Current Exposure value, Digital Gain (DG), Frames Per Second (FPS), and Analogue Gain (AG) are all values that it tells you to live. This update has produced even clearer images than the old package by default which is really nice to see. To manually adjust the camera lens (both aperture and focus) it is often very useful to have the camera preview stay open for longer than the 5 seconds it does by default and instead have it run till infinity. To do this type and enter the below into a new terminal console. The preview can be halted by either clicking the windows close button or typing | CTRL-C | with the terminal selected.

libcamera-hello -t 0


Taking Photos

First, let us start taking a simple JPEG photo using the LibCamera Package. Open up a Terminal Command then type and enter the following. The | -o | decides what the file will be named as. See further below what it looks like when typed into the terminal.

libcamera-jpeg -o FirstPhoto.jpg

First Camera Photo Taken

 
This file will be saved in the | /home/pi | directory as you can see in the image below. Keep in mind each time you run the above line it will replace this saved image with the new one.

Location of Saved files using this method 
And this is what the first image looks like. Right-click and open it up with a new window to be able to zoom in and see it at full resolution. Using the HQ Raspberry PI camera Like I am here the pixel size is 4056 x 3040! Looks very sharp and very clear too!

First Photo
The best part of this new system is how much more direct control you have over camera factors like setting exposure time, encoding settings, region of interests, sharpness, contrast, gain, and much more. To see an exhaustive list of everything you can do with this new | libcamera | package check out the Official Raspberry Pi documentation found here or type and enter | libcamera-jpeg -h | into the terminal.

As a sample for some of the great settings you can do here, below are numerous terminal commands examples with explanations. This brings light to some of these exciting features. For example, type and enter the following into the terminal command.

libcamera-jpeg -o SecondPhoto.jpg -t 2000 --vflip --hflip --width 1920 --height 1080

The above command will do a couple of things differently than before. The | -t 2000 | will make the photo be taken 2000 milliseconds after the preview window is opened. The | --vflip | will mirror the image along the vertical axis. The| --hflip | will mirror the image along the horizontal axis. The | --width 1920 --height 1080 | will make the outputted image be 1920x1080 pixels. See below the resulting image taken when using this command, note that I am holding the paper upside-down.

1920x1080 photo

  
The above features were prevalent in the previous package but now there is a whole bunch more control when it comes to encoding. For instance, if you type any of the below lines you will be able to encode or have binary dumps of your photo in PNG, BMP, RGB, YUV420, or even Raw. In these latter cases, the application reading the files will have to understand the pixel arrangement for itself. Raw images are saved in DNG (Adobe Digital Negative) format and using the very below line will produce a RAW file image and a JPEG file of what the camera can see.

libcamera-still -e png -o test.png

libcamera-still -e bmp -o test.bmp

libcamera-still -e rgb -o test.data

libcamera-still -e yuv420 -o test.data

libcamera-still -r -o test.jpg

See below an image captured using the first Terminal Command. This is a PNG file with the max pixels that the HQ camera can do - captured at 4056 x 3040. Right-click and open it up with a new window to be able to zoom in and see it at full resolution.

PNG-image-first-captured

 

Finally, before we move on to video capture I will demonstrate how to create a timelapse where each image captured has the date-time stamped to it as a filename (in the format MMDDhhmmss). Type and enter the below into your terminal.

libcamera-still -t 60000 --timelaspe 10000 --datetime

Above will take 5 JPEG images over 1 minute at full resolution. The | --timelaspe 10000 | determines the time between each image, as it is set at 10000 it means each 10 second it will take an image. The | --datetime | makes the system label each time-lapse image with a MMDDhhmmss date format. You can see a collage of the time-lapse and what each was named in the image below. 

Timelaspe Photos


Taking Videos

With taking pictures covered it's time to look at video capturing. The same as before the | libcamera | package has a whole bunch of settings available to it. It also allows you to encode these videos in a number of different ways (h264, mjpeg and yuv420 formats) that were lacking in the previous package. Starting off let's take our first 10-second video. Type and enter the following into a new terminal command.

libcamera-vid -t 10000 -o FirstVideo.h264

This will create a ten-second video and save it to | /home/pi | as FirstVideo.h264. You can then and right-click on FirstVideo.h264 and select VLC Media Player to play the file. The Raspberry Pi camera doesn’t have a microphone so there will be no sound. See the image below of this command in the terminal and the result of entering it on the Raspberry Pi Desktop.

First-video-and-terminal-command-to-do-so 

You can even control the captured resolution of your video (along with heaps of other settings). For instance, adding the | --width 640 --height 480 | to the above line will then create a 10-second 640x480 video from what the camera is looking at. Type and enter | libcamera-vid -h | into the terminal to see all of the settings available.


Where To Now

This new package also provides a whole bunch of streaming capabilities like streaming video over VLC. Depending on how good your internet connection results can vary but this is a very exciting addition to the default camera capability of Raspberry Pi single-board computers!

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.