Difference between revisions of "Template:RPi Camera Raspicam Guide"

From Waveshare Wiki
Jump to: navigation, search
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
 +
==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.<br />
 +
If you are using the latest Bullseye system, you need to install and configure it separately. <br />
 +
<font color="red">Applicable to OV5647, official IMX219, official IMX477.</font>
 
==Install Raspicam (Optional)==
 
==Install Raspicam (Optional)==
 
If you use the Bullseye image (the newest image), you need to install the Raspicam for using the legacy stack. <br />
 
If you use the Bullseye image (the newest image), you need to install the Raspicam for using the legacy stack. <br />
Open a terminal and run the following commands
+
<font color="#FF0000">Note: This driver does not support the 64-bit Raspberry Pi system for now.</font>
 +
 
 +
Open a terminal and run the following commands.
 
<pre>
 
<pre>
 
sudo apt-get update
 
sudo apt-get update
Line 12: Line 19:
 
sudo reboot
 
sudo reboot
 
</pre>
 
</pre>
==Enable Camera==
+
==Call the Camera==
To use the Raspicam application, you need to enable the camera first. <br/>
+
===raspistill===
Open the raspi-config tool from the terminal
+
raspistill is for taking still pictures.
 +
For example: <font style="color:grey; font-style:italic">raspistill -o cam.jpg</font>
 +
===raspivid===
 +
raspivid is for recording video.
 +
For example: <font style="color:grey; font-style:italic">raspivid -o vid.h264</font>
 +
===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.<br/>
 +
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.<br/>
 +
For example: <font style="color:grey; font-style:italic">raspiyuv -o cam.jpg</font>
 +
 
 +
===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. <br />
 +
 
 +
<pre>
 +
--preview, -p  #Set the preview window<x, y, w, h>
 +
</pre>
 +
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.
 +
 
 +
<pre>
 +
--fullscreen, -f  #Full screen preview window
 +
</pre>
 +
Display the preview window in full screen.
 +
 
 +
<pre>
 +
--nopreview, -n  #No preview window displayed
 +
</pre>
 +
Close the preview window and the command will output the image or video directly to the file.
 +
 
 +
<pre>
 +
--opacity, -op  #Set the preview window transparency
 +
</pre>
 +
Set the transparency of the preview window, 0 is invisible, and 255 is fully transparent.
 +
 
 +
<pre>
 +
--sharpness, -sh  #Set image sharpness (-100 - 100)
 +
</pre>
 +
The default sharpening value is 0.
 +
 
 +
<pre>
 +
--contrast. -co  #Setting Image Contrast(-100 - 100)
 +
</pre>
 +
The default contrast is 0.
 +
 
 +
<pre>
 +
--brightness, -br  #Set Image Contrast(0 - 100)
 +
</pre>
 +
The default brightness is 50, 0 is all black and 100 is all white.
 +
 
 +
<pre>
 +
--saturation, -sa  #Set image saturation (-100 - 100)
 +
</pre>
 +
The default saturation is 0.
 +
 
 +
<pre>
 +
--ISO  #Setting Shutter Sensitivity (100 - 800)
 +
</pre>
 +
Setting the sensitivity when taking pictures.
 +
 
 +
<pre>
 +
--vstab, -vs  #Enable video stabilization
 +
</pre>
 +
Only the video recording mode is valid, with video stabilization turned on.
 +
 
 +
<pre>
 +
--ev  #Set EV compensation
 +
</pre>
 +
Set the EV compensation value of the image, and the default is 0.
 +
 
 +
<pre>
 +
--exposure,  -ex  #Setting the exposure mode
 +
</pre>
 +
Exposure options:<br />
 +
*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.
 +
<pre>
 +
--flicker, -fli  #Flicker Avoidance
 +
</pre>
 +
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
 +
 
 +
<pre>
 +
--awb,  #Set auto white balance mode
 +
</pre>
 +
*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.
 +
 
 +
<pre>
 +
--imfx, -ifx  #Set the image filter effect
 +
</pre>
 +
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.
 +
 
 
<pre>
 
<pre>
sudo raspi-config
+
--colfx, -cfx  #Set the color effect<U:V>
 
</pre>
 
</pre>
Select Interfacing Options then Camera and press Enter. Choose Yes then Ok. Go to Finish and you’ll be prompted to reboot.
+
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 <font style="color:grey; front-style:italic>--colfx 128:128</font> will set the image to a monochrome image.
==Test camera==
+
 
===raspistill===
+
<pre>
raspistill is the command line tool for capturing still photographs with a Raspberry Pi camera module.
+
--metering, -mm  #Setting the metering mode
 +
</pre>
 +
Configurable mode:
 +
*average: Average or full-frame metering
 +
*spot: Spot metering
 +
*backlit: Preset a backlit image
 +
*matrix: Matrix metering
 +
 
 +
<pre>
 +
--rotation, -rot  #Set image rotation (0 - 359)
 +
</pre>
 +
The image rotation angle can be set by the angle parameter.
 +
<pre>
 +
--hflip, -hf  #Set image horizontal flip
 +
</pre>
 +
Set image horizontal flip.
 +
 
 
<pre>
 
<pre>
raspistill -o cam.jpg
+
--vflip, -vf  #Set image vertical flip
 
</pre>
 
</pre>
===raspivid===
+
Set image vertical flip.
raspivid is the command line tool for capturing video with a Raspberry Pi camera module.
+
 
 
<pre>
 
<pre>
raspivid -o vid.h264
+
--roi, #Crop image <x, y, w, h>
 
</pre>
 
</pre>
===raspiyuv===
+
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 <font style="color:grey; font-style:italic">-roi 0.5,0.5,0.25,0.25 </font>
raspiyuv has the same set of features as raspistill but instead of outputting standard image files such as .jpgs, it generates YUV420 or RGB888 image files from the output of the camera ISP. <br />
+
 
In most cases using raspistill is the best option for standard image capture, but using YUV can be of benefit in certain circumstances. For example if you just need a uncompressed black and white image for computer vision applications, you can simply use the Y channel of a YUV capture.
 
 
<pre>
 
<pre>
raspiyuv -o cam.jpg
+
--shutter, --ss  Set shutter speed/time
 
</pre>
 
</pre>
===Command Line Options===
+
Set the shutter time (unit:ms). The maximum shutter time that can be set varies depending on the light-sensitive chip.<br />
 
{|class="wikitable"
 
{|class="wikitable"
! Option !! Option(abbreviate) !! Description
+
!Mode !! Maximum number(ms)
 
|-
 
|-
| --preview
+
|V1 (OV5647) || 6000000 (6s)
| -p
 
| Preview window settings <'x,y,w,h'>
 
 
|-
 
|-
| --fullscreen
+
|V2 (IMX219) || 10000000 (10s)
| -f
 
| Fullscreen preview mode
 
 
|-
 
|-
| --nopreview
+
|HQ (IMX477 || 200000000 (200s)
| -n
+
|}
| Do not display a preview window
+
 
|-
+
<pre>
| --opacity
+
--drc, -drc #Enable/disable dynamic range compression
| -op
+
</pre>
| Set preview window opacity
+
*off (Default)
|-
 
| --sharpness
 
| -sh
 
| Set image sharpness (-100 - 100)
 
|-
 
| --contrast
 
| -co
 
| Set image contrast (-100 - 100)
 
|-
 
| --brightness
 
| -br
 
| Set image brightness (0 - 100)
 
|-
 
| --saturation
 
| -sa
 
| Set image saturation (-100 - 100)
 
|-
 
| --ISO
 
| -ISO
 
| Set capture ISO (100 - 800)
 
|-
 
| --vstab
 
| -vs
 
| Turn on video stabilisation
 
|-
 
| --ev
 
| -ev
 
| Set EV compensation (-10 - 10)
 
|-
 
| --exposure
 
| -ex
 
| Set exposure mode
 
*auto: use automatic exposure mode
 
*night: select setting for night shooting
 
*nightpreview:
 
*backlight: select setting for backlit subject
 
*spotlight:
 
*sports: select setting for sports (fast shutter etc.)
 
*snow: select setting optimised for snowy scenery
 
*beach: select setting optimised for beach
 
*verylong: select setting for long exposures
 
*fixedfps: constrain fps to a fixed value
 
*antishake: antishake mode
 
*fireworks: select setting optimised for fireworks
 
|-
 
| --flicker
 
| -fli
 
| Set flicker avoidance mode
 
*off: turn off flicker avoidance
 
*auto: automatically detect mains frequency
 
*50hz: set avoidance at 50Hz
 
*60hz: set avoidance at 60Hz
 
|-
 
| --awb
 
| -awb
 
| Set Automatic White Balance (AWB) mode
 
*off: turn off white balance calculation
 
*auto: automatic mode (default)
 
*sun: sunny mode (between 5000K and 6500K)
 
*cloud: cloudy mode (between 6500K and 12000K)
 
*shade: shade mode
 
*tungsten: tungsten lighting mode (between 2500K and 3500K)
 
*fluorescent: fluorescent lighting mode (between 2500K and 4500K)
 
*incandescent: incandescent lighting mode
 
*flash: flash mode
 
*horizon: horizon mode
 
*greyworld: Use this on the NoIR camera to fix incorrect AWB results due to the lack of the IR filter.
 
|-
 
| --imxfx
 
| -ifx
 
| Set image effect
 
*one: no effect (default)
 
*negative: invert the image colours
 
*solarise: solarise the image
 
*posterise: posterise the image
 
*whiteboard: whiteboard effect
 
*blackboard: blackboard effect
 
*sketch: sketch effect
 
*denoise: denoise the image
 
*emboss: emboss the image
 
*oilpaint: oil paint effect
 
*hatch: hatch sketch effect
 
*gpen: graphite sketch effect
 
*pastel: pastel effect
 
*watercolour: watercolour effect
 
*film: film grain effect
 
*blur: blur the image
 
*saturation: colour saturate the image
 
*colourswap: not fully implemented
 
*washedout: not fully implemented
 
*colourpoint: not fully implemented
 
*colourbalance: not fully implemented
 
*cartoon: not fully implemented
 
|-
 
| --colfx
 
| -cfx
 
| Set colour effect <U:V>
 
|-
 
| --metering
 
| -mm
 
| Set metering mode
 
*average: average the whole frame for metering
 
*spot: spot metering
 
*backlit: assume a backlit image
 
*matrix: matrix metering
 
|-
 
| --rotation
 
| -rot
 
| Set image rotation (0 - 359)
 
|-
 
| --hflip
 
| -hf
 
| Set horizontal flip
 
|-
 
| --vflip
 
| -vf
 
| Set vertical flip
 
|-
 
|--roi
 
| -roi
 
| Set sensor region of interest
 
|-
 
| --shutter
 
| -ss
 
| Set shutter speed/time
 
|-
 
| --drc
 
| -drc
 
| Enable/disable dynamic range compression
 
*off
 
 
*low
 
*low
 
*med
 
*med
 
*high
 
*high
|-
 
| --stats
 
| -st
 
| Use stills capture frame for image statistics
 
|-
 
| --awbgains
 
| -awbg
 
|-
 
| --analoggain
 
| -ag
 
|Set blue and green gain, takes effect if --awb off is set
 
|-
 
| --digitalgain
 
| -dg
 
|
 
|-
 
| --mode
 
| -md
 
|
 
|-
 
| --camselect
 
| -cs
 
|
 
|-
 
| --annotate
 
| -a
 
| Enable/set annotate flags or text
 
|-
 
| --annotateex
 
| -ae
 
| Set extra annotation parameters
 
|-
 
| --stereo
 
| -3d
 
|
 
|-
 
| --decimate
 
| -dec
 
|
 
|-
 
| --3dswap
 
| -3dswap
 
|-
 
| --settings
 
| -set
 
|
 
|}
 
  
 +
<pre>
 +
--stats, -st  #Counting images by still image frames
 +
</pre>
 +
 +
<pre>
 +
--awbgains, -awbg
 +
</pre>
 +
Set blue and green gain, effective when --awb off is set.
 +
 +
<pre>
 +
--analoggain, -ag
 +
</pre>
 +
Set the analog gain value.
  
; Parameter for --shutter option
+
<pre>
{|class="wikitable"
+
--digitalgain, -dg
! Camera Version !! Max (ms)
+
</pre>
|-
+
Set the digital gain value.
| OV5647 || 6000000 (i.e. 6s)
 
|-
 
| IMX219 || 10000000 (i.e. 10s)
 
|-
 
| IMX477 || 200000000 (i.e. 200s)
 
|}
 
  
; Parameter for --mode, -md
+
<pre>
*OV5647
+
--mode, -md
 +
</pre>
 +
Set the sensor mode:
 +
* OV5647
 
{|class="wikitable"
 
{|class="wikitable"
! Mode !! Resolution !! Aspect Ratio !! Frame Rate !! FoV
+
! Mode !! Resolution !! Aspect Ratio !! Frame Rate !! FoV
 
|-
 
|-
| 0 || Automatic selection || || ||
+
| 0 || Auto-select || || ||  
 
|-
 
|-
| 1 || 1920 x 1080 || 16:9 || 1-30fps || Partial
+
| 1 || 1920 x 1080 || 16:9 || 1-30fps || Local
 
|-
 
|-
 
| 2 || 2592 x 1944 || 4:3 || 1-15fps || Full Frame
 
| 2 || 2592 x 1944 || 4:3 || 1-15fps || Full Frame
Line 262: Line 244:
 
|-
 
|-
 
| 4 || 1296 x 972 || 4:3 || 1 - 42fps || Full Frame
 
| 4 || 1296 x 972 || 4:3 || 1 - 42fps || Full Frame
|-
+
|-
 
| 5 || 1296 x 730 || 16:9 || 1- 49fps || Full Frame
 
| 5 || 1296 x 730 || 16:9 || 1- 49fps || Full Frame
 
|-
 
|-
Line 272: Line 254:
 
*IMX219
 
*IMX219
 
{|class="wikitable"
 
{|class="wikitable"
! Mode !! Resolution !! Aspect Ratio !! Frame Rate !! FoV
+
! Mode!!Resolution !! Aspect Ratio !! Frame Rate !! FoV
 
|-
 
|-
| 0 || Automatic selection || || ||
+
| 0 || Auto-select|| || ||  
 
|-
 
|-
| 1 || 1920 x 1080 || 16:9 || 0.1-30fps || Partial
+
| 1 || 1920 x 1080 || 16:9 || 0.1-30fps || Local
 
|-
 
|-
| 2 || 3280 x 2464 || 4:3 || 0.1-15fps || Full Frame
+
| 2 || 3280 x 2464 || 4:3 ||0. 1-15fps || Full Frame
 
|-
 
|-
| 3 || 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
+
| 4 || 1640 x 972 || 4:3 || 1 - 42fps || Full Frame
 +
|- 
 +
| 5 || 1296 x 730 || 16:9 || 1- 49fps ||  Full Frame
 
|-
 
|-
| 5 || 1296 x 730 || 16:9 || 1- 49fps || Full Frame
+
| 6 || 640 x 480 || 4:3 || 42.1 - 60fps || Full Frame
 
|-
 
|-
| 6 || 640 x 480 || 4:3 || 42.1 - 60fps || Full Frame
+
| 7 || 640 x 480 || 4:3 || 60.1 - 90fps || Full Frame
|-
 
| 7 || 640 x 480 || 4:3 || 60.1 - 90fps || Full Frame
 
 
|}
 
|}
 
*HQ Camera
 
*HQ Camera
 
{|class="wikitable"
 
{|class="wikitable"
! Mode !! Resolution !! Aspect Ratio !! Frame Rate !! FoV
+
! Mode!!Resolution !! Aspect Ratio !! Frame Rate !! FoV
 
|-
 
|-
| 0 || Automatic selection || || ||
+
| 0 || Auto-select || || ||  
 
|-
 
|-
| 1 || 2028 x 1080 || 169:90 || 0.1-50fps || Partial
+
| 1 || 2028 x 1080 || 169:90 || 0.1-50fps || Local
 
|-
 
|-
| 2 || 2028 x 1080 || 4:3 || 0.1-50fps || Full Frame
+
| 2 || 2028 x 1080 || 4:3 ||0. 1-50fps || Full Frame
 
|-
 
|-
| 3 || 4056x3040 || 4:3 || 0.005 - 10fps || Full Frame
+
| 3 || 4056 x 3040 || 4:3 || 0.005 - 10fps || Full Frame
 
|-
 
|-
| 4 || 1332x990 || 74:55 || 50.1-120 fps || Partial
+
| 4 || 1332 x 990 || 74:55 || 50.1-120 fps || Local
 
|}
 
|}
; Parameter for --annotate
+
 
*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.
+
<pre>
 +
--camselect, -cs
 +
</pre>
 +
When the system is connected to multiple cameras, select camera, 0 or 1.
 +
 
 +
<pre>
 +
--annotate, -a #Enable/Set Comments
 +
</pre>
 +
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.<br />
 
Configurable options:
 
Configurable options:
 
{| class="wikitable"
 
{| class="wikitable"
! value !! parameter description
+
! Value !! Parameters
 
|-
 
|-
| -a 4 || time
+
| -a 4 || Time
 
|-
 
|-
| -a 8 || date
+
| -a 8 || Date
 
|-
 
|-
 
| -a 12 || Time and date, actually 4 + 8
 
| -a 12 || Time and date, actually 4 + 8
Line 318: Line 308:
 
| -a 16 || Shutter setting
 
| -a 16 || Shutter setting
 
|-
 
|-
| -a 32 || CAF settings
+
| -a 32 || CAF setting
 
|-
 
|-
| -a 64 || gain setting
+
| -a 64 || Gain setting
 
|-
 
|-
 
| -a 128 || Lens settings
 
| -a 128 || Lens settings
 
|-
 
|-
| -a 256 || animation settings
+
| -a 256 || Animation Settings
 
|-
 
|-
| -a 512 || number of frames
+
| -a 512 || Frame Rate
 
|-
 
|-
| -a 1024 || black background
+
| -a 1024 || Black background
 
|-
 
|-
| -a "ABC %Y-%m-%d %X" || display text
+
| -a "ABC %Y-%m-%d %X" || Display text
 
|-
 
|-
 
| -a 4 -a "ABC %Y-%m-%d %X" || Display time/date in custom format
 
| -a 4 -a "ABC %Y-%m-%d %X" || Display time/date in custom format
Line 336: Line 326:
 
| -a 8 -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
 
|}
 
|}
 +
 
<pre>
 
<pre>
--annotateex, -ae #Set additional annotation parameters
+
--annotateex, -ae #Set additional annotation parameters
 
</pre>
 
</pre>
  
Line 344: Line 335:
 
</pre>
 
</pre>
 
Set the binocular mode.
 
Set the binocular mode.
*sbs - side by side mode
+
*sbs - Side-by-side mode
*tb: - Portrait mode
+
*tb: -Vertical mode
*off - turn off binocular mode (default)
+
*off -Turn off binocular mode (default)
  
 
<pre>
 
<pre>
 
--decimate, -dec
 
--decimate, -dec
 
</pre>
 
</pre>
Halve the width and height of the binocular image
+
Halving the width and height of binocular images.
  
 
<pre>
 
<pre>
 
--setting, -set
 
--setting, -set
 
</pre>
 
</pre>
Output current camera settings
+
Output the current camera settings.
  
===Raspistill Command Line Options===
+
===raspistill Parameters===
{|class="wikitable"
+
<pre>
! Option !! Option(abbreviate) !! Description
+
--width, -w  #Set image width
|-
+
--height, -h #Set image height
| --width <br /> --height <br /> --quality
+
--quality, 0q  #Set JPEG quality <0 ~ 100>
| -w <br /> -h <br /> -q
+
--raw, -r #Add the original Bayer data to the JPEG metadata
| Set image width <size> <br /> Set image height <size> <br /> Set JPEG quality <0 to 100>
+
--output, -o #output file <filename>
|-
+
--latest, -l #Associating the last image frame to the file <filename>
| --raw
+
--verbose, -v #Print Details
| -r
+
--timeout, -t #Set program preview time
| Add raw Bayer data to JPEG metadata
+
--timelapse, -tl #Set up demo photography
|-
+
--framestart, -fs #Save the number of the first frame
| --output  
+
--datetime, -dt #Naming files with date and time
| -o
+
--timestamp, -ts #Naming files with timestamps
| Output filename <filename>
+
--thumb, -th #Set thumbnail parameter <x:y:qulity>, default is (64:48:35)
|-
+
--demo, -d #Run demo mode <ms>
| --latest
+
--encoding, -e #Encode in the specified format, jpg, bmp or png
| -l
+
--restart, -rs #Set JPEG restart flag
| Link latest frame to filename <filename>
+
--exif, -x   #Setting EXIF tags
|-
+
--gpsdexif, -gps #Set real-time exif time (requires GPS Dongle access)
| --verbose
+
--fullpreview-fg  #Full Screen Preview
| -v
+
--keypress, -k #Push button photo mode
| Output verbose information during run
+
--signal, -s # Signal mode
|-
+
--burst, -bm #Capture mode
| --timeout
+
</pre>
| -t
 
| Time before the camera takes picture and shuts down
 
|-
 
| --timelapse
 
| -tl
 
| time-lapse mode
 
|-
 
| --framestart
 
| --fs
 
|
 
|-
 
| --datetime
 
| -dt
 
|
 
|-
 
| --timestamp
 
| -ts
 
|
 
|-
 
| --thumb
 
| -th
 
| Set thumbnail parameters (x:y:quality)
 
|-
 
| --demo
 
| -d
 
| Run a demo mode <milliseconds>
 
|-
 
| --encoding
 
| -e
 
| Encoding to use for output file
 
|-
 
| --restart
 
| -rs
 
|
 
|-
 
| --exif
 
| -x
 
| EXIF tag to apply to captures (format as 'key=value')
 
|-
 
| --gpsdexif
 
| -gps
 
|
 
|-
 
| --fullpreview
 
|- fp
 
| full preview mode
 
|-
 
| --keypress
 
| -k
 
| Keypress mode
 
|-
 
| --signal
 
| -s
 
| Signal mode
 
|-
 
| --burst
 
| -bm
 
|}
 
  
===Raspivid Command Line Options===
+
===raspivid Parameters===
{|class="wikitable"
 
! Option !! Option(abbreviate) !! Description
 
|-
 
| --width
 
| -w
 
| Set image width <size>
 
|-
 
| --height
 
| -h
 
| Set image height <size>
 
|-
 
| --bitrate
 
| -b
 
| Set bitrate
 
|-
 
| --output
 
| -o
 
| Output filename <filename>
 
|-
 
| --listen
 
| -l
 
|
 
|-
 
| --verbose
 
| -v
 
| Output verbose information during run
 
|-
 
| --timeout
 
| -t
 
| Time before the camera takes picture and shuts down
 
|-
 
| --demo
 
| -d
 
| Run a demo mode <milliseconds>
 
|-
 
| --framerate
 
| -fps
 
| Specify the frames per second to record
 
|-
 
| --penc
 
| -e
 
| Display preview image after encoding
 
|-
 
| --intra
 
| -g
 
| Specify the intra refresh period (key frame rate/GoP)
 
|-
 
| --qp
 
| -qp
 
| Set quantisation parameter
 
|-
 
| --profile
 
| -pf
 
| Specify H264 profile to use for encoding
 
*baseline
 
*main
 
*high
 
|-
 
| --level
 
| -lev
 
|-
 
| --irefresh
 
| -if
 
|
 
|-
 
| --inline
 
| --ih
 
| Insert PPS, SPS headers
 
|-
 
| --spstimings
 
| --stm
 
|
 
|-
 
| --timed
 
| -td
 
| Do timed switches between capture and pause
 
|-
 
| --keypress
 
| -k
 
| Toggle between record and pause on Enter keypress
 
|-
 
| --signal
 
| -s
 
| Toggle between record and pause according to SIGUSR1
 
|-
 
| --split
 
| -sp
 
|
 
|-
 
| --circular
 
| --c
 
|
 
|-
 
| --vectors
 
| -x
 
|
 
|-
 
| --flush
 
| -fl
 
|
 
|-
 
| --save-pts
 
| -pts
 
|
 
|-
 
| --codec
 
| --cd
 
|
 
|-
 
| --initial
 
| -i
 
| Define initial state on startup
 
|-
 
| --segment
 
| -sg
 
| Segment the stream into multiple files
 
|-
 
| --wrap
 
| -wr
 
| Set the maximum value for segment number
 
|-
 
| --start
 
| -sn
 
| Set the initial segment number
 
|-
 
| --raw
 
| -r
 
|
 
|-
 
| --raw-format
 
| -rf
 
|
 
|}
 
 
 
===Raspiyuv Command Line Options===
 
Many of the options for raspiyuv are the same as those for raspistill. This section shows the differences.
 
; Unsupported options
 
 
<pre>
 
<pre>
--exif, --encoding, --thumb, --raw, --quality
+
--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
 
</pre>
 
</pre>
; Extra options:
 
{|class="wikitable"
 
! Option !! Option(abbreviate) !! Description
 
|-
 
| --rgb
 
| -rgb
 
| Save uncompressed data as RGB888
 
|-
 
| --luma
 
| -y
 
|
 
|-
 
| --bgr
 
| -bgr
 
|
 
|}
 
For more information about the Raspicam, please refer to the [https://www.raspberrypi.com/documentation/accessories/camera.html#raspicam-commands Official Guides]
 

Latest revision as of 09:10, 7 August 2023

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