Raspberry Pi HQ Camera

From Waveshare Wiki
(Redirected from 6mm Wide Angle Lens for Pi)
Jump to: navigation, search
Raspberry Pi HQ Camera
RPi Camera V2

Official Raspberry Pi HQ Camera Module
6mm Wide Angle Lens for Pi
16mm Telephoto Lens for Pi




Official Raspberry Pi HQ Camera, 1230M pixels.


  • Sensor
    • IMX477R
    • 12.3 million pixels: 4056(H) x 3040(V)
    • CMOS diagonal length: 7.9mm
    • Single pixel size: 1.55μm(H) x 1.55μm (V)
  • Output format: RAW12/10/8, COMP8
  • Back focus: adjustable (12.5mm-22.4mm)
  • Lens standard
    • C-mount
    • CS-mount (including C/CS connection ring)
  • IR filter: integrated
  • Tripod mount: 1/4"-20
  • Compatible with standard
    • FCC 47 CFR Part 15, Subpart B, Class B Digital Device
    • Electromagnetic Compatibility Directive (EMC) 2014/30/EU
    • Restriction of Hazardous Substances (RoHS) Directive 2011/65/EU

Specification of Lens

Lens 6mm-Wide-Angle-Lens-for-Pi-1.jpg
6mm Wide Angle Lens
16mm Telephoto Lens
25mm Telephoto Lens
35mm Telephoto Lens
8-50mm Zoom Lens
Size 1/2" 1" 2/3" 1" 1/2.3"
F/No F1.2 F1.4-16 F1.4-16 F1.7-16 F1.4
Connector CS-mount C-mount
FoV 63° 1″ 44.6° × 33.6°
2/3″ 30.0° × 23.2°
1/1.8″ 24.7° × 18.6°
1/2″ 21.8° ×16.4°
2/3" 20.2°×15.1°
1/1.8″ 16.5°×12.4°
1/2″ 14.5°×10.5°
1″ 20.9°×15.8°
2/3″ 14.4°×10.8°
1/2″ 10.5°×7.9°
BFL 7.53mm 17.53mm
TTL - 67.53mm -
Distortion - 1″(-0.7%)
0.05% 0.35% -
M.O.D. 0.20m 0.20m 0.25m 0.30m 0.20m
Dimenstion Φ30.00 × 34.00mm Φ39.00 × 50.00mm Φ34.00×34.00mm Φ35.00×34.00mm Φ40.00×68.30mm
Aperature Manual
Weight 53g 133.7g 82g 78g 148g

Hardware Connection

IMX290-83 IR-CUT.png

To test the Raspberry Pi camera, you need to connect an HDMI screen or a DSI screen to the Raspberry Pi
The interfaces of the CSI (camera) and DSI (display) on the Raspberry Pi board are similar, so be careful not to connect them wrongly when wiring. The CSI interface is between the audio interface and the HDMI interface, and the camera interface of the Raspberry Pi Zero series is next to the Power interface. If you are using a computing module, you must refer to the specific layout of the backplane.

IMX290-83 IR-CUT2.png
  • Connect to Raspberry Pi Zero series

Turn the metal side of the cable down, and connect it the camera

  • Other Raspberry Pi motherboards

Direct the metal side of the cable to the HDMI port and connect it to the camera port

About the model

Photosensitive chip model Supported Raspberry Pi motherboard model Supported driver type
OV5647 All Raspberry Pi boards libcamera / Raspicam
OV9281 All Raspberry Pi boards libcamera
IMX219 (Raspberry Pi official) All Raspberry Pi boards libcamera / Raspicam
IMX219 (third party) Raspberry Pi Compute Module libcamera
IMX290/ IMX327 All Raspberry Pi boards libcamera
IMX378 All Raspberry Pi boards libcamera
IMX477 (Raspberry Pi official) All Raspberry Pi boards libcamera / Raspicam
IMX477 (third party) Raspberry Pi Compute Module libcamera

Enable Camera Interface

If you are using the latest bullseye image, the camera interface has been enabled by default, so you can skip the modification steps.

  • Open the Raspberry Pi terminal and use the command to enter the setting interface
sudo raspi-config
  • Set up the camera

Select Interface Options -> Camera -> Yes -> Finish -> Yes

  • Reboot the Raspberry Pi

Test Camera (Bullseyes)

If you use OV9281, IMX290, IMX378, or non-Raspberry Pi official IMX219 and IMX477 cameras, you need to configure the config.txt file separately

sudo nano /boot/config.txt

Find "camera-auto-detect=1" and modify it to "camera_auto_detect=0"

At the end of the file, add the following setting statements according to the camera model

model set statement
OV9281 dtoverlay=ov9281
IMX290/IMX327 dtoverlay=imx290,clock-frequency=37125000
IMX378 dtoverlay=imx378
IMX219 dtoverlay=imx219
IMX477 dtoverlay=imx477
Open the Raspberry Pi terminal and enable the camera preview
sudo libcamera-hello -t 0

If you want to close the preview window, you can directly combine the keys Alt-F4, or click x to close. You can also go back to the terminal interface and terminate the program with ctrl-c.

Test Camera (Buster)

Open the Raspberry Pi terminal and enable the camera preview:

sudo raspistill -t 0

If you want to close the preview window, you can terminate the program with ctrl-c.

User Guides for libcamera/libcamera


After the Bullseye version of the Raspberry Pi image, the underlying Raspberry Pi driver was switched from Raspicam to libcamera. libcamera is an open-source software stack (will be called driver later, which is easy to understand), which is convenient for third-party porting and development of their own camera drivers. As of 2021-12-20, there are still many bugs in libcamra, and the current libcamera does not support python, so the Raspberry Pi official still provides a method for installing and downloading Raspicam. For users who are difficult to switch to libcamera but need to use the latest system, please move directly to the Raspicam instructions.

Call Camera

The libcamera software stack provides six instructions for users to preview and test the camera interface.


This is a simple "hello world" program that previews the camera and displays the camera image on the screen.


This command will preview the camera on the screen for about 5 seconds. The user can use the -t <duration> parameter to set the preview time, where the unit of <duration> is milliseconds. If it is set to 0, it will keep previewing all the time. for example:

libcamerahello -t 0
Tune File

The libcamera driver of the Raspberry Pi will call a tuning file for different camera modules. The tuning file provides various parameters. When calling the camera, libcamera will call the parameters in the tuning file, and process the image in combination with the algorithm. The final output is the preview screen. Since the libcamera driver can only automatically receive the signal of the chip, the final display effect of the camera will also be affected by the entire module. The use of the tuning file is to flexibly handle the cameras of different modules and adjust to improve the image quality.
If the output image of the camera is not ideal when using the default tuning file, the user can adjust the image by calling the custom tuning file. For example, if you are using the official NOIR version of the camera, the NOIR camera may require different white balance parameters than the regular Raspberry Pi Camera V2. In this case, you can switch by calling the tuning file.

libcamera-hello --tuning-file /usr/share/libcamera/ipa/raspberrypi/imx219_noir.json

Users can copy the default tuning files and modify them according to their needs.
Note: The use of tuning files is applicable to other libcamera commands, and will not be introduced in subsequent commands

Preview Window

Most libcamera commands will display a preview window on the screen. Users can customize the title information of the preview window through the --info-text parameter, and can also call some camera parameters through %directives and display them on the window
For example, if you use HQ Camera: You can display the focal length of the camera on the window through --info-txe "%focus"

libcamera-hello --info-text "focus %focus"

Note: For more information on parameter settings, please refer to the following chapters.


libcamera-jpeg is a simple still picture shooting program, different from the complex functions of libcamera-still, libcamera-jpeg code is more concise, and has many of the same functions to complete picture shooting.

Take JPEG image of full pixel
libcamera-jpeg -o test.jpg

This shooting command will display a preview serial port for about 5 seconds, and then shoot a full-pixel JPEG image and save it as test.jpg
Users can set the preview time through the -t parameter, and can set the resolution of the captured image through --width and --height. E.g:

libcamera-jpeg -o test.jpg -t 2000 --width 640 --height 480
Exposure control

All libcamera commands allow the user to set the shutter time and gain themselves, such as:

libcamera-jpeg -o test.jpg -t 2000 --shutter 20000 --gain 1.5

This command will capture an image with 20ms exposure and camera gain set to 1.5x. The gain parameter set will first set the analog gain parameter inside the photosensitive chip. If the set gain exceeds the maximum built-in analog gain value of the driver, the maximum analog gain of the chip will be set first, and then the remaining gain multiples will be used as numbers. gain to take effect.
Remarks: The digital gain is realized by ISP (image signal processing), not directly adjusting the built-in register of the chip. Under normal circumstances, the default digital gain is close to 1.0, unless there are the following three situations.

  1. Overall gain parameter requirements, that is, when the analog gain cannot meet the set gain parameter requirements, digital gain will be needed for compensation
  2. One of the color gains is less than 1 (the color gain is achieved by digital gain), in this case, the final gain is stabilized at 1/min(red_gain, blue_gain), that is, a uniform number is actually applied gain, and is the gain value for one of the color channels (not the green channel).
  3. AEC/AGC was modified. If there is a change in AEC/AGC, the numerical gain will also change to a certain extent, where does it come from to eliminate any fluctuations, but this change will be quickly restored to the "normal" value

The Raspberry Pi's AEC/AGX algorithm allows the program to specify exposure compensation, which is to adjust the brightness of the image by setting the aperture value. for example:

libcamera-jpeg --ev -0.5 -o darker.jpg
libcamera-jpeg --ev 0 -o normal.jpg
libcamera-jpeg --ev 0.5 -o brighter.jpg


libcamera-still and libcamera-jpeg are very similar, the difference is that libcamera inherits more functions of raspistill. As before, the user can take a picture with the following command.

Test Command
libcamera-still -o test.jpg

libcamea-still supports image files in different formats, can support png and bmp encoding, and also supports saving binary dumps of RGB or YUV pixels as files without encoding or in any image format. If you save RGB or YUV data directly, the program must understand the pixel arrangement of the file when reading such files.

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

Note: The format of image saving is controlled by the -e parameter. If the -e parameter is not called, it will be saved in the format of the output file name by default.

Raw image capture

The raw image is the image output by the direct image sensor without any ISP or CPU processing. For color camera sensors, the output format of the raw image is generally Bayer. Note that the raw image is different from the bit-encoded RGB and YUV images we said earlier, and RGB and YUV are also ISP-processed images.
Instructions to take a raw image:

libcamera-still -r -o test.jpg

The original image is generally saved in DNG (Adobe digital Negative) format, which is compatible with most standard programs, such as dcraw or RawTherapee. The original image will be saved as a file with the same name with the .dng suffix, for example, if you run the above command , to be saved as test.dng, and generate a jpeg file at the same time. The DNG file contains metadata related to image acquisition, such as white balance data, ISP color matrix, etc. The following is the metadata encoding information displayed by the exiftool tool:

File Name : test.dng
Directory : .
File Size : 24MB
File Modification Date/Time : 2021:08:17 16:36:18+01:00
File Access Date/Time : 2021:08:17 16:36:18+01:00
File Inode Change Date/Time : 2021:08:17 16:36:18+01:00
File Permissions : rw-r--r--
File Type : DNG
File Type Extension : dng
MIME Type : image/x-adobe-dng
Exif Byte Order : Little-endian (Intel, II)
Make : Raspberry Pi
Camera Model Name : /base/soc/i2c0mux/[email protected]/[email protected]
Orientation : Horizontal (normal)
Software : libcamera-still
Subfile Type : Full-resolution Image
Image Width : 4056
Image Height : 3040
Bits Per Sample : 16
Compression : Uncompressed
Photometric Interpretation : Color Filter Array
Samples Per Pixel : 1
Planar Configuration : Chunky
CFA Repeat Pattern Dim : 2 2
CFA Pattern 2 : 2 1 1 0
Black Level Repeat Dim : 2 2
Black Level: 256 256 256 256
White Level : 4095
DNG Version :
DNG Backward Version :
Unique Camera Model : /base/soc/i2c0mux/[email protected]/[email protected]
Color Matrix 1 : 0.8545269369 -0.2382823821 -0.09044229197 -0.1890484985 1.063961506 0.1062747385 -0.01334283455 0.1440163847 0.2593136724
As Shot Neutral : 0.4754476844 1 0.413686484
Calibration Illuminant 1: D65
Strip Offsets : 0
Strip Byte Counts : 0
Exposure Time : 1/20
ISO : 400
CFA Pattern : [Blue,Green][Green,Red]
Image Size : 4056x3040
Megapixels : 12.3
Shutter Speed ​​: 1/20
long exposure

If we want to take a super long exposure picture, we need to disable AEC/AGC and white balance, otherwise these algorithms will cause the picture to wait for a lot of frame data when it converges. Disabling these algorithms requires another explicit value to be set. Additionally, the user can skip the preview process with the --immediate setting.
Here is the instruction to take an image with an exposure of 100 seconds:

libcamera-still -o long_exposure.jpg --shutter 100000000 --gain 1 --awbgains 1,1 --immediate

Remarks: Reference table for the longest exposure time of several official cameras.

Module Maximum exposure time (s)
V1(OV5647) 6
V2(IMX219) 10
HQ(IMX477) 230


libcamera-vid is a video recording program that uses the Raspberry Pi hardware H.264 encoder by default. After the program runs, a preview window will be displayed on the screen, and the bitstream encoding will be output to the specified file. For example, record a 10s video.

libcamera-vid -t 10000 -o test.h264

If you want to view the video, you can use vlc to play it

vlc test.h264

Note: The recorded video stream is unpackaged. Users can use --save-pts to set the output timestamp to facilitate subsequent conversion of the bit stream to other video formats.

libcamera-vid -o test.h264 --save-pts timestamps.txt

If you want to output the mkv file, you can use the following command:

mkvmerge -o test.mkv --timecodes 0:timestamps.txt test.h264

Raspberry Pi supports JPEG format and YUV420 without compression and format:

libcamera-vid -t 10000 --codec mjpeg -o test.mjpeg
libcamera-vid -t 10000 --codec yuv420 -o test.data

The --codec option sets the output format, not the output file extension.
Use the --segment parameter to split the output file into segments (unit is ms), which is suitable for JPEG files that need to split the JPEG video stream into separate short (about 1ms) JPEG files

libcamera-vid -t 10000 --codec mjpeg --segment 1 -o test%05d.jpeg


libcamera-raw is similar to a video recording program. In different places, libcamera-raw records the Bayer format data output by the direct sensor, that is, the original image data. libcamera-raw doesn't show a preview window. For example, record a 2-second clip of raw data.

libcamera-raw -t 2000 -o test.raw

The program will directly dump the original frame without format information, the program will directly print the pixel format and image size on the terminal, and the user can view the pixel data according to the output data.
By default, the program will save the original frame as a file, the file is usually large, and the user can divide the file by the --segement parameter.

libcamera-raw -t 2000 --segment 1 -o test%05d.raw

If the memory is large (such as using SSD), libcamera-raw can write the official HQ Camera data (about 18MB per frame) to the hard disk at a speed of about 10 frames per second. In order to achieve this speed, the program writes the unformatted raw frames, there is no way to save them as DNG files like libcamera-still does. If you want to ensure that there are no dropped frames, you can use --framerate to reduce the frame rate.

libcamera-raw -t 5000 --width 4056 --height 3040 -o test.raw --framerate 8

Common Command setting options

Common command setting options apply to all libcamera commands

--help, -h

Print program help information, you can print the available setting options for each program command, and then exit.


print software version, print the software version of libcamera and libcamera-app, then exit.

--timeout, -t

The -t option sets the running time of the libcamera program. If the video recording command is run, the timeout option sets the recording duration. If the image capture command is run, the timeout sets the preview time before the image is captured and output.
If the timeout is not set when running the libcamera program, the default timeout value is 5000 (5 seconds). If the timeout is set to 0, the program will continue to run.
Example: libcamera-hello -t 0

--preview, -p

-p Set the size and position of the preview window (the qualified settings are valid in both X and DRM version windows), and the format is --preview <x. y, w, h> where "x, y" sets the preview window coordinate, w and h set the width and length of the preview window
The settings of the preview serial port will not affect the resolution and aspect ratio of the camera image preview. The program will scale the preview image to display in the preview window and adapt it according to the original image aspect ratio.
Example: libcamera-hello -p 100,100,500,500

--fullscreen, -f

The -f option sets the preview window full screen, the preview window and border in full screen mode. Like -p, it does not affect the resolution and aspect ratio, and will automatically adapt.
Example: libcamera-still -f -o test.jpg


Using the preview window based on the QT framework, this setting is not recommended under normal circumstances, because the preview program will not use zero-copy buffer sharing and GPU acceleration, which will lead to high resource consumption. The QT preview window supports X forwarding (the default preview program does not).
The Qt preview serial port does not support the --fullscreen setting option. If the user wants to use the Qt preview, it is recommended to keep a small preview window to avoid excessive resource usage and affect the normal operation of the system.
Example: libcamera-hello --qt-preview

--nopreview, -n

Images are not previewed. This setting will turn off the image preview function.
Example: libcamera-hello -n


Set the title and information display of the preview window (only available in the X graphics window) using the format --info-text <string>. When calling this option, there are multiple parameters that can be set, and the parameters are usually called in the % command format. The program will call the corresponding value in the graphics metadata according to the instruction.
If no window info is specified, the default --info-text is set to "#%frame (%fps fps) exp %exp ag %ag dg %dg"
Example: libcamera-hello --info-test "Focus measure: %focus Available parameters:

Instructions Instructions
%frame frame sequence number
%fps Instantaneous frame rate
%exp The shutter speed when capturing the image, in ms
%ag Image analog gain controlled by the sensor chip
%dg Image value gain controlled by ISP
%rg Gain of the red component of each pixel
%bg The gain of the blue component of each pixel
%focus The corner measurement of the image, the larger the value, the clearer the image

These two parameters set the width and height of the image, respectively. For libcamera-still, libcamera-jpeg and libcamera-vid commands, these two parameters can set the resolution of the output image/video.
If the libcamera-raw command is used, these two parameters affect the size of the obtained metadata frame. The camera has a 2x2 block reading mode. If the set resolution is smaller than the split mode, the camera will obtain the metadata frame according to the 2x2 block size.
libcamera-hello cannot specify resolution.< br /> Example:
libcamera-vid -o test.h264 --width 1920 --height 1080 Record 1080p video
libcamera-still -r -o test.jpg --width 2028 --height 1520 Takes a 2028x1520 JPEG image.


This setting option is also used to set the resolution of the image, the difference is only the image size of the preview. It does not affect the final output image or video resolution. The size of the preview image will not affect the size of the preview window and will be adapted according to the window.
Example: libcamera-hello --viewfinder-width 640 --viewfinder-height 480


This setting forces the sensor to use the --width and --height settings to output still images and video in full resolution read mode. This setting libcamera-hello has no effect.
With this setting, framerate is sacrificed. In full resolution mode, frame reading will be slower.
Example: libcamera-raw -t 2000 --segment 1 --rawfull -o test%03d.raw The example command captures multiple full resolution images Metadata frame in rate mode. If you are using HQ camera. The size of each frame is 18MB, and if --rawfull is not set, the HQ camera defaults to 2x2 mode, and the data size of each frame is only 4.5MB.


These two options set low resolution images. The low-resolution data stream compresses the image, causing the aspect ratio of the image to change. When using libcamera-vid to record video, if a low resolution is set, functions such as color denoising will be disabled.
Example: libcamera-hello --lores-width 224 --lores-height 224 Note that low resolution settings are often used in conjunction with image postprocessing , otherwise it has little effect.

--hflip #Flip the image horizontally
--vflip #Flip the image vertically
--rotation #Flip the image horizontally or vertically according to the given angle <angle>

These three options are used to flip the image. The parameters of --rotation currently only support 0 and 180, which are actually equivalent to --hflip and --vflip.
Example: libcamera-hello --vflip --hflip

--roi #crop image <x, y, w, h>

--roi allows the user to crop the image area they want according to the coordinates from the complete image provided by the sensor, that is, digital scaling, pay attention to the coordinate value if it is in the valid range. For example --roi 0, 0, 1, 1 is an invalid instruction.
Example: libcamera-hello --roi 0.25,0.25,0.5,0.5 The example command will crop 1/4 of the image from the center of the image.

--sharpness #Set the sharpness of the image <number>

Adjust the sharpness of the image by the value of <number>. If set to 0, no sharpening is applied. If you set a value above 1.0, an extra sharpening amount will be used.
Example: libcamera-still -o test.jpg --sharpness 2.0

--contrast #Set image contrast <number>

Example: libcamera-still -o test.jpg --contrast 1.5

--brightness #Set image brightness <number>

The setting range is -1.0 ~ 1.0
Example: libcamera-still -o test.jpg --brightness 0.2

--saturation #Set image color saturation <number>

Example: libcamera-still -o test.jpg --saturation 0.8

--ev #Set EV compensation <number>

Set the EV compensation of the image in aperture units, the setting range is -10 ~ 10, the default value is 0. The program works by improving the target method of the AEC/AGC algorithm.
Example: libcamera-still -o test.jpg --ev 0.3

--shutter #Set the exposure time, the unit is ms <number>

Note: If the frame rate of the camera is too fast, it may not work according to the set shutter time. If this happens, you can try to use --framerate to reduce the frame rate.
Example: libcamera-hello --shutter 30000

--gain #Set gain value (combination of numerical gain and analog gain) <number>
--analoggain #--gain synonym

--analoggain is the same as --gain, the use of analoggain is only for compatibility with raspicam programs.

--metering #Set metering mode <string>

Set the metering mode of the AEC/AGC algorithm, the available parameters are:

  • centre - Center metering (default)
  • spot - spot metering
  • averag - average or full frame metering
  • custom - custom metering mode, can be set via tuning file

Example: libcamera-still -o test.jpg --metering spot

--exposure #set exposure profile <string>

The exposure mode can be set to normal or sport. The report profile for these two modes does not affect the overall exposure of the image, but in the case of sport mode, the program will shorten the exposure time and increase the justice to achieve the same exposure effect.
Example: libcamera-still -o test.jpg --exposure sport

--awb #Set white balance mode <string>

Available white balance modes:

Mode Color temperature
auto 2500K ~ 8000K
incadescent 2500K ~ 3000K
tungsten 3000K ~3500K
fluorescent 4000K ~ 4700K
indoor 3000K ~ 5000K
daylight 5500K ~ 6500K
cloudy 7000K ~ 8500K
custom Custom range, set via tuning file

Example: libamera-still -o test.jpg --awb tungsten

--awbgains #Set a fixed color gain <number,number>

Set red and blue gain.
Example: libcamera-still -o test.jpg --awbgains 1.5, 2.0

--denoise #Set denoising mode <string>

Supported denoising modes:

  • auto - default mode, use standard spatial denoising, if it is video, it will use fast color noise reduction, and use high quality color noise reduction when taking still pictures. Preview image will not use any color denoising
  • off - turn off spatial denoising and color denoising
  • cdn_off - turn off color denoising
  • cdn_fast - use fast color denoising
  • cdn_hq - use high quality color denoising, not suitable for video recording.

Example: libcamera-vid -o test.h264 --denoise cdn_off

--tuning-file #Specify camera tuning file <string>

For more instructions on tuning files, you can refer to official tutorial
Example: libcamera-hello --tuning-file ~/my~camera-tuning.json

--output, -o #output filename <string>

Set the filename of the output image or video. In addition to setting the file name, you can also specify the output udp or tcp server address to output the image to the server. If you are interested, you can check the relevant setting instructions of the subsequent tcp and udp.
Example: libcamera-vid -t 100000 -o test.h264

--wrap #Wrap the output file counter <number>

Example: libcamera-vid -t 0 --codec mjpeg --segment 1 --wrap 100 -o image%d.jpg

--flush # Flush the output file immediately

--flush will immediately update each frame of image to the hard disk at the same time as it is written, reducing latency.
Example: libcamera-vid -t 10000 --flush -o test.h264

Still photo shooting setting parameters

--qiality, -q #Set JPEG image quality <0 ~ 100>
--exif, -x #Add extra EXIF flags
--timelapse #Time interval of time-lapse photography, the unit is ms
--framestart #start value of frame count
--datetime #name output file with date format
--timestamp #name the output file with the system timestamp
-- restart #Set the JPEG restart interval
--keypress, -k # Set the enter button photo mode
--signal, -s #Set the signal to trigger the photo
--thumb #Set thumbnail parameters <w:h:q>
--ebcoding, -e #Set the image encoding type. jpg/png/bmp/rgb/yuv420
--raw, -r #Save raw image
--latest #Associate symbols to the latest saved file

Video recording image setting parameters

--quality, -q # Set JPEG commands <0 - 100>
--bitrate, -b # Set H.264 bitrate
--intra, -g #Set the internal frame period (only supports H.264)
--profile #Set H.264 configuration
--level #Set H.264 level
--codec #Set encoding type h264 / mjpeg / yuv420
--keypress, -k #Set carriage return to pause and record
--signal, -s #Set signal pause and record
--initial #Start the program in the recording or paused state
--split #Split video and save to another file
--segment #Split video into multiple video segments
--circular #Write video to circular buffer
--inline #Write header in each I frame (H.264 only)
--listen #Wait for a TCP connection

User Guides for Raspicam


If you are using the Buster version of the image, the Raspicam driver is installed by default in the system, you can directly turn on the camera and use it.
If you are using the latest Bullseye system, you need to install and configure it separately

Install Raspicam (optional)

Open the Raspberry Pi terminal, and enter the following command to install the driver. Note: This driver cannot support 64-bit Raspberry Pi system temporarily.

sudo apt-get update
sudo apt install cmake
git clone https://github.com/raspberrypi/userland
cd userland
cp build/bin/* ~/bin/

After following the need to restart the system

sudo reboot

Call camera


The raspistill command is used to take still pictures. Example: raspistill -o cam.jpg


The raspivid command is used to record video. Example: raspivid -o vid.h264


The raspiyuv command has the same function as raspisitll, the difference is that raspiyuv is not Su Chu. jpgs and other standard image files, but generate YUV420 or RGB888 image files from the camera's ISP output.
In most cases, it is better to use raspistill to capture images, but if you want to use uncompressed black and white images, you can choose to use the raspiyuv command. Example: raspiyuv -o cam.jpg

Instruction setting options

When the raspicam command is used, the final imaging effect of the image can be adjusted by setting options. The available setting options are listed below for reference.

--preview, -p #Set the preview window <x, y, w, h>

The user can set the position of the preview window by setting the values ​​of x and y, and adjust the resolution of the preview image by setting the values ​​of w and h.

--fullscreen, -f #Fullscreen preview window

Display the preview window in full screen

--nopreview, -n #Do not display the preview window

Close the preview window and the command will output the image or video directly to a file.

--opacity, -op #Set the transparency of the preview window

Set the transparency of the preview window, 0 is invisible, 255 is fully transparent

--sharpness, -sh #Set image sharpness (-100 - 100)

The default sharpening value is 0

--contrast. -co #Set image contrast (-100 - 100)

The default contrast is 0

--brightness, -br #Set image contrast (0 - 100)

The default brightness is 50, 0 is full black, and 100 is full white.

--saturation, -sa #set image saturation (-100 - 100)

Default saturation is 0

--ISO #set shutter sensitivity (100 - 800)

Set the sensitivity when taking pictures

--vstab, -vs #Enable video stabilization

Only the video recording mode is valid, and video stabilization is enabled.

--ev #set EV compensation

Set the EV compensation value of the image, default 0

--exposure, -ex #Set exposure mode

Settable exposure options:

  • auto: automatic exposure mode
  • night: night shooting mode
  • nightpreview
  • backlight: backlight mode
  • spotlight
  • sports: sports mode (the shutter time will be shortened in sports mode
  • snow: Snow mode
  • beach: beach mode
  • verylong: long exposure mode
  • fixedfps: fixed fps
  • antishake: anti-shake mode
  • fireworks: fireworks mode

Note: Depending on the camera model, some modes are not available

--flicker, -fli #flicker avoidance

Modes that can be set:

  • off: turn off anti-flicker mode
  • auto: auto-detect betting frequency
  • 50Hz: Set the anti-flicker frequency to 50Hz
  • 60Hz: Set the anti-flicker frequency to 60Hz
--awb, #Set auto white balance mode
  • off: disable auto white balance
  • auto: Auto white balance mode (default)
  • sun: sunny mode (5000K ~ 6500K)
  • cloud: cloudy mode (6500K ~ 12000K)
  • shade: shadow mode
  • tungsten: Tungsten mode (2500K ~ 3500K)
  • incandescent: Incandescent mode (2500K ~ 4500K)
  • flash: flash mode
  • horizon: horizon mode
  • greyworld: If you are using a camera without an IR filter (eg NoIR), you can fix the white balance misalignment caused by the lack of an IR filter

Note: Depending on the camera model, some modes are not available

--imfx, -ifx #Set image filter effect

Configurable image filter effects:

  • none: no effect (default)
  • negative: color flip
  • solarise: sunlight effect
  • posterise: poster effect
  • whiteboard: whiteboard effect
  • backboard: blackboard effect
  • sketch: sketch
  • denoise: denoise
  • emboss: Emboss
  • oilpaint: oil painting
  • hatch: texture
  • gpen: pencil sketch
  • pastel: colored pencils
  • watercolour: watercolor
  • film: film
  • blur: blur
  • saturation: saturation

Note: Depending on the camera model, some modes are not available

--colfx, -cfx #Set color effect <U:V>

The setting range of the U and V parameters is 0 ~ 255, which are used to adjust the values ​​of the U and Y channels. For example: --colfx 128:128 will set the image to monochrome.

--metering, -mm #Set metering mode

Settable options:

  • average: average or full frame metering
  • spot: spot metering
  • backlit: preset a backlit image
  • matrix: matrix metering
--rotation, -rot #set image rotation (0 - 359)

The image rotation angle can be set by the angle parameter

--hflip, -hf #Set the image to flip horizontally

Set the image to be flipped horizontally

--vflip, -vf #Set the image to flip vertically

Flip the image vertically

--roi, #crop image <x, y, w, h>

Crop the image according to the parameters, note that the parameters are all planned in (0,0 ~ 1.0), for example, if you want to crop 1/4 of the image, you can use the command - roi 0.5,0.5,0.25,0.25

--shutter, --ss set shutter speed/time

Set the shutter time (unit: ms). Shutter time The maximum shutter time that can be set is different depending on the photosensitive chip.

Model Max Digit (ms)
V1 (OV5647) 6000000 (6s)
V2 (IMX219) 10000000 (10s)
HQ (IMX477 200000000 (200s)
--drc, -drc #Enable/disable dynamic range compression
  • off (default)
  • low
  • med
  • high
--stats, -st #Statistics images by static image frames
--awbgains, -awbg

Set blue and green gain, takes effect if --awb off is set

--analoggain, -ag

Set the analog gain value

--digitalgain, -dg

Set digital gain value

--mode, -md

Set sensor mode:

  • OV5647
Mode Resolution Aspect Ratio Frame Rate FoV
0 Automatic selection
1 1920 x 1080 16:9 1-30fps Partial
2 2592 x 1944 4:3 1-15fps Full Frame
3 2592 x 1944 4:3 0.1666 - 1fps Full Frame
4 1296 x 972 4:3 1 - 42fps Full Frame
5 1296 x 730 16:9 1- 49fps Full Frame
6 640 x 480 4:3 42.1 - 60fps Full Frame
7 640 x 480 4:3 60.1 - 90fps Full Frame
  • IMX219
Mode Resolution Aspect Ratio Frame Rate FoV
0 Automatic selection
1 1920 x 1080 16:9 0.1-30fps Partial
2 3280 x 2464 4:3 0.1-15fps Full Frame
3 3280 x 2464 4:3 0.1 - 15fps Full Frame
4 1640 x 972 4:3 1 - 42fps Full Frame
5 1296 x 730 16:9 1- 49fps Full Frame
6 640 x 480 4:3 42.1 - 60fps Full Frame
7 640 x 480 4:3 60.1 - 90fps Full Frame
  • HQ Camera
Mode Resolution Aspect Ratio Frame Rate FoV
0 Automatic selection
1 2028 x 1080 169:90 0.1-50fps Partial
2 2028 x 1080 4:3 0.1-50fps Full Frame
3 4056x3040 4:3 0.005 - 10fps Full Frame
4 1332x990 74:55 50.1-120 fps Partial
--camselect, -cs

When multiple cameras are connected to the system, select the camera, 0 or 1.

--annotate, -a #enable/set annotations

The parameters are represented by bit masks in the metadata, which can be directly represented by addition. For example, 12 can represent the display time (4) and the display date (8), which is represented by the addition of 4+8 =12.
Configurable options

value parameter description
-a 4 time
-a 8 date
-a 12 Time and date, actually 4 + 8
-a 16 Shutter setting
-a 32 CAF settings
-a 64 gain setting
-a 128 Lens settings
-a 256 animation settings
-a 512 number of frames
-a 1024 black background
-a "ABC %Y-%m-%d %X" display text
-a 4 -a "ABC %Y-%m-%d %X" Display time/date in custom format
-a 8 -a "ABC %Y-%m-%d %X" Display time/date in custom format
--annotateex, -ae #Set additional annotation parameters
--stereo, -3d

Set the binocular mode.

  • sbs - side by side mode
  • tb: - Portrait mode
  • off - turn off binocular mode (default)
--decimate, -dec

Halve the width and height of the binocular image

--setting, -set

Output current camera settings

raspistill setting parameters

--width, -w #Set image width
--height, -h #Set image height
--quality, 0q #Set JPEG quality <0 ~ 100>
--raw, -r #Add raw Bayer data to JPEG metadata
--output, -o #output file <filename>
--latest, -l #Associate the last frame image to the file <filename>
--verbose, -v #print details
--timeout, -t #Set the program preview time
--timelapse, -tl #Set up demo photography
--framestart, -fs #Save the number of the first frame
--datetime, -dt #name the file with datetime
--timestamp, -ts #name files with timestamps
--thumb, -th #Set thumbnail parameters <x:y:quility>, the default is (64:48:35)
--demo, -d #Run demo mode <ms"
--encoding, -e #encode according to the specified format, jpg, bmp or png
--restart, -rs #Set JPEG restart flag
--exif, -x #Set EXIF ​​flag
--gpsdexif, -gps #Set real-time exif time (requires GPS Dongle access)
--fullpreview, -fg #Fullscreen preview
--keypress, -k #Keypress camera mode
--signal, -s # signal mode
--burst, -bm #Snapshot mode

raspivid setting parameters

--width, -w #Set the video width
--height, -h #Set the video height
--bitrate, -b #set bitrate
--output, -o #Set the output filename <filename>
--listen, -l #When using a network connection, wait for a network connection
--versbose, -v #print details
--timeout, -t #Set preview time
--demo, -d #run demo <ms>
--framerate, -fs #set frame rate
--penc, -e #Display the encoded preview image
--intra, -g #Set the internal refresh cycle
--qp, -qp #Set quantization parameters
--profile, -pf #Specify H264 profile, baseline / main / high
--level, -lev #Set H264 encoding level
--irefresh, -if #Set H264 internal refresh type cyclic / adaptive / both / cyclicrows
--inline, -ih #Insert PPS, SPS header
--spstimings, -stm #Insert timing information into SPS blocks
--timed, -td #Timed switch recording and pause function
--keypress, -k #Keypress to pause recording
--signal, -s #Switch pause and record state according to SIGUSR1
--split, -sp #In signal and keypress mode, the file will be recreated every time you re-record
--vectors, -x # vector output
--flush, -fl #Force the output data buffer to be flushed immediately after writing video data, bypassing any OS cache for written data and reducing latency.
--save-pts, -pts #Save timestamp information to the specified file.
--codec, -cd # Specify encoder H264 / MJPEG
--initial, -i #Set the initial state of startup
--segment, -sg #Split video stream into multiple files
--wrap, -wr #Set the maximum value of the split
--start, -sn #Set the initial split encoding
--raw, -r #Set metadata file name
--raw-format, -rf #Specify metadata format yuv / rgb / grey



If you require technical support, please go to the Support page and open a tickets.


*In different environments, the white balance effect may not be normal. Users can adjust the white balance parameters according to the actual usage.
  • The following OpenCV adjustment code is for reference only. (The code is shared by RPi Camera (G) users)
import picamera
import picamera.array
import cv2
from time import sleep
import numpy as np

def test_gcamera():
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.awb_mode = 'off'
        rg, bg = (1.8, 1.4)
        camera.awb_gains = (rg, bg)
        with picamera.array.PiRGBArray(camera) as output:
            for foo in camera.capture_continuous(output, 'rgb', use_video_port=True):
                img = cv2.cvtColor(output.array, cv2.COLOR_RGB2BGR)
                cv2.imshow("img", img)
                r, g, b = (np.mean(output.array[..., i]) for i in range(3))
                if abs(r - g) > 2:
                    if r > g:
                        rg -= 0.1
                        rg += 0.1
                if abs(b - g) > 1:
                    if b > g:
                        bg -= 0.1
                        bg += 0.1
                camera.awb_gains = (rg, bg)
if __name__=="__main__":