Template: RPi Camera Raspicam Guide

From Waveshare Wiki
Revision as of 10:43, 2 March 2022 by Waveshare-eng11 (talk | contribs) (Created page with "==Install Raspicam (Optional)== 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 t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Install Raspicam (Optional)

If you use the Bullseye image (the newest image), you need to install the Raspicam for using the legacy stack.
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

Enable Camera

To use the Raspicam application, you need to enable the camera first.
Open the raspi-config tool from the terminal

sudo raspi-config

Select Interfacing Options then Camera and press Enter. Choose Yes then Ok. Go to Finish and you’ll be prompted to reboot.

Test camera

raspistill

raspistill is the command line tool for capturing still photographs with a Raspberry Pi camera module.

raspistill -o cam.jpg

raspivid

raspivid is the command line tool for capturing video with a Raspberry Pi camera module.

raspivid -o vid.h264

raspiyuv

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.
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.

raspiyuv -o cam.jpg

Command Line Options

Option Option(abbreviate) Description
--preview -p Preview window settings <'x,y,w,h'>
--fullscreen -f Fullscreen preview mode
--nopreview -n Do not display a preview window
--opacity -op Set preview window opacity
--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 Set sensor region of interest
--shutter -ss Set shutter speed/time
--drc -drc Enable/disable dynamic range compression
  • off
  • low
  • med
  • high
--stats -st Use stills capture frame for image statistics
--awbgains -awbg --analoggain -ag
--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


Parameter for --shutter option
Camera Version Max (ms) OV5647 6000000 (i.e. 6s)
IMX219 10000000 (i.e. 10s)
IMX477 200000000 (i.e. 200s)

Raspistill Command Line Options

Option Option(abbreviate) Description
--width
--height
--quality
-w
-h
-q
Set image width <size>
Set image height <size>
Set JPEG quality <0 to 100>
--raw -r Add raw Bayer data to JPEG metadata
--output -o Output filename <filename>
--latest -l Link latest frame to filename <filename>
--verbose -v Output verbose information during run
--timeout -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
full preview mode
--keypress -k Keypress mode
--signal -s Signal mode
--burst -bm

Raspivid Command Line Options

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
--exif, --encoding, --thumb, --raw, --quality
Extra options
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 Official Guides