Camera
About the Camera Modules
Edit this on GitHub
There are now several official Raspberry Pi camera modules. The original 5-megapixel model was released in 2013, it was followed by an 8-megapixel Camera Module 2 which was released in 2016. The latest camera model is the 12-megapixel Camera Module 3 which was released in 2023. The original 5MP device is no longer available from Raspberry Pi.
All of these cameras come in visible light and infrared versions, while the Camera Module 3 also comes as a standard or wide FoV model for a total of four different variants.
Additionally a 12-megapixel High Quality Camera with CS- or M12-mount variants for use with external lenses was released in 2020 and 2023 respectively. There is no infrared version of the HQ Camera, however the IR Filter can be removed if required.
Finally, there is the Global Shutter camera, which was released in 2023. There is no infrared version of the GS Camera, however the IR Filter can be removed if required.
Note
|
Raspberry Pi Camera Modules are compatible with all Raspberry Pi computers with CSI connectors - that is, all models except Raspberry Pi 400 and the 2016 launch version of Zero. |
Rolling or Global shutter?
Most digital cameras — and our Camera Modules — use a rolling shutter: they scan the image they’re capturing line-by-line, then output the results. You may have noticed that this can cause distortion effects in some settings; if you’ve ever photographed rotating propeller blades, you’ve probably spotted the image shimmering rather than looking like an object that is rotating. The propeller blades have had enough time to change position in the tiny moment that the camera has taken to swipe across and observe the scene.
A global shutter — and our Global Shutter Camera Module — doesn’t do this. It captures the light from every pixel in the scene at once, so your photograph of propeller blades will not suffer from the same distortion.
Why is this useful? Fast-moving objects, like those propeller blades, are now easy to capture; we can also synchronise several cameras to take a photo at precisely the same moment in time. There are plenty of benefits here, like minimising distortion when capturing stereo images. (The human brain is confused if any movement that appears in the left eye has not appeared in the right eye yet.) The Raspberry Pi Global Shutter Camera can also operate with shorter exposure times - down to 30µs, given enough light - than a rolling shutter camera, which makes it useful for high-speed photography.
Note
|
The Global Shutter Camera’s image sensor has a 6.3mm diagonal active sensing area, which is similar in size to Raspberry Pi’s HQ Camera. However, the pixels are larger and can collect more light. Large pixel size and low pixel count are valuable in machine-vision applications; the more pixels a sensor produces, the harder it is to process the image in real time. To get around this, many applications downsize and crop images. This is unnecessary with the Global Shutter Camera and the appropriate lens magnification, where the lower resolution and large pixel size mean an image can be captured natively. |
Installing a Raspberry Pi camera
Warning
|
Cameras are sensitive to static. Earth yourself prior to handling the PCB. A sink tap or similar should suffice if you don’t have an earthing strap. |
Connecting the Camera
The flex cable inserts into the connector labelled CAMERA on the Raspberry Pi, which is located between the Ethernet and HDMI ports. The cable must be inserted with the silver contacts facing the HDMI port. To open the connector, pull the tabs on the top of the connector upwards, then towards the Ethernet port. The flex cable should be inserted firmly into the connector, with care taken not to bend the flex at too acute an angle. To close the connector, push the top part of the connector towards the HDMI port and down, while holding the flex cable in place.
We have created a video to illustrate the process of connecting the camera. Although the video shows the original camera on the original Raspberry Pi 1, the principle is the same for all camera boards:
Depending on the model, the camera may come with a small piece of translucent blue plastic film covering the lens. This is only present to protect the lens while it is being mailed to you, and needs to be removed by gently peeling it off.
Preparing the Software
Before proceeding, we recommend ensuring that your kernel, GPU firmware and applications are all up to date. Please follow the instructions on keeping your operating system up to date.
Then, please follow the relevant setup instructions for the libcamera software stack, and the Picamera2 Python library.
Hardware Specification
Camera Module v1 | Camera Module v2 | Camera Module 3 | Camera Module 3 Wide | HQ Camera | GS Camera | |
---|---|---|---|---|---|---|
Net price |
$25 |
$25 |
$25 |
$35 |
$50 |
$50 |
Size |
Around 25 × 24 × 9 mm |
Around 25 × 24 × 9 mm |
Around 25 × 24 × 11.5 mm |
Around 25 × 24 × 12.4 mm |
38 x 38 x 18.4mm (excluding lens) |
38 x 38 x 19.8mm (29.5mm with adaptor and dust cap) |
Weight |
3g |
3g |
4g |
4g |
30.4g |
34g (41g with adaptor and dust cap) |
Still resolution |
5 Megapixels |
8 Megapixels |
11.9 Megapixels |
11.9 Megapixels |
12.3 Megapixels |
1.58 Megapixels |
Video modes |
1080p30, 720p60 and 640 × 480p60/90 |
1080p47, 1640 × 1232p41 and 640 × 480p206 |
2304 × 1296p56, 2304 × 1296p30 HDR, 1536 × 864p120 |
2304 × 1296p56, 2304 × 1296p30 HDR, 1536 × 864p120 |
2028 × 1080p50, 2028 × 1520p40 and 1332 × 990p120 |
1456 x 1088p60 |
Sensor |
OmniVision OV5647 |
Sony IMX219 |
Sony IMX708 |
Sony IMX708 |
Sony IMX477 |
Sony IMX296 |
Sensor resolution |
2592 × 1944 pixels |
3280 × 2464 pixels |
4608 x 2592 pixels |
4608 x 2592 pixels |
4056 x 3040 pixels |
1456 x 1088 pixels |
Sensor image area |
3.76 × 2.74 mm |
3.68 x 2.76 mm (4.6 mm diagonal) |
6.45 x 3.63mm (7.4mm diagonal) |
6.45 x 3.63mm (7.4mm diagonal) |
6.287mm x 4.712 mm (7.9mm diagonal) |
6.3mm diagonal |
Pixel size |
1.4 µm × 1.4 µm |
1.12 µm x 1.12 µm |
1.4 µm x 1.4 µm |
1.4 µm x 1.4 µm |
1.55 µm x 1.55 µm |
3.45 µm x 3.45 µm |
Optical size |
1/4" |
1/4" |
1/2.43" |
1/2.43" |
1/2.3" |
1/2.9" |
Focus |
Fixed |
Adjustable |
Motorized |
Motorized |
Adjustable |
Adjustable |
Depth of field |
Approx 1 m to ∞ |
Approx 10 cm to ∞ |
Approx 10 cm to ∞ |
Approx 5 cm to ∞ |
N/A |
N/A |
Focal length |
3.60 mm +/- 0.01 |
3.04 mm |
4.74 mm |
2.75 mmm |
Depends on lens |
Depends on lens |
Horizontal Field of View (FoV) |
53.50 +/- 0.13 degrees |
62.2 degrees |
66 degrees |
102 degrees |
Depends on lens |
Depends on lens |
Vertical Field of View (FoV) |
41.41 +/- 0.11 degrees |
48.8 degrees |
41 degrees |
67 degrees |
Depends on lens |
Depends on lens |
Focal ratio (F-Stop) |
F2.9 |
F2.0 |
F1.8 |
F2.2 |
Depends on lens |
Depends on lens |
Maximum exposure times (seconds) |
6 (legacy) / 0.97 (libcamera) |
11.76 |
112 |
112 |
670.74 |
15.5 |
Lens Mount |
N/A |
N/A |
N/A |
N/A |
C/CS- or M12-mount |
C/CS |
NoIR version available? |
Yes |
Yes |
Yes |
Yes |
No |
No |
Note
|
There is some evidence to suggest that the Camera Module 3 may emit RFI at a harmonic of the CSI clock rate. This RFI is in a range to interfere with GPS L1 frequencies (1575 MHz). Please see the thread on Github for details and proposed workarounds. |
Mechanical Drawings
Available mechanical drawings;
Note
|
Board dimensions and mounting-hole positions for Camera Module 3 are identical to Camera Module 2. However, due to changes in the size and position of the sensor module, it is not mechanically compatible with the camera lid for the Raspberry Pi Zero Case. |
Camera Filters
Edit this on GitHub
Some transmission characteristics are available for the Camera Module 3 and the HQ camera.
Filter Removal
Note
|
This procedure applies to both the HQ and GS cameras. |
Warning
|
This procedure cannot be reversed: the adhesive that attaches the filter will not survive being lifted and replaced, and while the IR filter is about 1.1mm thick, it may crack when it is removed. Removing it will void the warranty on the product. Nevertheless, removing the filter will be desirable to some users. |
Both the High Quality Camera and Global Shutter Camera contain an IR filter, which is used to reduce the camera’s sensitivity to infrared light. This ensures that outdoor photos look more natural. However, some nature photography can be enhanced with the removal of this filter; the colours of sky, plants, and water can be affected by its removal. The camera can also be used without the filter for night vision in a location that is illuminated with infrared light.
Warning
|
Before proceeding read through all of the steps and decide whether you are willing to void your warranty. Do not proceed unless you are sure that you are willing to void your warranty. |
To remove the filter:
-
Work in a clean and dust-free environment, as the sensor will be exposed to the air.
-
Unscrew the two 1.5 mm hex lock keys on the underside of the main circuit board. Be careful not to let the washers roll away. There is a gasket of slightly sticky material between the housing and PCB which will require some force to separate.
-
Lift up the board and place it down on a very clean surface. Make sure the sensor does not touch the surface.
-
You may try some ways to weaken the adhesive, such as a little isopropyl alcohol and/or heat (~20-30 C).
-
Turn the lens mount around so that it is "looking" upwards and place it on a table.
-
Using a pen top or similar soft plastic item, push down on the filter only at the very edges where the glass attaches to the aluminium - to minimise the risk of breaking the filter. The glue will break and the filter will detach from the lens mount.
-
Given that changing lenses will expose the sensor, at this point you could affix a clear filter (for example, OHP plastic) to minimize the chance of dust entering the sensor cavity.
-
Replace the main housing over the circuit board. Be sure to realign the housing with the gasket, which remains on the circuit board.
-
The nylon washer prevents damage to the circuit board; apply this washer first. Next, fit the steel washer, which prevents damage to the nylon washer.
-
Screw down the two hex lock keys. As long as the washers have been fitted in the correct order, they do not need to be screwed very tightly.
Note
|
It is likely to be difficult or impossible to glue the filter back in place and return the device to functioning as a normal optical camera. |
Recommended Lenses
Edit this on GitHub
The following lenses are recommended for use with our HQ and GS cameras.
Note
|
While the HQ Camera is available in both C/CS- and M12-mount versions, the GS Camera is available only with a C/CS-mount. |
C/CS Lenses
We recommend two lenses, a 6mm wide angle lens and a 16mm telephoto lens. These lenses should be available from your nearest Authorised Reseller.
16mm telephoto | 6mm wide angle | ||
---|---|---|---|
Resolution |
10MP |
3MP |
|
Image format |
1" |
1/2" |
|
Aperture |
F1.4 to 1.6 |
F1.2 |
|
Mount |
C |
CS |
|
Field Angle |
1" |
44.6°× 33.6° |
63° |
2/3" |
30.0°× 23.2° |
||
1/1.8" |
24.7°× 18.6° |
||
1/2" |
21.8°× 16.4° |
||
Back focal length |
17.53mm |
7.53mm |
|
M.O.D. |
0.2m |
0.2m |
|
Dimensions |
φ39.00×50.00mm |
φ30×34mm |
M12 Lenses
We recommend three lenses manufactured by Gaojia Optotech. These lenses should be available from your nearest Authorised Reseller.
8mm | 25mm | Fish Eye | ||
---|---|---|---|---|
Resolution |
12MP |
5MP |
15MP |
|
Image format |
1/1.7" |
1/2" |
1/2.3" |
|
Aperture |
F1.8 |
F2.4 |
F2.5 |
|
Mount |
M12 |
|||
Field of View (D/H/V) |
72.64°/57.12°/42.44° |
18.3°/14.7°/11.1° |
184.6°/140°/102.6° |
Synchronous Captures
Edit this on GitHub
Both the HQ Camera and the Global Shutter Camera, have support for synchronous captures. Making use of the XVS pin (Vertical Sync) allows one camera to pulse when a frame capture is initiated. The other camera can then listen for this sync pulse, and capture a frame at the same time as the other camera.
Using the HQ Camera
For correct operation, both cameras require a 1.65v pull up voltage on the XVS line, which is created by a potential divider through the 3.3v and GND pins on the Raspberry Pi.
Connect a potential divider of 2 equally high impedance ( > 1kOhm) resistors to 3v3 and ground, creating 1.65V. This can be connected to either Pi.
Solder the GND and XVS touchpoints of each HQ Camera board to each other.
Connect the XVS wires to the 1.65V potential divider pull up.
Boot up both Raspberry Pis
The file /sys/module/imx477/parameters/trigger_mode
determines which board outputs pulses, or waits to recieve pulses (source and sink).
This parameter can only be altered in superuser mode.
On the sink, run:
sudo su
echo 2 > /sys/module/imx477/parameters/trigger_mode
exit
On the source, run:
sudo su
echo 1 > /sys/module/imx477/parameters/trigger_mode
exit
Start the sink running:
libcamera-vid --frames 300 --qt-preview -o sink.h264
Start the source running
libcamera-vid --frames 300 --qt-preview -o source.h264
Frames should be synchronous. Use --frames to ensure the same number of frames are captured, and that the recordings are exactly the same length. Running the sink first ensures that no frames are missed.
Note
|
The potential divider is needed to pull up the XVS pin to high whilst the source is in an idle state. This ensures that no frames are created or lost upon startup. The source whilst initialising goes from LOW to HIGH which can trigger a false frame. |
Using the GS Camera
Note
|
The Global Shutter (GS) camera can also be operated in a synchonous mode. However, the source camera will record one extra frame. A much better alternative method to ensure that both cameras capture the same amount of frames is to use the external trigger method. |
To operate as source and sink together, the Global Shutter Cameras also require connection of the XHS (horizontal sync) pins together. However, these do not need connection to a pullup resistor.
The wiring setup is identical to the HQ Camera method, except that you will also need to connect the XHS pins together.
Create a potential divider made of 2 equally high impedance ( > 1kOhm) resistors resistors to 3v3 and ground, creating 1.65V. This can be connected to either Pi.
Solder 2 wires to the XVS touchpoint on each board and connect both of these wires together to the 1.65V potential divider.
Solder the GND of each Camera board to each other. Also solder 2 wires to the XHS touchpoints on each board and connect these. No pullup is needed for XHS pin.
On the boards that you wish to act as sinks, solder the two halves of the MAS pad together. This tells the sensor to act as a sink, and will wait for a signal to capture a frame.
Boot up both Raspberry Pis
Start the sink running:
libcamera-vid --frames 300 -o sync.h264
Allow a delay before you start the source running (see note below). Needs to be roughly > 2 seconds.
Start the source running:
libcamera-vid --frames 299 -o sync.h264
Note
|
Due to limitations of the IMX296 sensor, we are unable to get the sink to record exactly the same amount of frames as the source. The source will record one extra frame before the sink starts recording. This will need to be accounted for later in the application. Because of this, you need to specify that the sink records one less frame in the '--frames' option. FFmpeg has the ability to resync these two videos. By dropping the first frame from the source, we then get two recordings of the same frame length and with the same starting point.
|
External Trigger on the GS Camera
Edit this on GitHub
The Global Shutter (GS) camera can be triggered externally by pulsing the external trigger (denoted on the board as XTR) connection on the board. Multiple cameras can be connected to the same pulse, allowing for an alternative way to synchronise two cameras.
The exposure time is equal to the low pulse-width time plus an additional 14.26us. i.e. a low pulse of 10000us leads to an exposure time of 10014.26us. Framerate is directly controlled by how often you pulse the pin. A PWM frequency of 30Hz will lead to a framerate of 30 frames per second.
Preparation
Warning
|
This modification includes removing an SMD soldered part. You should not attempt this modification unless you feel you are competent to complete it. When soldering to the Camera board, please remove the plastic back cover to avoid damaging it. |
If your board has transistor Q2 fitted, shown in blue on the image below, you will need to remove R11 from the board, as shown in red. This connects GP0 to XTR and without removal, the camera will not operate in external trigger mode. The location of the components is displayed below.
Next solder a wire to the touchpoints of XTR and GND on the GS Camera board. We can use a Raspberry Pi Pico to provide the trigger. Connect these to the Pico - XTR to any pin (GP28 is used in this example). Also connect Pico GND to Camera GND. A wiring diagram is shown below.
Boot up the Raspberry Pi with the camera connected.
Enable external triggering through superuser mode:
sudo su
echo 1 > /sys/module/imx296/parameters/trigger_mode
exit
Raspberry Pi Pico Micropython Code
from machine import Pin, PWM
from time import sleep
pwm = PWM(Pin(28))
framerate = 30
shutter = 6000 # In microseconds
frame_length = 1000000 / framerate
pwm.freq(framerate)
pwm.duty_u16(int((1 - (shutter - 14) / frame_length) * 65535))
The low pulsewidth is equal to the shutter time, and the frequency of the PWM equals the framerate.
Note
|
In this example Pin 28 is used to connect to the XTR touchpoint on the GS camera board. |
Operation
Run the code on the Pico, and set the camera running:
libcamera-hello -t 0 --qt-preview --shutter 3000
A frame should now be generated every time that the Pico pulses the pin. Variable framerate is acceptable, and can be controlled by simply varying the duration between pulses. No options need to be passed to libcamera-apps to enable external trigger.
Note
|
When running libcamera apps, you will need to specify a fixed shutter duration (the value does not matter). This will ensure the AGC does not try adjusting camera’s shutter speed, which is controlled by the external trigger pulse. |