After the Bullseye version of the Raspberry Pi image, the underlying Raspberry Pi driver is switched from Raspicam to libcamera. Libcamera is an open source software stack (hereinafter referred to as the driver for ease of understanding) that facilitates third-party porting and development of their own camera drivers. As of 20231211, the official has provided the pycamera2 library for libcamera, which is convenient for users to call using Python programs
https://www.raspberrypi.com Detailed instructions for using the official libcamera program of Raspberry Pi

The buster system version of Raspberry Pi (that is, the old version) uses the Raspicam camera library, which currently only supports three camera models, OV5647, IMX219 (with encryption chip), and IMX477 (with encryption chip). The IMX219 and IMX477 cameras without encryption chips on the market are not supported

The bookworm system version of Raspberry Pi (new version system) uses the libcamera camera library, which can expand various camera models. The currently supported models are as follows:
After opening sudo nano /boot/config.txt or sudo nano /boot/firmware/config.txt, find the camera_auto_detect=1 and change the number 1 behind it to 0. camera_auto_detect=0
Add the following content at the end
#dtoverlay=ov5647
#dtoverlay=imx219
#dtoverlay=imx219,cam0
#dtoverlay=imx477
#dtoverlay=imx290,clock-frequency=37125000
#dtoverlay=imx378
#dtoverlay=ov9281
#dtoverlay=imx296
#dtoverlay=imx519
#dtoverlay=imx708
#dtoverlay=imx708,vcm=0 Here is the setting to turn off the auto focus function
Remove the # sign in front of the camera model you use, save, and restart
For Raspberry Pi 5, or Raspberry Pi CM3 and CM4, these models support 2 cameras, and the setting method is as follows:
sudo nano /boot/config.txt or sudo nano /boot/firmware/config.txt , add the following content at the end
dtoverlay=imx219
dtoverlay=imx219,cam0
The default interface corresponding to the above dtoverlay=imx219 is CSI/DSI1
dtoverlay=imx219,cam0 The interface corresponding to this setting is CSI/DSI0

If IMX290 is used on Raspberry Pi 5, you also need to add the json file to the command directory before you can use it. The operation is as follows:
sudo wget https://www.waveshare.net/w/upload/7/7a/Imx290.zip
sudo unzip Imx290.zip
sudo cp imx290.json /usr/share/libcamera/ipa/rpi/pisp
sudo nano /boot/firmware/config.txt
dtoverlay=imx290,clock-frequency=37125000,cam0

After saving and restarting, you can use the command libcamera-hello –list-cameras to check whether the corresponding camera is recognized
The following are the instructions for operating the camera:
libcamera-jpeg -h #You can view detailed usage

sudo libcamera-hello -t 0 –camera 0
sudo libcamera-hello -t 0 –camera 1
libcamera-jpeg –camera 1 -t 2000 -o test.jpg
libcamera-jpeg –camera 0 -t 2000 -o test.jpg
libcamera-hello
libcamera-hello -t 0
libcamera-jpeg -o test.jpg
libcamera-jpeg -o test.jpg -t 2000 –width 640 –height 480
libcamera-still -o test.jpg
libcamera-vid -t 10000 -o test.h264
rpicam-vid -t 20000 –width 2028 –height 1080 –codec libav -o 1.MP4
rpicam-vid -t 20000 –width 2028 –height 1080 –framerate 50 –codec libav -o 1.MP4
You may not be able to view the real-time image of the camera by operating the above command through SSH. It is best to connect a monitor, mouse and keyboard to the Raspberry Pi, and then use the above command to see the real-time image
You can use libcamera -h See libcamera for details
When testing the IMX296 full-color camera, if the color cannot be displayed normally, you can try to use sudo apt-get full-upgrade to update the system, restart and test again, which usually solves the problem.

Camera shooting instructions for the Raspberry Pi buster system version:
You can refer to: Raspberry Pi camera module application document translation
raspistill -o 1.jpg -t 2000
raspistill -cs 0 -o 1.jpg -t 2000
raspistill -cs 1 -o 2.jpg -t 2000
sudo raspivid -t 0 -cs 0
sudo raspivid -t 0 -cs 1
raspistill -3d sbs -w 1280 -h 480 -o 1.jpg

raspivid -t 0 -f -w 640 -h 480 Force full screen display
raspivid -t 0 -w 1920 -h 1080 -fps 30 -sa 100

raspivid -o 1.h264 Default 5 seconds

raspivid -o 1.h264 -t 10000 time in milliseconds

raspivid -o 1.h264 -t 10000 -w 1280 -h 720 resolution settings

raspivid -o 1.h264 -t 10000 -w 1280 -h 720 -fps 24 video frame rate settings

# Take a picture after a two-second (time in milliseconds) delay and save it as image.jpg
raspistill -t 2000 -o image.jpg

# Take a picture of a custom size.
raspistill -t 2000 -o image.jpg -w 640 -h 480

# Reduce image quality and file size
raspistill -t 2000 -o image.jpg -q 5

# Force the preview window to appear at coordinates 100,100 and be 300 pixels wide and 200 pixels high.
raspistill -t 2000 -o image.jpg -p 100,100,300,200

# Disable the preview window
raspistill -t 2000 -o image.jpg -n

# Save the image as a PNG file (lossless compression, but slower than JPEG). Note that the file extension is ignored when selecting an image encoding.
raspistill -t 2000 -o image.png –e png

# Add some EXIF ​​information to the JPEG file. This command will set the author name tag to Dreamcolor and the GPS altitude to 123.5 meters.
raspistill -t 2000 -o image.jpg -x IFD0.Artist=Dreamcolor -x GPS.GPSAltitude=1235/10

# Set emboss style image effects
raspistill -t 2000 -o image.jpg -ifx emboss

# Set the U and V channels of the YUV image to the specified values ​​(128:128 for black and white images)
raspistill -t 2000 -o image.jpg -cfx 128:128

# Display the preview image for only two seconds without saving the image.
raspistill -t 2000

# Get pictures at intervals, get one every 10 seconds in 10 minutes (10 minutes = 600000 milliseconds), and name them in the form of image_number_001_today.jpg, image_number_002_today.jpg…, and the last picture will be named latest.jpg.
raspistill -t 600000 -tl 10000 -o image_num_%03d_today.jpg -l latest.jpg

# Get a picture and send it to standard output
raspistill -t 2000 -o -

# Get a picture and save it to a file
raspistill -t 2000 -o - > my_file.jpg

# The camera keeps working and gets a picture when the enter key is pressed.
raspistill -t 0 -k -o my_pics%02d.jpg

Video Capture
Image size and preview settings are the same as for image capture. The default size of the recorded video is 1080p (1920×1080)

# Record a 5-second video clip (1080p30) with default settings
raspivid -t 5000 -o video.h264

# Record a 5-second video clip with a specified bitrate (3.5Mbits/s)
raspivid -t 5000 -o video.h264 -b 3500000

# Record a 5-second video clip with a specified frame rate (5fps)
raspivid -t 5000 -o video.h264 -f 5

# Send a 5-second encoded camera stream image to the standard output device
raspivid -t 5000 -o -

# Save a 5-second encoded camera stream image to a file
raspivid -t 5000 -o - > my_file.h264

请输入您的评论. 可以使用维基语法:
 
  • developmentboard/raspberry_pi_camera_driver.txt
  • 最后更改: 2025/01/09 06:26
  • admin