Template: RPi Camera Raspicam Guide

From Waveshare Wiki
Jump to: navigation, search

Introduction

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

Install Raspicam (Optional)

If you use the Bullseye image (the newest image), you need to install the Raspicam for using the legacy stack.
Note: This driver does not support the 64-bit Raspberry Pi system for now.

Open a terminal and run the following commands.

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

Call the Camera

raspistill

raspistill is for taking still pictures. For example: raspistill -o cam.jpg

raspivid

raspivid is for recording video. For example: raspivid -o vid.h264

raspiyuv

The commands of raspiyuv and raspisitll have the same function. The difference is that instead of outputting standard image files such as jpgs, raspiyuv generates YUV420 or RGB888 image files from the camera's ISP output.
For the most part, it is better to shoot images and use raspistill, but if you want to use uncompressed black-and-white images, you can choose to use the raspiyuv command.
For example: raspiyuv -o cam.jpg

Command Setting Options

The raspicam command can be used with setting options to adjust the final image effect. The following is a list of the available setup options for reference.

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

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

--fullscreen, -f  #Full screen preview window

Display the preview window in full screen.

--nopreview, -n  #No preview window displayed

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

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

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

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

The default sharpening value is 0.

--contrast. -co  #Setting Image Contrast(-100 - 100)

The default contrast is 0.

--brightness, -br  #Set Image Contrast(0 - 100)

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

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

The default saturation is 0.

--ISO  #Setting Shutter Sensitivity (100 - 800)

Setting the sensitivity when taking pictures.

--vstab, -vs  #Enable video stabilization

Only the video recording mode is valid, with video stabilization turned on.

--ev  #Set EV compensation

Set the EV compensation value of the image, and the default is 0.

--exposure,  -ex  #Setting the exposure mode

Exposure options:

  • auto: Auto Exposure Mode
  • night: Night shooting mode
  • nightpreview
  • backlight: Backlight mode
  • spotlight
  • sports: Sports mode (the shutter time is 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

Configurable mode:

  • off: Turn off anti-flicker mode
  • auto: Automatic detection of injection frequency
  • 50Hz: Set the anti-flicker frequency to 50 Hz
  • 60Hz: Set the anti-flicker frequency to 60Hz
--awb,  #Set auto white balance mode
  • off: Turn off auto white balance
  • auto: Auto white balance mode (default)
  • sun: Sunny mode (5000K ~ 6500K)
  • cloud: Cloudy mode (6500K ~ 12000K)
  • shade: Shade mode
  • tungsten: Tungsten lamp 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 (e.g. NoIR), you can fix the white balance imbalance caused by the lack of an IR filter.

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

--imfx, -ifx  #Set the image filter effect

Configurable filter effect:

  • none: No effect (default)
  • negative: Color Flip
  • solarise: Sunlight effect
  • posterise: Poster effect
  • whiteboard: Whiteboard effect
  • backboard: Blackboard effect
  • sketch: Sketch effect
  • denoise: Denoise effect
  • emboss: amboss effect
  • oilpaint: Oil paint effect
  • hatch: Hatch effect
  • gpen: Pencil sketch effect
  • pastel: Colored pencils effect
  • watercolour: Watercolor effect
  • film: Film effect
  • blur: Blur effect
  • saturation: Saturation effect

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

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

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

--metering, -mm  #Setting the metering mode

Configurable mode:

  • 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 image horizontal flip

Set image horizontal flip.

--vflip, -vf  #Set image vertical flip

Set image vertical flip.

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

Crop the image according to the parameters, note that the parameters are 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). The maximum shutter time that can be set varies depending on the light-sensitive chip.

Mode Maximum number(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  #Counting images by still image frames
--awbgains, -awbg

Set blue and green gain, effective when --awb off is set.

--analoggain, -ag

Set the analog gain value.

--digitalgain, -dg

Set the digital gain value.

--mode, -md

Set the sensor mode:

  • OV5647
Mode Resolution Aspect Ratio Frame Rate FoV
0 Auto-select
1 1920 x 1080 16:9 1-30fps Local
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 Auto-select
1 1920 x 1080 16:9 0.1-30fps Local
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 Auto-select
1 2028 x 1080 169:90 0.1-50fps Local
2 2028 x 1080 4:3 0. 1-50fps Full Frame
3 4056 x 3040 4:3 0.005 - 10fps Full Frame
4 1332 x 990 74:55 50.1-120 fps Local
--camselect, -cs

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

--annotate, -a #Enable/Set Comments

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

Value Parameters
-a 4 Time
-a 8 Date
-a 12 Time and date, actually 4 + 8
-a 16 Shutter setting
-a 32 CAF setting
-a 64 Gain setting
-a 128 Lens settings
-a 256 Animation Settings
-a 512 Frame Rate
-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: -Vertical mode
  • off -Turn off binocular mode (default)
--decimate, -dec

Halving the width and height of binocular images.

--setting, -set

Output the current camera settings.

raspistill Parameters

--width, -w  #Set image width
--height, -h  #Set image height
--quality, 0q  #Set JPEG quality <0 ~ 100>
--raw, -r  #Add the original Bayer data to the JPEG metadata
--output, -o #output file <filename>
--latest, -l  #Associating the last image frame to the file <filename>
--verbose, -v #Print Details
--timeout, -t  #Set program preview time
--timelapse, -tl  #Set up demo photography
--framestart, -fs #Save the number of the first frame
--datetime, -dt  #Naming files with date and time
--timestamp, -ts #Naming files with timestamps
--thumb, -th #Set thumbnail parameter <x:y:qulity>, default is (64:48:35)
--demo, -d  #Run demo mode <ms>
--encoding, -e #Encode in the specified format, jpg, bmp or png
--restart, -rs  #Set JPEG restart flag
--exif, -x   #Setting EXIF tags
--gpsdexif, -gps #Set real-time exif time (requires GPS Dongle access)
--fullpreview,  -fg  #Full Screen Preview
--keypress, -k  #Push button photo mode
--signal, -s  # Signal mode
--burst, -bm #Capture mode

raspivid Parameters

--width, -w #Set the video width
--height, -h #Sets the height of the video
--bitrate, -b #Sets the bitrate
--output, -o #Set output file name <filename>
--listen, -l #When using a network connection, wait for a network connection
--versbose, -v #Print details
--timeout, -t #Sets the preview time
--demo, -d #Run demo <ms>
--framerate, -fs #set frame rate
--penc, -e #Show encoded preview image
--intra, -g #Set internal refresh period
--qp, -qp #Set quantization parameters
--profile, -pf #Specify H264 profile, baseline / main / high
--level, -lev #Sets the 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 the SPS block
--timed, -td #Timed toggle recording and pause functions
--keypress, -k #Pause recording by keystroke
--signal, -s #Switch between pause and record according to SIGUSR1
--split, -sp #In signal and keypress mode, the file will be recreated each time you re-record
--vectors, -x #Vector output
--flush, -fl # Force a flush of the output data buffer immediately after writing video data, bypassing any OS caching of the 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 for startup
--segment, -sg # Split the video stream into multiple files
--wrap, -wr # Set the maximum value for splitting
--start, -sn #Sets the initial split encoding
--raw, -r #Sets the metadata filename
--raw-format, -rf #Specify metadata format yuv / rgb / grey