The Raspberry Pi Camera Module turns your Pi into a capable imaging platform for photography, video, security, and computer vision projects. With the Camera Module 3 offering 12MP autofocus and HDR, and the Pi 5 supporting dual cameras, the possibilities go well beyond basic snapshots.
Table of Contents
- Camera Module Options
- Hardware Setup and Configuration
- Project 1: Timelapse Photography
- Project 2: Motion-Detecting Security Camera
- Project 3: Stop Motion Animation Studio
- Project 4: Bird Feeder Camera with AI Detection
- Project 5: Live Video Streaming
- Frequently Asked Questions
- Conclusion
Camera Module Options
Raspberry Pi offers several official camera modules, and third-party options extend the range further:
| Camera | Resolution | Features | Best For |
|---|---|---|---|
| Camera Module 3 | 12MP | Autofocus, HDR, 75.7° FOV | General photography, timelapse |
| Camera Module 3 Wide | 12MP | Autofocus, HDR, 120° FOV | Security, dashcam, wide scenes |
| Camera Module 3 NoIR | 12MP | No IR filter, autofocus | Night vision with IR LEDs |
| Waveshare IMX219 (79.3°) | 8MP | Fixed focus, compact | Embedded systems, cost-effective |
| Waveshare IMX219 (120°) | 8MP | Wide angle, fixed focus | Surveillance, fisheye views |
The Camera Module 3 is the recommended starting point. Its autofocus capability means you get sharp images without manual adjustment — a big upgrade from the fixed-focus Camera Module 2.
Hardware Setup and Configuration
Connecting the camera:
On the Raspberry Pi 5, the camera connects via a 22-pin FFC (flat flexible cable) to one of the two MIPI CSI ports. Lift the connector latch, slide the cable in with the contacts facing the board, and press the latch down.
Important: The Pi 5 uses 22-pin camera connectors, while older Pi models use 15-pin connectors. Make sure you have the correct cable for your board.
Software setup:
Raspberry Pi OS Bookworm uses libcamera as the default camera stack. The old raspistill and raspivid commands are deprecated.
# Test camera is detected
libcamera-hello --list-cameras
# Take a still photo
libcamera-still -o test.jpg
# Record 10 seconds of video
libcamera-vid -o test.h264 -t 10000
# Take a photo with autofocus
libcamera-still -o photo.jpg --autofocus-mode auto
Python access:
from picamera2 import Picamera2
import time
cam = Picamera2()
config = cam.create_still_configuration()
cam.configure(config)
cam.start()
time.sleep(2) # Allow auto-exposure to settle
cam.capture_file("image.jpg")
cam.stop()
The picamera2 library is the Python interface for libcamera. It provides full control over exposure, white balance, autofocus, and image processing.
Project 1: Timelapse Photography
Capture hours, days, or weeks of change compressed into a short video. Timelapse is perfect for documenting construction projects, plant growth, weather patterns, or city skylines.
Basic timelapse script:
from picamera2 import Picamera2
import time
import os
from datetime import datetime
cam = Picamera2()
config = cam.create_still_configuration(main={"size": (4056, 3040)})
cam.configure(config)
cam.start()
output_dir = "/home/pi/timelapse"
os.makedirs(output_dir, exist_ok=True)
interval = 30 # seconds between shots
duration = 3600 * 8 # total duration: 8 hours
start = time.time()
frame = 0
while time.time() - start < duration:
filename = f"{output_dir}/frame_{frame:05d}.jpg"
cam.capture_file(filename)
frame += 1
print(f"Captured frame {frame} at {datetime.now()}")
time.sleep(interval)
cam.stop()
print(f"Captured {frame} frames")
Converting frames to video:
ffmpeg -r 30 -i frame_%05d.jpg -c:v libx264 -pix_fmt yuv420p timelapse.mp4
At one frame every 30 seconds over 8 hours, you get 960 frames — which plays as a 32-second video at 30 FPS. Experiment with intervals: 5 seconds for cloud movement, 60 seconds for construction, 15 minutes for plant growth.
Advanced tips:
- Lock exposure and white balance to prevent flickering between frames
- Use the Camera Module 3’s HDR mode for scenes with challenging lighting
- Mount the camera rigidly — even small vibrations ruin timelapse smoothness
- For outdoor timelapses in India, use a weatherproof enclosure with a clear window
Project 2: Motion-Detecting Security Camera
Build a security camera that records only when motion is detected, saving storage and making review efficient.
Using MotionEye:
MotionEye is a web-based surveillance solution that handles motion detection, recording, and remote viewing through a browser interface.
sudo apt install -y motion
sudo pip3 install motioneye
After installation, access the web interface at http://pi-ip:8765. Add your camera, configure motion detection sensitivity, and set up recording rules (record on motion, keep recordings for X days, maximum file size).
Key settings for Indian deployment:
- Adjust motion threshold for environments with variable lighting (ceiling fans create motion, adjust sensitivity accordingly)
- Set up motion masks to ignore areas with constant movement (trees in wind, passing traffic)
- Configure email or Telegram notifications for motion events
- Store recordings on an NVMe drive rather than the SD card for reliability
Night vision: Use the Camera Module 3 NoIR (no infrared filter) paired with IR LED illuminators. The NoIR camera sees infrared light, so IR LEDs illuminate the scene without visible light — perfect for unobtrusive night surveillance.
Project 3: Stop Motion Animation Studio
Create stop-motion animations using the Pi camera and a simple Python interface. Each frame is a photo captured when you press a button, and the sequence is compiled into a video.
Hardware setup:
- Raspberry Pi 5 with Camera Module 3 (autofocus helps keep subjects sharp)
- Push button connected to GPIO for triggering captures
- Consistent lighting (desk lamp or LED panel)
- Tripod or fixed mount for the camera
Workflow:
- Position your subject and camera
- Press the button to capture a frame
- Make a small adjustment to the subject
- Capture again
- Repeat until your animation is complete
- Compile frames into video with ffmpeg
The script displays a live preview on screen with an onion-skin overlay (semi-transparent previous frame) to help you judge the movement between frames. This is how professional stop-motion animators work — the Pi version costs ₹12,000 total instead of ₹50,000+ for dedicated stop-motion software and camera setups.
Project 4: Bird Feeder Camera with AI Detection
Mount a camera near a bird feeder and use AI to identify visiting bird species automatically. This project combines camera hardware with TensorFlow Lite for on-device image classification.
Hardware:
- Raspberry Pi 5 (4GB+)
- Camera Module 3 (standard or wide angle)
- Weatherproof enclosure
- Power supply (or PoE HAT for single-cable installation)
Software approach:
- Motion detection triggers capture (saves battery and processing)
- Captured image is passed to a TensorFlow Lite bird classification model
- Model identifies the bird species (or classifies as “not a bird”)
- Results are logged with timestamp, species, and confidence score
- Optional: push notification via Telegram with the photo and species name
Pre-trained bird classification models are available online — you do not need to train your own. The Pi 5 runs TFLite inference on a 224×224 image in under 100ms, making real-time classification practical.
India has over 1,300 bird species, and even urban gardens attract parakeets, bulbuls, sunbirds, mynas, and more. A Pi bird camera is both a fun project and a genuine contribution to citizen science platforms like eBird.
Project 5: Live Video Streaming
Stream live video from your Pi camera to a web browser, YouTube, or Twitch. This is useful for baby monitors, pet cameras, workshop streams, or remote monitoring.
Local network streaming (lowest latency):
# Using libcamera's built-in streaming
libcamera-vid -t 0 --inline -o - | cvlc stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8080}' :demux=h264
Access the stream at http://pi-ip:8080 from any device on your network. Latency is typically under 500ms on a local network.
YouTube/Twitch streaming:
libcamera-vid -t 0 --width 1920 --height 1080 --framerate 30 --inline -o - |
ffmpeg -re -f h264 -i - -c:v copy -f flv rtmp://a.rtmp.youtube.com/live2/YOUR_STREAM_KEY
This pushes the Pi’s camera feed directly to YouTube Live or Twitch. The Pi 5’s hardware H.264 encoder handles 1080p30 without significant CPU load, leaving resources for overlays or audio mixing.
Web dashboard with controls:
For more advanced setups, use Flask or FastAPI to build a web interface that shows the live feed alongside camera controls (zoom, exposure, autofocus toggle). The Pi 5’s CPU handles both the video encoding and web server without issues.
Frequently Asked Questions
Can I use a USB webcam instead of the camera module?
Yes, but the MIPI CSI camera module is recommended. USB cameras use more CPU for encoding (no hardware acceleration), have higher latency, and are limited to USB bandwidth. The camera module connects directly to the GPU for hardware-accelerated capture and encoding.
Can I use two cameras on a Raspberry Pi 5?
Yes. The Pi 5 has two MIPI CSI ports, each supporting a camera simultaneously. This enables stereo vision, dual-angle security, or combining a standard and NoIR camera for day/night operation.
What video resolution and frame rate can the camera module achieve?
The Camera Module 3 captures 12MP stills (4056×3040) and 1080p video at 30 FPS through the hardware encoder. For lower resolutions, frame rates up to 120 FPS are possible (720p at 120 FPS for slow-motion capture).
How do I power a camera outdoors?
Use a PoE HAT and an outdoor-rated Ethernet cable — this provides both power and network over a single cable. Alternatively, use a weatherproof enclosure with a sealed USB-C cable run. For truly remote locations, a solar panel with a battery and charge controller can power the Pi 5 indefinitely.
Does the camera work with OpenCV?
Yes. OpenCV works with the camera via picamera2 or by capturing frames from the libcamera pipeline. This enables face detection, object tracking, colour filtering, and other computer vision applications directly on the Pi 5.
Conclusion
The Raspberry Pi Camera Module transforms your Pi from a computing platform into an imaging powerhouse. Whether you are building a security system, creating art through timelapse and stop-motion, identifying wildlife with AI, or streaming live video, the camera module provides professional-grade capabilities at a hobbyist price point.
Start with the Camera Module 3 for its autofocus and HDR features, add the NoIR variant for night vision projects, and use the Pi 5’s dual camera ports when your project demands multiple viewpoints.
Find all Raspberry Pi camera modules and accessories at Zbotic’s Raspberry Pi collection with fast shipping across India.
Add comment