How to use the Raspberry Pi camera module with the Raspberry Pi board

Hello and welcome back. In this tutorial, we will learn how to use the Raspberry Pi camera module with the Raspberry Pi board. For that, I used the Raspberry Pi 2 B board, but you can follow the same steps with other boards. If you’re using the Pi Zero board, just make sure to use the adapter cable.

Raspberry Pi Camera module

There are various Raspberry Pi camera modules available in the market, such as version 1, version 2, version 3, HQ camera, and Global shutter camera. Each of these has distinct features and uses different technology. The versions 1, 2, and 3 cameras are the most common in the market. Now, let’s take a closer look at the specifications of each camera one by one.

Camera Module v1

  • Size: Around 25 × 24 × 9 mm
  • Year: 2013
  • Megapixels: 5 Megapixels
  • Video modes: 1080p30, 720p60 and 640 × 480p60/90
  • Sensor: OmniVision OV5647
  • Sensor resolution: 2592 × 1944 pixels
  • Sensor image area: 3.76 × 2.74 mm

Camera Module v2

  • Size: Around 25 × 24 × 9 mm
  • Year: 2016
  • Megapixels: 8 Megapixels
  • Video modes: 1080p47, 1640 × 1232p41 and 640 × 480p206
  • Sensor: Sony IMX219
  • Sensor resolution: 3280 × 2464 pixels
  • Sensor image area: 3.68 x 2.76 mm (4.6 mm diagonal)

Camera Module v3

  • Size: Around 25 × 24 × 11.5 mm
  • Year: 2023
  • Megapixels: 11.9 Megapixels
  • Video modes: 2304 × 1296p56, 2304 × 1296p30 HDR, 1536 × 864p120
  • Sensor: Sony IMX708
  • Sensor resolution: 4608 x 2592 pixels
  • Sensor image area: 6.45 x 3.63mm (7.4mm diagonal)

HQ Camera

  • Size:  38 x 38 x 18.4mm (excluding lens)
  • Megapixels: 12.3 Megapixels
  • Video modes: 2028 × 1080p50, 2028 × 1520p40 and 1332 × 990p120
  • Sensor: Sony IMX477
  • Sensor resolution: 4056 x 3040 pixels
  • Sensor image area: 6.287mm x 4.712 mm (7.9mm diagonal)

GS Camera

  • Size: 38 x 38 x 19.8mm (29.5mm with adaptor and dust cap)
  • Megapixels: 1.58 Megapixels
  • Video modes: 1456 x 1088p60
  • Sensor: Sony IMX296
  • Sensor resolution: 1456 x 1088 pixels
  • Sensor image area: 6.3mm diagonal

If you want more info about these cameras, please visit the Raspberry Pi official website.

Specifications of this camera module

  • Dimensions — 20 x 25 x 10mm
  • Resolution — 5 megapixels
  • Standscape resolution — 2592 x 1944
  • Lens — 1/4″
  • Image sensor — Omnivision 5647 CMOS image sensor
  • Maximum image transmission rate — 1080p: 30FPS (coding and decoding) / 720p / 60FPS
  • Connection to the Raspberry Pi — 15-pin flat tape cable, to the dedicated 15-pin Mipi / serial camera interface (CSI-2)
  • Temperature range — Operating range: -30 ° C to +70 ° C / stable picture: 0 ° C to 50 ° C

OK, let’s do it step by step. The required components are given below.

  • Raspberry Pi 2 Model B board — Amazon
  • Raspberry camera with ribbon cable — Amazon

Step 1

Firstly, identify these components.

Step 2

Secondly, connect the Ribbon cable to the camera module and Raspberry Pi board. For that, pull up the plastic clip and insert the Ribbon cable. Then, push the plastic clips.

Step 3

Thirdly, insert the SD card(OS installed). Then, connect the mouse, keyboard, and monitor.

Step 4

Now, connect the 5VDC power supply to the Raspberry Pi board. And then, power on your Raspberry Pi computer.

Step 5

Next, enable the camera module. For that, open the terminal and run the command below.

  • sudo raspi-config
  • Then, go to the interface options and enable the Camera option.

Step 6

Now, open the following Python script using your favorite IDE. I used Thonny IDE.

from picamera import PiCamera, Color
from time import sleep


camera = PiCamera()
camera.rotation = 180

times = True

def onePhoto():
    camera.start_preview()
    sleep(4)
    camera.capture('/home/srituhobby/Desktop/image.jpg')#change location
    camera.stop_preview()
    
def multiPhoto():
    camera.start_preview()
    for i in range(3):
        sleep(4)
        camera.capture('/home/srituhobby/Desktop/images%s.jpg'% i)#change location
    camera.stop_preview()

def video():
    camera.start_preview()
    camera.start_recording('/home/srituhobby/Desktop/video.h264')#change location
    sleep(6)
    camera.stop_recording()
    camera.stop_preview()
    
def modifyPhoto():
    camera.resolution = (800,800) #Max = 2592,1944 / Min = 64,64
    camera.framerate = 15
    camera.start_preview()
    camera.image_effect = 'oilpaint' #none,negative,solarize,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolor ...
    camera.exposure_mode = 'snow' # off,auto,night, nightpreview, backlight, spotlight, sports, snow , beach , verylong ...
    camera.awb_mode = 'shade' # off, auto , sunlight , cloudy,shade,tungsten,fluorescent,incandescent,flash,horizon
    camera.brightness = 80 # 0 - 100
    camera.contrast = 50 # 0 - 100
    camera.annotate_background = Color('red')
    camera.annotate_foreground = Color('white')
    camera.annotate_text = "SriTu Hobby"
    camera.annotate_text_size = 50
    sleep(4)
    camera.capture('/home/srituhobby/Desktop/imagems.jpg')#change location
    camera.stop_preview()

    
    
while times:   
#    onePhoto()
#    multiPhoto()
#    video()
#    modifyPhoto()
    times = False
  • This script includes four functions. You can use them one by one removing the # character.

OK, enjoy this tutorial. The full video guide is below. So, we hope to see you in the next tutorial or project. Have a good day.

How to use the Raspberry Pi camera module with the Raspberry Pi board

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *