Difference between revisions of "Rpi Camera Module"

From eLinux.org
Jump to: navigation, search
(Adjusting Lens Focus)
(Technical Parameters (v.2 board): add link to measured response curves)
 
(123 intermediate revisions by 10 users not shown)
Line 4: Line 4:
  
 
==Introduction==
 
==Introduction==
 +
[[File:RPiCam.jpg|thumbnail|right|Raspberry Pi Camera v1]]
 +
[[File:Pi-noir.png|thumbnail|right|Pi NoIR v1]]
 +
The Raspberry Pi camera board v.1 has a 5 MPixel sensor, and connects via a ribbon cable to the CSI connector on the Raspberry Pi. A [http://www.raspberrypi.org/wp-content/uploads/2013/07/RaspiCam-Documentation.pdf User's Guide] describes setup and use. The video and still image quality is better than a USB webcam of similar price.
 +
It was released for sale on 14 May 2013<ref>http://www.raspberrypi.org/archives/3890</ref>.
  
The Raspberry Pi Camera board was released for sale on 14th May 2013.<ref>http://www.raspberrypi.org/archives/3890</ref> The initial production of 10k units<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=350#p358580</ref> sold out quickly. The camera contains a 5 MPixel sensor and connects via a ribbon cable to the CSI connector on the board. Subjective video and still image quality is good; it is better than a USB webcam of similar price.
+
The "Pi NoIR" version of the v.1 camera was released on 28 October 2013. It has the same sensor with the IR filter removed, and a black PCB.<ref>http://www.raspberrypi.org/archives/5128</ref> With no IR filter, it can see near-IR wavelengths (700 - 1000 nm) like a security camera, with the tradeoff of poor color rendition. It is otherwise the same and uses the same software as the normal Pi camera.
  
==Technical Parameters==
+
The "Pi Camera v2.1" was released 25 April 2016, in both normal and NoIR versions <ref>https://www.raspberrypi.org/blog/new-8-megapixel-camera-board-sale-25/</ref>. It uses the Sony IMX219 8-megapixel sensor with a slightly wider (62 degrees H) and faster (f/2.0) lens. The board is the same 25 x 24 mm size, and is intended as a drop-in replacement for the previous camera.
* Sensor size: 3.67 x 2.74 mm
+
 
 +
Initial production of v2.1 camera boards have lens focus set closer than v.1 (infinity)<ref>https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200#p971091</ref>. This can be [https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200#p971545 modified].  Later production was set at infinity <ref>https://www.raspberrypi.org/blog/camera-board-comparisons-pi-noir-v1-vs-pi-noir-v2/#comment-1259481</ref>.
 +
 
 +
==Technical Parameters (v.1 board)==
 +
* Sensor type: OmniVision OV5647<ref>http://www.ovt.com/products/sensor.php?id=66</ref> Color CMOS QSXGA (5-megapixel)
 +
* Sensor size: 3.67 x 2.74 mm (1/4" format)
 
* Pixel Count: 2592 x 1944
 
* Pixel Count: 2592 x 1944
 
* Pixel Size: 1.4 x 1.4 um
 
* Pixel Size: 1.4 x 1.4 um
Line 16: Line 25:
 
* Full-frame SLR lens equivalent: 35 mm
 
* Full-frame SLR lens equivalent: 35 mm
 
* Fixed Focus: 1 m to infinity
 
* Fixed Focus: 1 m to infinity
 +
* Video: 1080p at 30 fps with codec H.264 (AVC)
 +
* Up to 90 fps Video at VGA
 +
* Board size: 25 x 24 mm (not including flex cable)
 +
* Test Fixture Holes: 4x D=2.15 mm on 12.5 x 21.0 mm centers
  
 
Because the focal length of the lens is roughly the same as the width of the sensor, it is easy to remember the field of view: at ''x'' meters away, you can see about ''x'' meters horizontally, assuming 4x3 stills mode. Horizontal field of view in 1080p video mode is 75% of that (75% H x 55% V sensor crop for 1:1 pixels at 1920x1080).
 
Because the focal length of the lens is roughly the same as the width of the sensor, it is easy to remember the field of view: at ''x'' meters away, you can see about ''x'' meters horizontally, assuming 4x3 stills mode. Horizontal field of view in 1080p video mode is 75% of that (75% H x 55% V sensor crop for 1:1 pixels at 1920x1080).
  
'''References:''' Focal length and f-stop measurements [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=46150],[http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=325#p357018]  depth of field & angle of view calculators[http://www.tawbaware.com/maxlyons/calc.htm] sensor info[http://ovt.com/products/sensor.php?id=66]  f-stop measurement[http://www.raspberrypi.org/phpBB3/viewtopic.php?t=32605&p=357246#p357135]
+
'''References:''' Focal length and f-stop measurements [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=46150],[http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=325#p357018]  depth of field & angle of view calculators[http://www.tawbaware.com/maxlyons/calc.htm] sensor info[http://ovt.com/products/sensor.php?id=66]  f-stop measurement[http://www.raspberrypi.org/phpBB3/viewtopic.php?t=32605&p=357246#p357135] Spectral response curves [http://www.khufkens.com/ov5647-spectral-response/]
 +
 
 +
[[File:Pi-NoIR-v2.jpg|thumbnail|Pi NoIR v2.1]]
 +
 
 +
==Technical Parameters (v.2 board)==
 +
* Sensor type: Sony IMX219PQ<ref>http://www.sony.net/Products/SC-HP/new_pro/april_2014/imx219_e.html</ref> Color CMOS 8-megapixel
 +
* Sensor size:  3.674 x 2.760 mm (1/4" format)
 +
* Pixel Count: 3280 x 2464 (active pixels)  3296 x 2512 (total pixels)
 +
* Pixel Size: 1.12 x 1.12 um
 +
* Lens: f=3.04 mm, f/2.0
 +
* Angle of View:  62.2 x 48.8 degrees
 +
* Full-frame SLR lens equivalent: 29 mm
 +
* Video Modes:
 +
* 1 - 1080P30 cropped (680 pixels off left/right, 692 pixels off top/bottom), up to 30fps
 +
* 2 - 3240x2464 Full 4:3, up to 15fps
 +
* 3 - 3240x2464 Full 4:3, up to 15fps (identical to 2)
 +
* 4 - 1640x1232 binned 4:3, up 40fps
 +
* 5 - 1640x922 2x2 binned 16:9 (310 px crop T/B before binning), up to 40fps
 +
* 6 - 720P bin+crop (360 px L/R, 512 px T/B before binning), 40..90fps (OC: 120fps)
 +
* 7 - VGA bin+crop (1000 px L/R, 752 px T/B before binning), 40..90fps (OC: 120fps)
 +
* Board size: 25 x 23.86 x 9mm
 +
* Mounting Holes: 4x D=2.20 mm on 12.5 x 21.0 mm centers
 +
 
 +
'''References:''' Semi-official v.2 thread:[https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815#p960789]
 +
Sony IMX219 product brief:[http://www.sony.net/Products/SC-HP/new_pro/april_2014/imx219_e.html] Crypto chip:[https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=149426#p982590]
 +
Measured response curves:[https://www.spiedigitallibrary.org/journals/journal-of-electronic-imaging/volume-26/issue-01/013014/Laying-the-foundation-to-use-Raspberry-Pi-3-V2-camera/10.1117/1.JEI.26.1.013014.full?SSO=1]
  
 
==Sample Programs==
 
==Sample Programs==
  
Sample programs using the camera for taking stills and video have been developed for the Foundation and the source for these is available on [https://github.com/raspberrypi/userland/tree/master/host_applications/linux/apps/raspicam github].
+
Sample programs using the camera for taking stills and video have been developed for the Foundation. There is a [http://www.raspberrypi.org/wp-content/uploads/2013/07/RaspiCam-Documentation.pdf User's Guide] and the source for these programs is available on [https://github.com/raspberrypi/userland/tree/master/host_applications/linux/apps/raspicam github].
  
 
Forum user M1M1 published instructions on compiling the sample programs [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43990#p350970 here]
 
Forum user M1M1 published instructions on compiling the sample programs [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43990#p350970 here]
  
 
The command line parameters for the programs are as follows:
 
The command line parameters for the programs are as follows:
 +
===RaspiVid===
 
<pre>
 
<pre>
RaspiVid Camera App  
+
RaspiVid Camera App v1.3.9
 
===================   
 
===================   
 
+
Display camera output to display, and optionally saves an H264 capture at requested bitrate
Display camera output to display, and optionally saves an H264 capture at requested bitrate  
+
 
 
+
usage: raspivid [options]
 
+
 
usage: RaspiVid [options]  
+
Image parameter commands
 
+
 
Image parameter commands  
+
-?, --help      : This help information
 
+
-w, --width    : Set image width <size>. Default 1920
?, ‐‐ help      : This help information  
+
-h, --height    : Set image height <size>. Default 1080
‐w, ‐‐ width    : Set image width <size>. Default 1920
+
-b, --bitrate  : Set bitrate. Use bits per second (e.g. 10MBits/s would be -b 10000000)
‐h, ‐‐ height    : Set image height <size>. Default 1080
+
-o, --output    : Output filename <filename> (to write to stdout, use '-o -')
‐b, ‐‐ bitrate  : Set bitrate. Use bits per second (e.g.   10MBits/ s would be b 10000000)
+
-v, --verbose  : Output verbose information during run
‐o, ‐‐ output    : Output filename <filename> (to write to stdout, use '‐o  ‐ ')  
+
-t, --timeout  : Time (in ms) to capture for. If not specified, set to 5s. Zero to disable
‐v, ‐‐ verbose  : Output   verbose information during run  
+
-d, --demo      : Run a demo mode (cycle through range of camera options, no capture)
‐t, ‐‐ timeout  : Time (in ms) before  takes picture  and  shuts down.   If not specified, set to 5s  
+
-fps, --framerate       : Specify the frames per second to record
‐d, ‐‐ demo      : Run a demo mode (cycl e  through range of camera options, no capture)  
+
-e, --penc      : Display preview image *after* encoding (shows compression artifacts)
‐fps, ‐‐ framerate       : Specify the frames per second to record  
+
-g, --intra    : Specify the intra refresh period (key frame rate/GoP size)
‐e, ‐‐ penc      : Display preview image *after* encoding (shows compression artifacts)   
+
-pf, --profile  : Specify H264 profile to use for encoding
    
+
-td, --timed    : Cycle between capture and pause. -cycle on,off where on is record time and off is pause time in ms
Preview parameter commands  
+
-s, --signal    : Cycle between capture and pause on Signal
 
+
-k, --keypress  : Cycle between capture and pause on ENTER
‐p, ‐‐ preview  : Preview window settings <'x,y,w,h'>
+
-i, --initial   : Initial state. Use 'record' or 'pause'. Default 'record'
‐f, ‐‐ fullscreen: Fullscreen preview mode   
+
-qp, --qp      : Quantisation parameter. Use approximately 10-40. Default 0 (off)
‐n, ‐‐ nopreview : Do not display a preview window
+
-ih, --inline   : Insert inline headers (SPS, PPS) to stream
 
+
-sg, --segment  : Segment output file in to multiple files at specified interval <ms>
Image parameter commands  
+
-wr, --wrap    : In segment mode, wrap any numbered filename back to 1 when reach number
 
+
-sn, --start    : In segment mode, start with specified segment number
‐sh, ‐‐ sharpness : Set image sharpness ( ‐100  to 100)  
+
-sp, --split    : In wait mode, create new output file for each start event
‐co, ‐‐ contrast : Set image contrast ( ‐100  to 100)  
+
 
‐br, ‐‐ brightness: Set image brightness (0 to   100)  
+
 
‐sa, ‐‐ saturation: Set image saturation ( ‐100  to 100)  
+
H264 Profile options :
‐ISO, ‐‐ ISO    : Set capture ISO  
+
baseline,main,high
‐vs, ‐‐ vstab     : Turn on video stablisation 
+
 
‐ev, ‐‐ ev       : Set EV compensation (-10 to 10) - range corresponds to  -3 stops to +3 stops 
+
Preview parameter commands
‐ex, ‐‐ exposure : Set exposure mode (see Notes)  
+
 
‐awb, ‐‐ awb    : Set AWB mode (see Notes)  
+
-p, --preview  : Preview window settings <'x,y,w,h'>
‐ifx, ‐‐ imxfx   : Set image effect (see Notes)  
+
-f, --fullscreen       : Fullscreen preview mode
‐cfx, ‐‐ colfx   : Set colour effect (U:V)
+
-op, --opacity : Preview window opacity (0-255)
‐mm, ‐‐ metering : Set metering mode (see Notes)  
+
-n, --nopreview : Do not display a preview window
‐rot, ‐‐ rotation: Set image rotation (0 ‐359)  
+
 
‐hf, ‐‐ hflip     : Set horizontal flip
+
Image parameter commands
‐vf, ‐‐ vflip     : Set vertical flip   
+
 
 
+
-sh, --sharpness       : Set image sharpness (-100 to 100)
 
+
-co, --contrast : Set image contrast (-100 to 100)
Notes
+
-br, --brightness       : Set image brightness (0 to 100)
 
+
-sa, --saturation       : Set image saturation (-100 to 100)
Exposure mode options :  
+
-ISO, --ISO    : Set capture ISO
off,auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks  
+
-vs, --vstab   : Turn on video stabilisation
 
+
-ev, --ev       : Set EV compensation (-25 to 25)
AWB mode options :  
+
-ex, --exposure : Set exposure mode (see Notes)
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon  
+
-awb, --awb    : Set AWB mode (see Notes)
 
+
-ifx, --imxfx   : Set image effect (see Notes)
Image Effect mode options :  
+
-cfx, --colfx   : Set colour effect (U:V)
none,negative,solarise,sketch,denoise,emboss,oilpaint,h atch,gpen,pastel,watercolour,film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon
+
-mm, --metering : Set metering mode (see Notes)
 
+
-rot, --rotation       : Set image rotation (90,180,270)
Metering Mode options :  
+
-hf, --hflip   : Set horizontal flip
average,spot,backlit,matrix  
+
-vf, --vflip   : Set vertical flip
 +
-roi, --roi    : Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])
 +
-ss, --shutter : Set shutter speed in microseconds
 +
 
 +
 
 +
Notes
 +
 
 +
Exposure mode options :
 +
auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks
 +
 
 +
AWB mode options :
 +
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon
 +
 
 +
Image Effect mode options :
 +
none,negative,solarise,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolour,film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon
 +
 
 +
Metering Mode options :
 +
average,spot,backlit,matrix
 
</pre>
 
</pre>
  
 +
===RaspiStill===
 
<pre> 
 
<pre> 
RaspiStill Camera App  
+
RaspiStill Camera App v1.3.6 
 
===================== 
 
===================== 
 
+
Runs camera for specific time, and take JPG capture at end if requested
Runs camera for specific time, and take JPG capture at end if requested 
+
 
 
+
usage: raspistill [options]
usage:  RaspiStill  [options]  
+
 
 
+
Image parameter commands
Image  parameter commands  
+
 
 
+
-?, --help     : This help information
?,  ‐‐ help      :  This  help  information  
+
-w, --width    : Set image width <size>
‐w,  ‐‐ width     :  Set image  width <size>  
+
-h, --height   : Set image height <size>
‐h,  ‐‐ height    :  Set image  height  <size>  
+
-q, --quality   : Set jpeg quality <0 to 100>
‐q,  ‐‐ quality   :  Set jpeg  quality  <0 to  100> 
+
-r, --raw       : Add raw bayer data to jpeg metadata
‐r,  ‐‐ raw       :  Add  raw  bayer data  to  jpeg  metadata 
+
-o, --output   : Output filename <filename> (to write to stdout, use '-o -'). If not specified, no file is saved
‐o,  ‐‐ output    :  Output  filename  <filename>  (to write to  stdout,  use '‐o  ‐ ').  If  not specified,  no file is  saved 
+
-l, --latest    : Link latest complete image to filename <filename>
‐v,  ‐‐ verbose   :  Output   verbose information  during  run  
+
-v, --verbose  : Output verbose information during run
‐t,  ‐‐ timeout   :  Time (in ms) before  takes picture  and  shuts down (if  not specified,  set to  5s) 
+
-t, --timeout  : Time (in ms) before takes picture and shuts down (if not specified, set to 5s)
‐th, ‐‐ thumb     :  Set thumbnail parameters  (x:y:quality)  
+
                  minimum 30ms, setting to 0 waits forever.
‐d,  ‐‐ demo      :  Run  a  demo mode (cycle  through range of  camera options, no capture)  
+
-th, --thumb   : Set thumbnail parameters (x:y:quality) or none
‐e,  ‐‐ encoding  :  Encoding  to  use for output  file (jpg,  bmp, gif, png)  
+
-d, --demo      : Run a demo mode (cycle through range of camera options, no capture)
‐x,  ‐‐ exif      :  EXIF  tag to   apply to  captures  (forma t as  'key=value')  
+
-e, --encoding : Encoding to use for output file (jpg, bmp, gif, png)
‐tl,  ‐‐ timelapse:   Timelapse mode. Takes a  picture  every <t>ms  
+
-x, --exif      : EXIF tag to apply to captures (format as 'key=value') or none
 
+
-tl, --timelapse       : Timelapse mode. Takes a picture every <t>ms
Preview parameter commands  
+
-fp, --fullpreview      : Run the preview using the still capture resolution (may reduce preview fps)
 
+
-k, --keypress  : Wait between captures for a ENTER, X then ENTER to exit
‐p,  ‐‐ preview   :  Preview window settings <'x,y,w,h'> 
+
-s, --signal    : Wait between captures for a SIGUSR1 from another process
‐f,  ‐‐ fullscreen:  Fullscreen preview mode 
+
-g, --gl        : Draw preview to texture instead of using video render component
‐n,  ‐‐ nopreview :  Do not  display  a  preview window 
+
-gc, --glcapture        : Capture the GL frame-buffer instead of the camera image
 
+
 
Image  parameter commands  
+
Preview parameter commands
 
+
 
‐sh, ‐‐ sharpness :  Set image  sharpness ( ‐100  to  100)  
+
-p, --preview  : Preview window settings <'x,y,w,h'>
‐co, ‐‐ contrast  :  Set imag e  contrast ( ‐100  to  100)  
+
-f, --fullscreen       : Fullscreen preview mode
‐br, ‐‐ brightness:  Set image  brightness (0  to   100)  
+
-op, --opacity  : Preview window opacity (0-255)
‐sa, ‐‐ saturation:  Set image  saturation ( ‐100  to  100)  
+
-n, --nopreview : Do not display a preview window
‐ISO,  ‐‐ ISO     :  Set capture ISO  
+
 
‐vs, ‐‐ vstab     :  Turn  on  video stablisation  
+
Image parameter commands
‐ev, ‐‐ ev        :  Set EV compensation (-10 to 10) - range corresponds to  -3 stops to +3 stops
+
 
‐ex, ‐‐ exposure  :  Set exposure  mode (see  Notes)  
+
-sh, --sharpness        : Set image sharpness (-100 to 100)
‐awb,  ‐‐ awb     :  Set AWB mode (see  Notes)  
+
-co, --contrast : Set image contrast (-100 to 100)
‐ifx, ‐‐ imxfx    :  Set image  effect (see  Notes)  
+
-br, --brightness       : Set image brightness (0 to 100)
‐cfx, ‐‐ colfx    :  Set colour  effect (U:V) 
+
-sa, --saturation       : Set image saturation (-100 to 100)
‐mm,  ‐‐ metering :  Set metering mode (see  Notes)  
+
-ISO, --ISO     : Set capture ISO
‐rot,  ‐‐ rotation:  Set image  rotation (0 ‐359)  
+
-vs, --vstab    : Turn on video stabilisation
‐hf, ‐‐ hflip     :  Set horizontal flip 
+
-ev, --ev       : Set EV compensation (-25 to 25)
‐vf, ‐‐ vflip     :  Set vertical  flip 
+
-ex, --exposure : Set exposure mode (see Notes)
 
+
-awb, --awb     : Set AWB mode (see Notes)
 
+
-ifx, --imxfx  : Set image effect (see Notes)
Notes 
+
-cfx, --colfx   : Set colour effect (U:V)
 
+
-mm, --metering : Set metering mode (see Notes)
Exposure  mode options  :  
+
-rot, --rotation       : Set image rotation (90,180,270)
off,auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks  
+
-hf, --hflip   : Set horizontal flip
 
+
-vf, --vflip   : Set vertical flip
AWB mode options :  
+
-roi, --roi    : Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon  
+
-ss, --shutter  : Set shutter speed in microseconds
 
+
 
Image  Effect mode options :  
+
 
none,negative,solarise,sketch,denoise,emboss,oilpaint,h atch,gpen,pastel,watercolour,film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon 
+
Notes
 
+
 
Metering Mode options  :  
+
Exposure mode options :
average,spot,backlit,matrix 
+
auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks
 +
 
 +
AWB mode options :
 +
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon
 +
 
 +
Image Effect mode options :
 +
none,negative,solarise,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolour,
 +
film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon
 +
 
 +
Metering Mode options :
 +
average,spot,backlit,matrix
 +
 
 +
Preview parameter commands
 +
 
 +
-gs, --glscene  : GL scene square,teapot,mirror,yuv,sobel
 +
-gw, --glwin    : GL window settings <'x,y,w,h'>
 
</pre>
 
</pre>
  
Line 161: Line 233:
 
MP4Box -add filename.h264 filename.mp4
 
MP4Box -add filename.h264 filename.mp4
 
</pre>
 
</pre>
 +
 +
===Motion===
 +
There is a version of the security cam / motion-detection program 'motion' adapted for the R-Pi camera (motion-MMAL), written by user 'dozencrows'.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44966</ref>  Motion detection with still and video capture at a resolution of 1024x576 at 1 fps is possible, and several fps at lower resolutions. There is a blog post explaining how to set it up.<ref>http://rbnrpi.wordpress.com/project-list/setting-up-wireless-motion-detect-cam/</ref>  It is also possible to use the stock motion program (sudo apt-get install motion) with either of the two available V4L2 drivers.
 +
 +
===Video4Linux2===
 +
There is an unofficial Userspace Video4Linux2 (V4L2) driver.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=50639</ref><ref>http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14</ref><ref>http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=16</ref>  This allows use of the R-Pi camera with many standard Linux applications developed for USB webcams. Due to the Pi's ARMv6 cpu, lower resolutions and framerates are typical when compared with a modern desktop system.
 +
 +
There is an official kernel-space V4L2 driver in development, with a "beta" version available for testing from 2 Dec 2013.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=62364</ref>
 +
 +
===RAW images===
 +
The '''raspistill --raw''' option will append RAW data to the JPEG. The RAW data contains the image direct from the sensor, before debayer and color processing. A simple tool called '''raspi_dng'''<ref>https://github.com/illes/raspiraw</ref> is being developed<ref>http://bealecorner.org/best/RPi/</ref> to convert the JPEG+RAW file into a standard Adobe DNG file.
 +
 +
===Configuration===
 +
 +
The cameras red LED lights up when recording video or taking a still picture, this can be turned off by adding the following line to config.txt ([[RPiconfig]])
 +
 +
  disable_camera_led=1
 +
 +
It's possible to turn it back on at runtime by using GPIO5 <ref>http://www.raspberrypi-spy.co.uk/2013/05/how-to-disable-the-red-led-on-the-pi-camera-module/</ref>
  
 
==Known Issues==
 
==Known Issues==
  
* Still captures did not use the full sensor, until the firmware update on 24 May 2013.
+
* ISO can go to 1600 in 'night' or 'sports' mode, but can only be directly set via -ISO from 100 to 800.
* Images were 'flipped' (mirror image) by default, until the firmware update on 24 May 2013. (-hf and -vf options provide horizontal and vertical flips)
+
* exposure times longer than 6 seconds are not supported
* The -? (--help) did not work, until update on 24 May 2013.
 
* The -n (--nopreview) command-line options originally did not work until a recent firmware update.
 
* Correct EXIF data (including user supplied tags) are not being written to the output files.
 
  
This forum [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44879 post] summarizes the issues as at 24th May 2013
+
Prior to March 2014, video mode did not use the full sensor area (only a 1920x1080 center crop), and there was no video mode faster than 30 fps. With new firmware as of March 18 2014<ref>http://www.raspberrypi.org/new-camera-mode-released/</ref> the camera has a full-sensor 2x2 binned video mode, and also can do 640 x 480 up to 90 fps.
  
 
==Troubleshooting==
 
==Troubleshooting==
 +
 +
===Minimum GPU Memory===
 +
The camera requires a minimum GPU setting of 32M, with 128M advised
 +
 +
Setting GPU split to less (16M) is ignored and the GPU split increased to 128M
 +
 +
Raspistill etc will work when the GPU is set to 32M however
 +
(useful on low memory pi like 256M A+ )
 +
 +
 
===Camera not working at all===  
 
===Camera not working at all===  
 +
Example error message: "mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)"
 +
 +
 
Make sure the flex cable is inserted the correct way on both ends, and each connector has the locking tab engaged. The RPi + camera draws about 260 mA more current when recording video, than without the camera. The Model B is about 550 mA by itself, so camera use pushes it over 800 mA. Some power supplies, cables, and polyfuses may not maintain 5V onboard at this current load well enough for reliable operation. You can check this with a voltmeter across TP1 and TP2.<ref>http://elinux.org/R-Pi_Troubleshooting#Troubleshooting_power_problems</ref><ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43998#p350528</ref>
 
Make sure the flex cable is inserted the correct way on both ends, and each connector has the locking tab engaged. The RPi + camera draws about 260 mA more current when recording video, than without the camera. The Model B is about 550 mA by itself, so camera use pushes it over 800 mA. Some power supplies, cables, and polyfuses may not maintain 5V onboard at this current load well enough for reliable operation. You can check this with a voltmeter across TP1 and TP2.<ref>http://elinux.org/R-Pi_Troubleshooting#Troubleshooting_power_problems</ref><ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43998#p350528</ref>
  
In some cases, the micro-connector from the camera module to the camera board PCB has been loose, causing mis-operation. This has been fixed by removing and re-seating the small (tiny!) yellow flex cable connector labelled "P5V04A SUNNY" on the camera board.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=39996&start=100#p355172</ref>
+
In some cases, the micro-connector from the camera module to the camera board PCB has been loose. This can be fixed by removing and re-seating the small (tiny!) yellow flex cable connector labelled "P5V04A SUNNY" on the camera board. It makes a click when it is fully seated.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=39996&start=150#p373336</ref>  Note: before touching the camera board, make sure you are grounded, as the board is ESD sensitive (can be damaged by static shock).
 +
 
 +
This error message also appear if you forgot to configure the configuration file of the Raspberry. Just type: sudo raspi-config and choose "5- Enable camera" option then "Enable"
 +
 
 +
As of august 2014, with 2014-06-20-wheezy-raspbian.img, the firmware of a RPi B+ model needs to be updated :
 +
  $ sudo rpi-update
 +
 
 +
Here is a working version :
 +
<pre>
 +
$ vcgencmd version
 +
Aug 12 2014 18:21:28
 +
Copyright (c) 2012 Broadcom
 +
version f32b2bbfdea55d48c9a52b92e5c798f9aa5f47bc (tainted) (release)
 +
 
 +
$ uname -a
 +
Linux poopdeck 3.12.26+ #703 PREEMPT Tue Aug 12 18:13:52 BST 2014 armv6l GNU/Linux
 +
 
 +
$ cat /proc/cpuinfo  | grep Revision
 +
Revision : 0010
 +
</pre>
  
 
===Colored Banding or Flickering on video===  
 
===Colored Banding or Flickering on video===  
 
This can be caused by a poor power supply, or bad power cable. Several people have fixed this by replacing the power supply, or the microUSB power cable.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44863</ref><ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43982</ref>
 
This can be caused by a poor power supply, or bad power cable. Several people have fixed this by replacing the power supply, or the microUSB power cable.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44863</ref><ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43982</ref>
 +
 +
It can also be caused by indoor fluorescent lighting. The camera defaults to video mode at 30 fps, which works well in the USA with 60 Hz power. If you are in Europe or elsewhere with 50 Hz power, this may give you flicker under fluorescent lighting.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?t=43982&p=351090#p350434</ref> Try using the option '''-fps 25''' to change the frame rate to 25 frames per second.
 +
 +
==3rd party software==
 +
===BerryCam - iOS===
 +
 +
BerryCam enables you to use your iOS device to control the Raspberry Pi camera module.
 +
 +
A Python handler script is installed on the raspberry pi.
 +
 +
Control exposure modes, special effects for still images with the simple interface - no need to learn complex SSH commands.
 +
Preview your images on the iOS device and save to your camera roll. The same images are also saved to your Raspberry Pi.[http://www.fotosyn.com/berrycam-support/]
 +
 +
===Pi Sight - Android===
 +
Pi Sight is an Android application which allows you to control all the aspects of your Raspberry Pi camera.
 +
 +
It was inspired by BerryCam for iOS and has much of the same functionality. You can control exposure modes, image effects, white balance, image size and quality and pretty much every other parameter that can be accessed when using the camera on the command line.
 +
It also uses the same Python handler script on the Raspberry Pi as BerryCam [http://www.pi-supply.com/pi-sight]
 +
 +
===RaspiCam Remote - Android===
 +
RaspiCam Remote is an app to view the Raspberry Pi camera module on your Android Device.
 +
 +
Unlike other apps, no software needs to be installed or configured on the Raspberry Pi - simply type in the ip address of the Pi.
 +
It also allows use of USB cameras.
 +
 +
Continuous 30fps h264 streeaming for camera monitoring on your android device, and live view of the various image effects. [https://play.google.com/store/apps/details?id=com.pibits.raspberrypiremotecam&hl=en_GB]
 +
 +
===Pi Vision - Raspberry Pi===
 +
 +
Pi Vision is a GUI based controller for the Raspberry Pi camera module which runs on your Raspberry Pi. [http://heywhatsthebigidea.net/projects/pi-vision-a-raspberry-pi-camera-controller/]
 +
 +
===PiKrellCam===
 +
 +
View and control RPi camera through web browser on remote PC, tablet, or phone with live MJPEG preview. Timelapse and mp4 video recording on manual trigger or on motion-detection. Uses true motion vectors from encoder for more effective motion detection than traditional average-frame-difference methods. [https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=115583]
 +
 +
===picamera===
 +
 +
The picamera library is a pure Python library for controlling the Raspberry Pi camera module. It is available for installation from the Raspbian repository (as python-picamera) or from [http://pypi.python.org/pypi/picamera/ PyPI] (for non-Raspbian distros). [http://picamera.readthedocs.org/]
  
 
==Customizing==
 
==Customizing==
 
===Changing the ribbon cable===
 
===Changing the ribbon cable===
The ribbon cable that connects the camera board to the Pi is 15-core 1mm pitch ribbon cable.  In the UK they can be sourced from http://www.toby.co.uk/content/catalogue/products.aspx?series=FFCx-xx-A-xx-xx where the required type is FFC1-15-B150105160MM<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p352401</ref>. Other suppliers have been noted on eBay.
+
The ribbon cable that connects the camera board to the Pi is 15-core 1mm pitch ribbon cable, with alternate end contacts (top side / bottom side)ModMyPi stock [https://www.modmypi.com/raspberry-pi-camera/replacement-raspberry-pi-camera-cable-150mm Replacement Raspberry Pi Camera Cables] for £1.99 and have worldwide shipping. In the UK they can also be sourced from [http://www.toby.co.uk/content/catalogue/products.aspx?series=FFCx-xx-A-xx-xx Toby Electronics] where the required type is FFC1-15-B150105160MM<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p352401</ref>.   Other suppliers have been noted on eBay.
  
The Foundation has noted that the camera only passed EMI emissions testing with ribbon cable lengths of 15cm, although longer cables may also work.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p348917</ref>
+
The Foundation has noted that the camera only passed EMI emissions testing with ribbon cable lengths of 15cm, although longer cables may also work.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p348917</ref> One user 'rew' reports a 4 m (13 foot) extension cable is working.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p362714</ref><ref>http://www.bitwizard.nl/catalog/product_info.php?products_id=146</ref>
 +
 
 +
A quick guide on [https://www.modmypi.com/blog/how-to-replace-the-raspberry-pi-camera-cable how to replace the raspberry pi camera cable] is available on the ModMyPi tutorials.
  
 
===Adjusting Lens Focus===
 
===Adjusting Lens Focus===
The camera is fixed-focus (at infinity) as delivered. The thread-locking glue dots can be scraped off<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=225#p346170</ref> allowing manual lens focus, as close as 6 cm, or complete removal of the lens<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=325#p352613</ref> allowing other optical systems. The lens thread size may be M6 x 0.35<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=46637&p=367053#p367053</ref>.
+
The v1 camera is fixed-focus (at infinity) as delivered. The thread-locking glue dots can be scraped off<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=225#p346170</ref> allowing manual lens focus, as close as 2.5 cm.  A special purpose tool<ref>http://www.thingiverse.com/thing:1570865</ref> may help. To change the focus to '''FL''' cm, unscrew the lens (turn counter-clockwise) by '''D''' degrees, where D = 360 * (3.5 cm / FL).  For example, to focus at 10 cm, unscrew lens 360 * (3.5 / 10) = 126 degrees. Values are approximate<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=46637#p366719</ref>.
 +
The closest achievable focus is about 25 mm, after unscrewing the lens roughly 2 full turns.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=60828&p=454021#p454021</ref> At this point it is loose and must be held in place by other means.
  
===Macro, Wide, Tele lenses===
+
Unscrewing more than 2 turns results in removal of the lens<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=325#p352613</ref> allowing use of other optical systems. The lens thread size is believed to be M6 x 0.35<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=46637&p=367053#p367053</ref>.
 +
 
 +
The v2.1 camera was preset to focus closer than infinity, unlike the v1 camera. There have been reports of success refocusing it by turning the lens with a cut-up credit card tool<ref>https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200#p971545</ref> or 3D printed tool<ref>http://www.thingiverse.com/thing:1574661</ref>.  Later production of V2.1 changed to the lens to be at or near infinity.<ref>https://www.raspberrypi.org/blog/camera-board-comparisons-pi-noir-v1-vs-pi-noir-v2/#comment-1259481</ref> At least one supplier in 2018 includes a small plastic lens adjuster / refocusing tool with the Pi v2.1 camera.
 +
 
 +
===Macro, Wide, Tele adaptor lenses===
 
The near focus point of the camera is about 1 meter as delivered. Without modification to the camera itself, it is possible to put a simple external lens in front such as reading glasses, SLR diopter ("close-up filter") or loupe to enable closer focus. For best results, put the additional lens very close to the camera lens.  
 
The near focus point of the camera is about 1 meter as delivered. Without modification to the camera itself, it is possible to put a simple external lens in front such as reading glasses, SLR diopter ("close-up filter") or loupe to enable closer focus. For best results, put the additional lens very close to the camera lens.  
  
Macro, Wide-Angle, and Telephoto adapter lenses designed for the iPhone 4/4s and similar devices will also work on the R-Pi camera. Depending on your configuration, properly mounting the accessory lens in front of the camera module may require some ingenuity.  Focus becomes critical with a telephoto adapter, so success there may also require the manual focus modification.
+
Macro, Wide-Angle, and Telephoto adapter lenses designed for smartphone cameras will also work on the R-Pi camera. Depending on your configuration, properly mounting the accessory lens in front of the camera module may require some ingenuity.  Focus becomes critical with a telephoto adapter, so success there may also require the manual focus modification.
 +
 
 +
===Replacing Stock Lens===
 +
Changing the lens is a more significant and risky modification than simply adding an accessory lens.
 +
Richard Kinch has made an adaptor to mount M12 thread lenses on the R-Pi camera board, after unscrewing and removing the stock lens.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?t=45887</ref><ref>http://www.truetex.com/raspberry_pi_m12_lens_adapter.pdf</ref> Martin Miller has posted a guide on raspberrytorte.com describing complete camera module disassembly and replacing lens holder with a stock M12 unit.<ref>http://wiki.raspberrytorte.com/index.php?title=Camera_Module_Lens_Modifcation</ref> Various M12 x 0.5 (S-mount) lenses intended for board-level cameras are available at focal lengths from fisheye to long telephoto.<ref>http://www.solino.com/cms/index.php?article_id=193&clang=0</ref><ref>http://www.m12lenses.com/M12-Mount-Mega-Pixel-Lenses-s/21.htm</ref><ref>http://www.net-gmbh.com/en/s-mount.html</ref>  Various unofficial, 3rd party versions of RPi-compatible camera boards are available online which feature a M12 lens housing.
  
 
===Removing IR Filter===
 
===Removing IR Filter===
The IR filter is rigid and glued to the bottom inside of the black plastic lens housing, requiring complete disassembly to remove. Two early attempts by RPi forum users M33P<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339#p352586</ref> and scorp<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339#p352902</ref> were initially successful, but in both cases the camera died soon afterwards from blunt trauma to the fragile bond wires on the die.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339</ref>
+
''('''NOTE:''' Since release of the official Pi-NoIR version at the same price, this is of mostly historical interest.)''
 
+
The IR filter is rigid and glued to the bottom inside of the black plastic lens housing, requiring complete disassembly to remove. Two early attempts by RPi forum users M33P<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339#p352586</ref> and scorp<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339#p352902</ref> were initially successful, but in both cases the camera died soon afterwards from blunt trauma to the fragile bond wires on the die.<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339</ref> A RPi blog post (27 May 2013) has more description of this process with a video of the modification, and video from the resulting IR-enabled camera.<ref>http://www.raspberrypi.org/archives/4088</ref>
A RPi blog post (27 May 2013) has more description of this process with a video of the modification, and video from the resulting IR-enabled camera.<ref>http://www.raspberrypi.org/archives/4088</ref>
 
  
 
===Housings===
 
===Housings===
To help building your own enclosure, a hand-measured mechanical drawing<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44466</ref> of the camera module is available, thanks to Gert van Loo. There is another drawing<ref>http://www.raspberrypi-spy.co.uk/2013/05/pi-camera-module-mechanical-dimensions/</ref> from raspberrypi-spy.
+
To help building your own camera board case or enclosure, a hand-measured mechanical drawing<ref>http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44466</ref> of the camera module is available, thanks to Gert van Loo. There is another drawing<ref>http://www.raspberrypi-spy.co.uk/2013/05/pi-camera-module-mechanical-dimensions/</ref> from raspberrypi-spy.
 
There are some CAD files for housings and camera holders available on Thingiverse<ref>http://www.thingiverse.com/search?q=raspberry+pi+camera&sa=</ref>.
 
There are some CAD files for housings and camera holders available on Thingiverse<ref>http://www.thingiverse.com/search?q=raspberry+pi+camera&sa=</ref>.
  
 
==References==
 
==References==
 
<references/>
 
<references/>

Latest revision as of 17:23, 6 December 2018


RaspPi.png Back to the Hub


Hardware & Peripherals:

Hardware - detailed information about the Raspberry Pi boards.

Hardware History - guide to the Raspberry Pi models.

Low-level Peripherals - using the GPIO and other connectors.

Expansion Boards - GPIO plug-in boards providing additional functionality.

Screens - attaching a screen to the Raspberry Pi.

Cases - lots of nice cases to protect the Raspberry Pi.

Other Peripherals - all sorts of peripherals used with the Raspberry Pi.


Introduction

Raspberry Pi Camera v1
Pi NoIR v1

The Raspberry Pi camera board v.1 has a 5 MPixel sensor, and connects via a ribbon cable to the CSI connector on the Raspberry Pi. A User's Guide describes setup and use. The video and still image quality is better than a USB webcam of similar price. It was released for sale on 14 May 2013[1].

The "Pi NoIR" version of the v.1 camera was released on 28 October 2013. It has the same sensor with the IR filter removed, and a black PCB.[2] With no IR filter, it can see near-IR wavelengths (700 - 1000 nm) like a security camera, with the tradeoff of poor color rendition. It is otherwise the same and uses the same software as the normal Pi camera.

The "Pi Camera v2.1" was released 25 April 2016, in both normal and NoIR versions [3]. It uses the Sony IMX219 8-megapixel sensor with a slightly wider (62 degrees H) and faster (f/2.0) lens. The board is the same 25 x 24 mm size, and is intended as a drop-in replacement for the previous camera.

Initial production of v2.1 camera boards have lens focus set closer than v.1 (infinity)[4]. This can be modified. Later production was set at infinity [5].

Technical Parameters (v.1 board)

  • Sensor type: OmniVision OV5647[6] Color CMOS QSXGA (5-megapixel)
  • Sensor size: 3.67 x 2.74 mm (1/4" format)
  • Pixel Count: 2592 x 1944
  • Pixel Size: 1.4 x 1.4 um
  • Lens: f=3.6 mm, f/2.9
  • Angle of View: 54 x 41 degrees
  • Field of View: 2.0 x 1.33 m at 2 m
  • Full-frame SLR lens equivalent: 35 mm
  • Fixed Focus: 1 m to infinity
  • Video: 1080p at 30 fps with codec H.264 (AVC)
  • Up to 90 fps Video at VGA
  • Board size: 25 x 24 mm (not including flex cable)
  • Test Fixture Holes: 4x D=2.15 mm on 12.5 x 21.0 mm centers

Because the focal length of the lens is roughly the same as the width of the sensor, it is easy to remember the field of view: at x meters away, you can see about x meters horizontally, assuming 4x3 stills mode. Horizontal field of view in 1080p video mode is 75% of that (75% H x 55% V sensor crop for 1:1 pixels at 1920x1080).

References: Focal length and f-stop measurements [1],[2] depth of field & angle of view calculators[3] sensor info[4] f-stop measurement[5] Spectral response curves [6]

Pi NoIR v2.1

Technical Parameters (v.2 board)

  • Sensor type: Sony IMX219PQ[7] Color CMOS 8-megapixel
  • Sensor size: 3.674 x 2.760 mm (1/4" format)
  • Pixel Count: 3280 x 2464 (active pixels) 3296 x 2512 (total pixels)
  • Pixel Size: 1.12 x 1.12 um
  • Lens: f=3.04 mm, f/2.0
  • Angle of View: 62.2 x 48.8 degrees
  • Full-frame SLR lens equivalent: 29 mm
  • Video Modes:
  • 1 - 1080P30 cropped (680 pixels off left/right, 692 pixels off top/bottom), up to 30fps
  • 2 - 3240x2464 Full 4:3, up to 15fps
  • 3 - 3240x2464 Full 4:3, up to 15fps (identical to 2)
  • 4 - 1640x1232 binned 4:3, up 40fps
  • 5 - 1640x922 2x2 binned 16:9 (310 px crop T/B before binning), up to 40fps
  • 6 - 720P bin+crop (360 px L/R, 512 px T/B before binning), 40..90fps (OC: 120fps)
  • 7 - VGA bin+crop (1000 px L/R, 752 px T/B before binning), 40..90fps (OC: 120fps)
  • Board size: 25 x 23.86 x 9mm
  • Mounting Holes: 4x D=2.20 mm on 12.5 x 21.0 mm centers

References: Semi-official v.2 thread:[7] Sony IMX219 product brief:[8] Crypto chip:[9] Measured response curves:[10]

Sample Programs

Sample programs using the camera for taking stills and video have been developed for the Foundation. There is a User's Guide and the source for these programs is available on github.

Forum user M1M1 published instructions on compiling the sample programs here

The command line parameters for the programs are as follows:

RaspiVid

RaspiVid Camera App v1.3.9
===================  
Display camera output to display, and optionally saves an H264 capture at requested bitrate

usage: raspivid [options]

Image parameter commands

-?, --help      : This help information
-w, --width     : Set image width <size>. Default 1920
-h, --height    : Set image height <size>. Default 1080
-b, --bitrate   : Set bitrate. Use bits per second (e.g. 10MBits/s would be -b 10000000)
-o, --output    : Output filename <filename> (to write to stdout, use '-o -')
-v, --verbose   : Output verbose information during run
-t, --timeout   : Time (in ms) to capture for. If not specified, set to 5s. Zero to disable
-d, --demo      : Run a demo mode (cycle through range of camera options, no capture)
-fps, --framerate       : Specify the frames per second to record
-e, --penc      : Display preview image *after* encoding (shows compression artifacts)
-g, --intra     : Specify the intra refresh period (key frame rate/GoP size)
-pf, --profile  : Specify H264 profile to use for encoding
-td, --timed    : Cycle between capture and pause. -cycle on,off where on is record time and off is pause time in ms
-s, --signal    : Cycle between capture and pause on Signal
-k, --keypress  : Cycle between capture and pause on ENTER
-i, --initial   : Initial state. Use 'record' or 'pause'. Default 'record'
-qp, --qp       : Quantisation parameter. Use approximately 10-40. Default 0 (off)
-ih, --inline   : Insert inline headers (SPS, PPS) to stream
-sg, --segment  : Segment output file in to multiple files at specified interval <ms>
-wr, --wrap     : In segment mode, wrap any numbered filename back to 1 when reach number
-sn, --start    : In segment mode, start with specified segment number
-sp, --split    : In wait mode, create new output file for each start event


H264 Profile options :
baseline,main,high

Preview parameter commands

-p, --preview   : Preview window settings <'x,y,w,h'>
-f, --fullscreen        : Fullscreen preview mode
-op, --opacity  : Preview window opacity (0-255)
-n, --nopreview : Do not display a preview window

Image parameter commands

-sh, --sharpness        : Set image sharpness (-100 to 100)
-co, --contrast : Set image contrast (-100 to 100)
-br, --brightness       : Set image brightness (0 to 100)
-sa, --saturation       : Set image saturation (-100 to 100)
-ISO, --ISO     : Set capture ISO
-vs, --vstab    : Turn on video stabilisation
-ev, --ev       : Set EV compensation (-25 to 25)
-ex, --exposure : Set exposure mode (see Notes)
-awb, --awb     : Set AWB mode (see Notes)
-ifx, --imxfx   : Set image effect (see Notes)
-cfx, --colfx   : Set colour effect (U:V)
-mm, --metering : Set metering mode (see Notes)
-rot, --rotation        : Set image rotation (90,180,270)
-hf, --hflip    : Set horizontal flip
-vf, --vflip    : Set vertical flip
-roi, --roi     : Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])
-ss, --shutter  : Set shutter speed in microseconds


Notes

Exposure mode options :
auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks

AWB mode options :
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon

Image Effect mode options :
none,negative,solarise,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolour,film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon

Metering Mode options :
average,spot,backlit,matrix  

RaspiStill

 
RaspiStill Camera App v1.3.6 
===================== 
Runs camera for specific time, and take JPG capture at end if requested

usage: raspistill [options]

Image parameter commands

-?, --help      : This help information
-w, --width     : Set image width <size>
-h, --height    : Set image height <size>
-q, --quality   : Set jpeg quality <0 to 100>
-r, --raw       : Add raw bayer data to jpeg metadata
-o, --output    : Output filename <filename> (to write to stdout, use '-o -'). If not specified, no file is saved
-l, --latest    : Link latest complete image to filename <filename>
-v, --verbose   : Output verbose information during run
-t, --timeout   : Time (in ms) before takes picture and shuts down (if not specified, set to 5s)
                  minimum 30ms, setting to 0 waits forever.
-th, --thumb    : Set thumbnail parameters (x:y:quality) or none
-d, --demo      : Run a demo mode (cycle through range of camera options, no capture)
-e, --encoding  : Encoding to use for output file (jpg, bmp, gif, png)
-x, --exif      : EXIF tag to apply to captures (format as 'key=value') or none
-tl, --timelapse        : Timelapse mode. Takes a picture every <t>ms
-fp, --fullpreview      : Run the preview using the still capture resolution (may reduce preview fps)
-k, --keypress  : Wait between captures for a ENTER, X then ENTER to exit
-s, --signal    : Wait between captures for a SIGUSR1 from another process
-g, --gl        : Draw preview to texture instead of using video render component
-gc, --glcapture        : Capture the GL frame-buffer instead of the camera image

Preview parameter commands

-p, --preview   : Preview window settings <'x,y,w,h'>
-f, --fullscreen        : Fullscreen preview mode
-op, --opacity  : Preview window opacity (0-255)
-n, --nopreview : Do not display a preview window

Image parameter commands

-sh, --sharpness        : Set image sharpness (-100 to 100)
-co, --contrast : Set image contrast (-100 to 100)
-br, --brightness       : Set image brightness (0 to 100)
-sa, --saturation       : Set image saturation (-100 to 100)
-ISO, --ISO     : Set capture ISO
-vs, --vstab    : Turn on video stabilisation
-ev, --ev       : Set EV compensation (-25 to 25)
-ex, --exposure : Set exposure mode (see Notes)
-awb, --awb     : Set AWB mode (see Notes)
-ifx, --imxfx   : Set image effect (see Notes)
-cfx, --colfx   : Set colour effect (U:V)
-mm, --metering : Set metering mode (see Notes)
-rot, --rotation        : Set image rotation (90,180,270)
-hf, --hflip    : Set horizontal flip
-vf, --vflip    : Set vertical flip
-roi, --roi     : Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])
-ss, --shutter  : Set shutter speed in microseconds


Notes

Exposure mode options :
auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks

AWB mode options :
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon

Image Effect mode options :
none,negative,solarise,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolour,
film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon

Metering Mode options :
average,spot,backlit,matrix

Preview parameter commands

-gs, --glscene  : GL scene square,teapot,mirror,yuv,sobel
-gw, --glwin    : GL window settings <'x,y,w,h'>

The raspivid utility saves .h264 format files. Some programs need this in a .mp4 wrapper to use, which you can do in several ways. One is to use "MP4Box" which is in the 'gpac' package.

sudo apt-get update
sudo apt-get install gpac

MP4Box -add filename.h264 filename.mp4

Motion

There is a version of the security cam / motion-detection program 'motion' adapted for the R-Pi camera (motion-MMAL), written by user 'dozencrows'.[8] Motion detection with still and video capture at a resolution of 1024x576 at 1 fps is possible, and several fps at lower resolutions. There is a blog post explaining how to set it up.[9] It is also possible to use the stock motion program (sudo apt-get install motion) with either of the two available V4L2 drivers.

Video4Linux2

There is an unofficial Userspace Video4Linux2 (V4L2) driver.[10][11][12] This allows use of the R-Pi camera with many standard Linux applications developed for USB webcams. Due to the Pi's ARMv6 cpu, lower resolutions and framerates are typical when compared with a modern desktop system.

There is an official kernel-space V4L2 driver in development, with a "beta" version available for testing from 2 Dec 2013.[13]

RAW images

The raspistill --raw option will append RAW data to the JPEG. The RAW data contains the image direct from the sensor, before debayer and color processing. A simple tool called raspi_dng[14] is being developed[15] to convert the JPEG+RAW file into a standard Adobe DNG file.

Configuration

The cameras red LED lights up when recording video or taking a still picture, this can be turned off by adding the following line to config.txt (RPiconfig)

 disable_camera_led=1

It's possible to turn it back on at runtime by using GPIO5 [16]

Known Issues

  • ISO can go to 1600 in 'night' or 'sports' mode, but can only be directly set via -ISO from 100 to 800.
  • exposure times longer than 6 seconds are not supported

Prior to March 2014, video mode did not use the full sensor area (only a 1920x1080 center crop), and there was no video mode faster than 30 fps. With new firmware as of March 18 2014[17] the camera has a full-sensor 2x2 binned video mode, and also can do 640 x 480 up to 90 fps.

Troubleshooting

Minimum GPU Memory

The camera requires a minimum GPU setting of 32M, with 128M advised

Setting GPU split to less (16M) is ignored and the GPU split increased to 128M

Raspistill etc will work when the GPU is set to 32M however (useful on low memory pi like 256M A+ )


Camera not working at all

Example error message: "mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)"


Make sure the flex cable is inserted the correct way on both ends, and each connector has the locking tab engaged. The RPi + camera draws about 260 mA more current when recording video, than without the camera. The Model B is about 550 mA by itself, so camera use pushes it over 800 mA. Some power supplies, cables, and polyfuses may not maintain 5V onboard at this current load well enough for reliable operation. You can check this with a voltmeter across TP1 and TP2.[18][19]

In some cases, the micro-connector from the camera module to the camera board PCB has been loose. This can be fixed by removing and re-seating the small (tiny!) yellow flex cable connector labelled "P5V04A SUNNY" on the camera board. It makes a click when it is fully seated.[20] Note: before touching the camera board, make sure you are grounded, as the board is ESD sensitive (can be damaged by static shock).

This error message also appear if you forgot to configure the configuration file of the Raspberry. Just type: sudo raspi-config and choose "5- Enable camera" option then "Enable"

As of august 2014, with 2014-06-20-wheezy-raspbian.img, the firmware of a RPi B+ model needs to be updated :

 $ sudo rpi-update

Here is a working version :

$ vcgencmd version
Aug 12 2014 18:21:28 
Copyright (c) 2012 Broadcom
version f32b2bbfdea55d48c9a52b92e5c798f9aa5f47bc (tainted) (release)

$ uname -a
Linux poopdeck 3.12.26+ #703 PREEMPT Tue Aug 12 18:13:52 BST 2014 armv6l GNU/Linux

$ cat /proc/cpuinfo  | grep Revision
Revision	: 0010

Colored Banding or Flickering on video

This can be caused by a poor power supply, or bad power cable. Several people have fixed this by replacing the power supply, or the microUSB power cable.[21][22]

It can also be caused by indoor fluorescent lighting. The camera defaults to video mode at 30 fps, which works well in the USA with 60 Hz power. If you are in Europe or elsewhere with 50 Hz power, this may give you flicker under fluorescent lighting.[23] Try using the option -fps 25 to change the frame rate to 25 frames per second.

3rd party software

BerryCam - iOS

BerryCam enables you to use your iOS device to control the Raspberry Pi camera module.

A Python handler script is installed on the raspberry pi.

Control exposure modes, special effects for still images with the simple interface - no need to learn complex SSH commands. Preview your images on the iOS device and save to your camera roll. The same images are also saved to your Raspberry Pi.[11]

Pi Sight - Android

Pi Sight is an Android application which allows you to control all the aspects of your Raspberry Pi camera.

It was inspired by BerryCam for iOS and has much of the same functionality. You can control exposure modes, image effects, white balance, image size and quality and pretty much every other parameter that can be accessed when using the camera on the command line. It also uses the same Python handler script on the Raspberry Pi as BerryCam [12]

RaspiCam Remote - Android

RaspiCam Remote is an app to view the Raspberry Pi camera module on your Android Device.

Unlike other apps, no software needs to be installed or configured on the Raspberry Pi - simply type in the ip address of the Pi. It also allows use of USB cameras.

Continuous 30fps h264 streeaming for camera monitoring on your android device, and live view of the various image effects. [13]

Pi Vision - Raspberry Pi

Pi Vision is a GUI based controller for the Raspberry Pi camera module which runs on your Raspberry Pi. [14]

PiKrellCam

View and control RPi camera through web browser on remote PC, tablet, or phone with live MJPEG preview. Timelapse and mp4 video recording on manual trigger or on motion-detection. Uses true motion vectors from encoder for more effective motion detection than traditional average-frame-difference methods. [15]

picamera

The picamera library is a pure Python library for controlling the Raspberry Pi camera module. It is available for installation from the Raspbian repository (as python-picamera) or from PyPI (for non-Raspbian distros). [16]

Customizing

Changing the ribbon cable

The ribbon cable that connects the camera board to the Pi is 15-core 1mm pitch ribbon cable, with alternate end contacts (top side / bottom side). ModMyPi stock Replacement Raspberry Pi Camera Cables for £1.99 and have worldwide shipping. In the UK they can also be sourced from Toby Electronics where the required type is FFC1-15-B150105160MM[24]. Other suppliers have been noted on eBay.

The Foundation has noted that the camera only passed EMI emissions testing with ribbon cable lengths of 15cm, although longer cables may also work.[25] One user 'rew' reports a 4 m (13 foot) extension cable is working.[26][27]

A quick guide on how to replace the raspberry pi camera cable is available on the ModMyPi tutorials.

Adjusting Lens Focus

The v1 camera is fixed-focus (at infinity) as delivered. The thread-locking glue dots can be scraped off[28] allowing manual lens focus, as close as 2.5 cm. A special purpose tool[29] may help. To change the focus to FL cm, unscrew the lens (turn counter-clockwise) by D degrees, where D = 360 * (3.5 cm / FL). For example, to focus at 10 cm, unscrew lens 360 * (3.5 / 10) = 126 degrees. Values are approximate[30]. The closest achievable focus is about 25 mm, after unscrewing the lens roughly 2 full turns.[31] At this point it is loose and must be held in place by other means.

Unscrewing more than 2 turns results in removal of the lens[32] allowing use of other optical systems. The lens thread size is believed to be M6 x 0.35[33].

The v2.1 camera was preset to focus closer than infinity, unlike the v1 camera. There have been reports of success refocusing it by turning the lens with a cut-up credit card tool[34] or 3D printed tool[35]. Later production of V2.1 changed to the lens to be at or near infinity.[36] At least one supplier in 2018 includes a small plastic lens adjuster / refocusing tool with the Pi v2.1 camera.

Macro, Wide, Tele adaptor lenses

The near focus point of the camera is about 1 meter as delivered. Without modification to the camera itself, it is possible to put a simple external lens in front such as reading glasses, SLR diopter ("close-up filter") or loupe to enable closer focus. For best results, put the additional lens very close to the camera lens.

Macro, Wide-Angle, and Telephoto adapter lenses designed for smartphone cameras will also work on the R-Pi camera. Depending on your configuration, properly mounting the accessory lens in front of the camera module may require some ingenuity. Focus becomes critical with a telephoto adapter, so success there may also require the manual focus modification.

Replacing Stock Lens

Changing the lens is a more significant and risky modification than simply adding an accessory lens. Richard Kinch has made an adaptor to mount M12 thread lenses on the R-Pi camera board, after unscrewing and removing the stock lens.[37][38] Martin Miller has posted a guide on raspberrytorte.com describing complete camera module disassembly and replacing lens holder with a stock M12 unit.[39] Various M12 x 0.5 (S-mount) lenses intended for board-level cameras are available at focal lengths from fisheye to long telephoto.[40][41][42] Various unofficial, 3rd party versions of RPi-compatible camera boards are available online which feature a M12 lens housing.

Removing IR Filter

(NOTE: Since release of the official Pi-NoIR version at the same price, this is of mostly historical interest.) The IR filter is rigid and glued to the bottom inside of the black plastic lens housing, requiring complete disassembly to remove. Two early attempts by RPi forum users M33P[43] and scorp[44] were initially successful, but in both cases the camera died soon afterwards from blunt trauma to the fragile bond wires on the die.[45] A RPi blog post (27 May 2013) has more description of this process with a video of the modification, and video from the resulting IR-enabled camera.[46]

Housings

To help building your own camera board case or enclosure, a hand-measured mechanical drawing[47] of the camera module is available, thanks to Gert van Loo. There is another drawing[48] from raspberrypi-spy. There are some CAD files for housings and camera holders available on Thingiverse[49].

References

  1. http://www.raspberrypi.org/archives/3890
  2. http://www.raspberrypi.org/archives/5128
  3. https://www.raspberrypi.org/blog/new-8-megapixel-camera-board-sale-25/
  4. https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200#p971091
  5. https://www.raspberrypi.org/blog/camera-board-comparisons-pi-noir-v1-vs-pi-noir-v2/#comment-1259481
  6. http://www.ovt.com/products/sensor.php?id=66
  7. http://www.sony.net/Products/SC-HP/new_pro/april_2014/imx219_e.html
  8. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44966
  9. http://rbnrpi.wordpress.com/project-list/setting-up-wireless-motion-detect-cam/
  10. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=50639
  11. http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14
  12. http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=16
  13. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=62364
  14. https://github.com/illes/raspiraw
  15. http://bealecorner.org/best/RPi/
  16. http://www.raspberrypi-spy.co.uk/2013/05/how-to-disable-the-red-led-on-the-pi-camera-module/
  17. http://www.raspberrypi.org/new-camera-mode-released/
  18. http://elinux.org/R-Pi_Troubleshooting#Troubleshooting_power_problems
  19. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43998#p350528
  20. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=39996&start=150#p373336
  21. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44863
  22. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43982
  23. http://www.raspberrypi.org/phpBB3/viewtopic.php?t=43982&p=351090#p350434
  24. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p352401
  25. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p348917
  26. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=43737#p362714
  27. http://www.bitwizard.nl/catalog/product_info.php?products_id=146
  28. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=225#p346170
  29. http://www.thingiverse.com/thing:1570865
  30. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=46637#p366719
  31. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=60828&p=454021#p454021
  32. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=32605&start=325#p352613
  33. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=46637&p=367053#p367053
  34. https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200#p971545
  35. http://www.thingiverse.com/thing:1574661
  36. https://www.raspberrypi.org/blog/camera-board-comparisons-pi-noir-v1-vs-pi-noir-v2/#comment-1259481
  37. http://www.raspberrypi.org/phpBB3/viewtopic.php?t=45887
  38. http://www.truetex.com/raspberry_pi_m12_lens_adapter.pdf
  39. http://wiki.raspberrytorte.com/index.php?title=Camera_Module_Lens_Modifcation
  40. http://www.solino.com/cms/index.php?article_id=193&clang=0
  41. http://www.m12lenses.com/M12-Mount-Mega-Pixel-Lenses-s/21.htm
  42. http://www.net-gmbh.com/en/s-mount.html
  43. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339#p352586
  44. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339#p352902
  45. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44339
  46. http://www.raspberrypi.org/archives/4088
  47. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44466
  48. http://www.raspberrypi-spy.co.uk/2013/05/pi-camera-module-mechanical-dimensions/
  49. http://www.thingiverse.com/search?q=raspberry+pi+camera&sa=