Rpi Camera Module
The Raspberry Pi cameraboard v.1 has a 5 MPixel sensor, and connects via a ribbon cable to the CSIconnector on the Raspberry Pi. A
User's Guide describessetup and use. The video and still image quality is better than a USB webcam ofsimilar 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 samesensor with the IR filter removed, and a black PCB.
[2] With no IR filter, it can see near-IRwavelengths (700 - 1000 nm) like a security camera, with the tradeoff of poorcolor rendition. It is otherwise the same and uses the same software as thenormal Pi camera.
The "Pi Camerav2.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 intendedas a drop-in replacement for the previous camera.
The v2.1 camera boardshave lens focus set closer than v.1 (infinity)
[4].This can be
modified.
TechnicalParameters (v.1 board)
· Sensortype: OmniVision OV5647
[5] Color CMOS QSXGA (5-megapixel)
· Sensorsize: 3.67 x 2.74 mm (1/4" format)
· PixelCount: 2592 x 1944
· PixelSize: 1.4 x 1.4 um
· Lens:f=3.6 mm, f/2.9
· Angle ofView: 54 x 41 degrees
· Field ofView: 2.0 x 1.33 m at 2 m
· Full-frameSLR lens equivalent: 35 mm
· FixedFocus: 1 m to infinity
· Video:1080p at 30 fps with codec H.264 (AVC)
· Up to 90fps Video at VGA
· Boardsize: 25 x 24 mm (not including flex cable)
· TestFixture Holes: 4x D=2.15 mm on 12.5 x 21.0 mm centers
Because the focal length of the lens is roughly the sameas the width of the sensor, it is easy to remember the field of view: at x metersaway, you can see about x meters horizontally, assuming 4x3 stills mode. Horizontalfield of view in 1080p video mode is 75% of that (75% H x 55% V sensor crop for1:1 pixels at 1920x1080).
References: Focallength 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] TechnicalParameters (v.2 board)
· Sensortype: Sony IMX219PQ
[6] Color CMOS 8-megapixel
· Sensorsize: 3.674 x 2.760 mm (1/4" format)
· PixelCount: 3280 x 2464 (active pixels) 3296 x 2512 (total pixels)
· PixelSize: 1.12 x 1.12 um
· Lens:f=3.04 mm, f/2.0
· Angle ofView: 62.2 x 48.8 degrees
· Full-frameSLR lens equivalent: 29 mm
· Video:1280x720 binned and cropped up to 60fps
· 1080Pcropped up to 30fps
· 1640x1232full FOV binned mode, up to 30fps
· 3280x2464full FOV, allegedly 0.1fps to 15fps
· 1280x720binned(? may be skipping) and cropped, at 60-120 fps (?)
· Boardsize: 25 x 23.86 x 9mm
· MountingHoles: 4x D=2.20 mm on 12.5 x 21.0 mm centers
References: Semi-officialv.2 thread:
[7] Sony IMX219 product brief:
[8] SamplePrograms
Sample programs using thecamera for taking stills and video have been developed for the Foundation.There is a
User's Guide andthe source for these programs is available on
github.
Forum user M1M1 publishedinstructions on compiling the sample programs
hereThe command lineparameters for the programs are as follows:
RaspiVidRaspiVid 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 utilitysaves .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 inthe 'gpac' package.
sudo apt-get updatesudo apt-get install gpac MP4Box -add filename.h264 filename.mp4
MotionThere is a version of thesecurity cam / motion-detection program 'motion' adapted for the R-Pi camera(motion-MMAL), written by user 'dozencrows'.
[7] Motion detection with still and videocapture at a resolution of 1024x576 at 1 fps is possible, and several fps atlower resolutions. There is a blog post explaining how to set it up.
[8] It is also possible to use the stockmotion program (sudo apt-get install motion) with either of the two availableV4L2 drivers.
Video4Linux2There is an unofficialUserspace Video4Linux2 (V4L2) driver.
[9][10][11] Thisallows use of the R-Pi camera with many standard Linux applications developedfor USB webcams. Due to the Pi's ARMv6 cpu, lower resolutions and frameratesare typical when compared with a modern desktop system.
There is an officialkernel-space V4L2 driver in development, with a "beta" versionavailable for testing from 2 Dec 2013.
[12] RAW imagesThe
raspistill --raw option will append RAW data to theJPEG. The RAW data contains the image direct from the sensor, before debayerand color processing. A simple tool called
raspi_dng[13] isbeing developed
[14] toconvert the JPEG+RAW file into a standard Adobe DNG file.
ConfigurationThe cameras red LEDlights up when recording video or taking a still picture, this can be turnedoff by adding the following line to config.txt (
RPiconfig)
disable_camera_led=1
It's possible to turn itback on at runtime by using GPIO5
[15] KnownIssues
· 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 6seconds are not supported
Prior to March 2014,video mode did not use the full sensor area (only a 1920x1080 center crop), andthere was no video mode faster than 30 fps. With new firmware as of March 182014
[16] thecamera has a full-sensor 2x2 binned video mode, and also can do 640 x 480 up to90 fps.
Troubleshooting
Minimum GPU MemoryThe camera requires aminimum 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 workwhen the GPU is set to 32M however (useful on low memory pi like 256M A+ )
Camera not working at allExample 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 eachconnector has the locking tab engaged. The RPi + camera draws about 260 mA morecurrent when recording video, than without the camera. The Model B is about 550mA 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 forreliable operation. You can check this with a voltmeter across TP1 and TP2.
[17][18]In some cases, themicro-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 flexcable connector labelled "P5V04A SUNNY" on the camera board. It makesa click when it is fully seated.
[19] Note:before touching the camera board, make sure you are grounded, as the board isESD sensitive (can be damaged by static shock).
This error message alsoappear if you forgot to configure the configuration file of the Raspberry. Justtype: sudo raspi-config and choose "5- Enable camera" option then"Enable"
As of august 2014, with2014-06-20-wheezy-raspbian.img, the firmware of a RPi B+ model needs to beupdated :
$ sudo rpi-update
Here is a workingversion :
$ vcgencmd versionAug 12 2014 18:21:28 Copyright (c) 2012 Broadcomversion f32b2bbfdea55d48c9a52b92e5c798f9aa5f47bc (tainted) (release) $ uname -aLinux poopdeck 3.12.26+ #703 PREEMPT Tue Aug 12 18:13:52 BST 2014 armv6l GNU/Linux $ cat /proc/cpuinfo | grep RevisionRevision : 0010
Colored Banding or Flickering on videoThis can be caused by apoor power supply, or bad power cable. Several people have fixed this byreplacing the power supply, or the microUSB power cable.
[20][21]It can also be caused byindoor fluorescent lighting. The camera defaults to video mode at 30 fps, whichworks well in the USA with 60 Hz power. If you are in Europe or elsewhere with50 Hz power, this may give you flicker under fluorescent lighting.
[22] Tryusing the option
-fps 25 to change the frame rate to 25 framesper second.
3rdparty software
BerryCam - iOSBerryCam enables you touse your iOS device to control the Raspberry Pi camera module.
A Python handler scriptis installed on the raspberry pi.
Control exposure modes,special effects for still images with the simple interface - no need to learncomplex SSH commands. Preview your images on the iOS device and save to yourcamera roll. The same images are also saved to your Raspberry Pi.
[9] Pi Sight - AndroidPi Sight is an Androidapplication which allows you to control all the aspects of your Raspberry Picamera.
It was inspired byBerryCam for iOS and has much of the same functionality. You can controlexposure modes, image effects, white balance, image size and quality and prettymuch every other parameter that can be accessed when using the camera on thecommand line. It also uses the same Python handler script on the Raspberry Pias BerryCam
[10] RaspiCam Remote - AndroidRaspiCam Remote is an appto view the Raspberry Pi camera module on your Android Device.
Unlike other apps, nosoftware needs to be installed or configured on the Raspberry Pi - simply typein the ip address of the Pi. It also allows use of USB cameras.
Continuous 30fps h264streeaming for camera monitoring on your android device, and live view of thevarious image effects.
[11] Pi Vision - Raspberry PiPi Vision is a GUI basedcontroller for the Raspberry Pi camera module which runs on your Raspberry Pi.
[12] picameraThe picamera library is apure Python library for controlling the Raspberry Pi camera module. It isavailable for installation from the Raspbian repository (as python-picamera) orfrom
PyPI (for non-Raspbian distros).
[13] Customizing
Changing the ribbon cableThe ribbon cable thatconnects the camera board to the Pi is 15-core 1mm pitch ribbon cable, withalternate 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 isFFC1-15-B150105160MM
[23]. Other suppliers have been noted on eBay.
The Foundation has notedthat the camera only passed EMI emissions testing with ribbon cable lengths of15cm, although longer cables may also work.
[24] Oneuser 'rew' reports a 4 m (13 foot) extension cable is working.
[25][26] Adjusting Lens FocusThe v1 camera isfixed-focus (at infinity) as delivered. The thread-locking glue dots can bescraped off
[27] allowingmanual lens focus, as close as 2.5 cm. To change the focus to
FL cm, unscrew the lens (turncounter-clockwise) by
Ddegrees,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
[28]. The closest achievable focus is about 25 mm,after unscrewing the lens roughly 2 full turns.
[29] Atthis point it is loose and must be held in place by other means.
Unscrewing more than 2turns results in removal of the lens
[30] allowinguse of other optical systems. The lens thread size is believed to be M6 x 0.35
[31].
The v2.1 camera is presetto focus closer than infinity, unlike the v1 camera. There have been reports ofsuccess refocusing it by turning the lens with a cut-up credit card tool
[32].
Macro, Wide, Tele adaptor lensesThe near focus point ofthe camera is about 1 meter as delivered. Without modification to the cameraitself, it is possible to put a simple external lens in front such as readingglasses, SLR diopter ("close-up filter") or loupe to enable closerfocus. For best results, put the additional lens very close to the camera lens.
Macro, Wide-Angle, andTelephoto adapter lenses designed for the iPhone 4/4s and similar devices willalso work on the R-Pi camera. Depending on your configuration, properlymounting the accessory lens in front of the camera module may require someingenuity. Focus becomes critical with a telephoto adapter, so success theremay also require the manual focus modification.
Replacing Stock LensChanging the lens is amore 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 cameraboard, after unscrewing and removing the stock lens.
[33][34] MartinMiller has posted a guide on raspberrytorte.com describing complete cameramodule disassembly and replacing lens holder with a stock M12 unit.
[35] VariousM12 x 0.5 (S-mount) lenses intended for board-level cameras are available atfocal lengths from fisheye to long telephoto.
[36][37][38] Variousunofficial, 3rd party versions of RPi-compatible camera boards are availableonline which feature a M12 lens housing.
Removing IR Filter(NOTE: Since release of the official Pi-NoIRversion at the same price, this is of mostly historical interest.) The IRfilter is rigid and glued to the bottom inside of the black plastic lenshousing, requiring complete disassembly to remove. Two early attempts by RPiforum users M33P
[39] andscorp
[40] wereinitially successful, but in both cases the camera died soon afterwards fromblunt trauma to the fragile bond wires on the die.
[41] ARPi blog post (27 May 2013) has more description of this process with a videoof the modification, and video from the resulting IR-enabled camera.
[42] HousingsTo help building your owncamera board case or enclosure, a hand-measured mechanical drawing
[43] ofthe camera module is available, thanks to Gert van Loo. There is anotherdrawing
[44] fromraspberrypi-spy. There are some CAD files for housings and camera holdersavailable on Thingiverse
[45].
References