The Raspberry Pi HQ Camera — the 12.3 MP IMX477 module with a C/CS lens mount — turns a Raspberry Pi 4 into a surprisingly capable imaging platform. Astrophotography, time-lapse, machine vision, a doorbell camera that doesn’t phone home to anyone — the Pi 4 has the horsepower and the HQ Camera has the sensor. The wrinkle in 2026: the camera stack changed. raspistill is gone, libcamera is the only game in town, and most of the old tutorials are wrong. Here is what actually works today.
What You Need
- A Raspberry Pi 4 (any RAM size — 2 GB is enough for stills, 4 GB+ for 4K video)
- The Raspberry Pi HQ Camera (IMX477, C/CS mount) — sometimes branded “Pi HD camera”
- A CS-mount or C-mount lens. The 6 mm wide-angle and 16 mm telephoto from the official Raspberry Pi accessory range are the easy starting points; any CCTV CS-mount lens works.
- A 15-pin to 22-pin CSI ribbon cable. The Pi 4 uses the wide 15-pin connector; the HQ Camera ships with a 15-pin cable, so you are usually fine — double-check before ordering.
- A microSD card with a fresh Raspberry Pi OS Bookworm install (32-bit or 64-bit)
- A 3A USB-C PSU — the camera sensor draws meaningful current under continuous capture
Step 1 — Connect the Camera
Power off the Pi. The CSI connector is the long thin one between the HDMI ports and the audio jack. Lift the black plastic catch on both ends, slide the ribbon in contacts facing the HDMI ports, push the catch back down. The HQ Camera side is identical — contacts face the PCB.
If you bought a 22-pin cable by mistake (the narrow connector used on the Pi 5 and CM4), it will not fit the Pi 4. The Pi 4 uses the wide 15-pin connector.
Step 2 — Confirm libcamera Sees It
Boot up and run:
libcamera-hello --list-cameras
You should see something like:
Available cameras
-----------------
0 : imx477 [4056x3040] (/base/soc/i2c0mux/i2c@1/imx477@1a)
Modes: 'SRGGB10_CSI2P' : 1332x990 [120.05 fps - (696, 528)/2664x1980 crop]
2028x1080 [50.03 fps - (0, 440)/4056x2160 crop]
2028x1520 [40.01 fps - (0, 0)/4056x3040 crop]
4056x3040 [10.00 fps - (0, 0)/4056x3040 crop]
If the list is empty: shut down, reseat the ribbon (it is almost always the ribbon), and confirm camera_auto_detect=1 is in /boot/firmware/config.txt. On Bookworm this is the default; on older Bullseye installs you may need to add dtoverlay=imx477 explicitly.
Step 3 — First Still and First Video
The libcamera-* tools replace the old raspistill / raspivid:
# 5-second preview window
libcamera-hello -t 5000
# Full-resolution still (12.3 MP, ~4 MB JPEG)
libcamera-still -o test.jpg --width 4056 --height 3040
# 10-second 1080p30 H.264 video to file
libcamera-vid -t 10000 --width 1920 --height 1080 --framerate 30 -o test.h264
# Wrap it in an MP4 container so VLC / Quicktime can open it
ffmpeg -framerate 30 -i test.h264 -c copy test.mp4
On a Pi 4 the IMX477 will reliably hold 1920×1080 at 30 fps, and 4K (4056×3040) at 10 fps. The HQ Camera’s sensor is capable of much more; the Pi 4’s CSI lane width and ISP are the bottleneck, not the sensor.
Step 4 — Focus the Lens
This is where most people give up on the HQ Camera. Unlike the older Pi Camera Module v2, the HQ Camera has no autofocus — you focus mechanically by rotating the lens. With the kit 6 mm wide-angle:
- Run
libcamera-hello -t 0— a live preview that stays open until you Ctrl-C it. - Point the camera at something with hard edges (a printed page, a brick wall) about 1 m away.
- Loosen the back focus adjustment ring (the silver collar between the lens and the camera body) by rotating it counter-clockwise.
- Rotate the lens itself until the preview is sharp.
- Tighten the back-focus ring to lock it.
The back-focus ring is what lets the same CS-mount lens focus correctly on a sensor that sits at a slightly different distance from the lens flange than the lens was designed for. If you cannot get infinity focus, loosen the back-focus ring a quarter turn and try again.
Step 5 — Useful Captures
Time-Lapse
One frame every 30 seconds, into a timestamped folder, indefinitely:
mkdir -p ~/timelapse
libcamera-still -t 0 --timelapse 30000 --framestart 0 \
--width 4056 --height 3040 \
-o ~/timelapse/img_%05d.jpg
Stitch the result with ffmpeg:
ffmpeg -framerate 30 -pattern_type glob -i '~/timelapse/img_*.jpg' \
-c:v libx264 -pix_fmt yuv420p timelapse.mp4
Long Exposure (Astrophotography)
The IMX477 supports exposures up to 239 seconds. To force a 30-second exposure with low ISO:
libcamera-still --shutter 30000000 --gain 1 --awb off \
--denoise off --immediate \
-o m31.jpg
--shutter is in microseconds, so 30000000 = 30 s. --immediate skips the preview window. For sub-second exposures the kit lens is fine; for long exposures you almost certainly want a fast CS-mount lens (f/1.4 or wider).
Streaming Over the Network
Pi 4 + HQ Camera as a low-latency MJPEG stream that any browser can render:
libcamera-vid -t 0 --inline --width 1280 --height 720 \
--codec mjpeg -o - | \
cvlc stream:///dev/stdin --sout \
'#standard{access=http,mux=mpjpeg,dst=:8090}' :demux=mjpeg
Then open http://<pi-ip>:8090/ in any browser. Latency around 200 ms on a wired LAN.
Machine Vision with Python and Picamera2
The Python binding for libcamera is picamera2 — pre-installed on Bookworm:
from picamera2 import Picamera2
import cv2
picam = Picamera2()
picam.configure(picam.create_preview_configuration(
main={"size": (1280, 720), "format": "RGB888"}))
picam.start()
while True:
frame = picam.capture_array()
# Hand it to OpenCV like any other numpy frame
gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
cv2.imshow("HQ Cam", gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
The HQ Camera’s larger sensor means lower noise at high gain than any of the older Pi cameras — useful for indoor/low-light vision work.
Common Gotchas
“ERROR: *** no cameras available ***”
99% of the time this is the ribbon. The CSI connector is fragile and the ribbon is easy to insert slightly off-axis. Power off, lift the catch on both ends, pull the ribbon, re-insert — contacts toward the HDMI ports on the Pi 4. If it still fails, swap the ribbon — we have seen brand-new cables out of the box with a broken trace.
“Image is pink/green tinted.”
Auto white-balance is doing its job — badly — under your lighting. Force a fixed AWB:
libcamera-still --awb daylight -o out.jpg
# or, with explicit gains:
libcamera-still --awbgains 1.5,1.6 -o out.jpg
“Video drops frames at 1080p30.”
The Pi 4’s hardware H.264 encoder is fine, but the microSD card often isn’t. Either write to a USB 3.0 SSD (-o /mnt/ssd/out.h264) or drop to 720p. A class-10 SD card is borderline at 1080p.
“The lens won’t focus at infinity.”
Back-focus ring. Loosen the silver collar between the lens and the camera body, retry focus, lock the collar once sharp. This is the single most common HQ Camera question we get.
“libcamera works but picamera2 import fails.”
You’re probably on Bullseye or a Python venv that doesn’t inherit system site-packages. On Bookworm:
sudo apt install -y python3-picamera2 python3-opencv
# When using a venv, create it with --system-site-packages
Pi 4 vs Pi 5 vs CM4 for the HQ Camera
- Pi 4 — the sweet spot for most use cases. 1080p30 video, 12 MP stills, single camera, $35–$75 depending on RAM. What this post covers.
- Pi 5 — 4K H.265, dual MIPI cameras, better noise handling at high gain. Worth it for video work; overkill for stills/time-lapse.
- CM4 — dual MIPI lanes by default and you control the carrier. Right answer for embedded products (security cameras, ANPR, microscopy).
For a stills-first hobby project — astrophotography, a printable-quality time-lapse rig, a wildlife camera — the Pi 4 + HQ Camera combo is hard to beat on price-per-pixel. Our Rock Pi 4 vs Raspberry Pi 4 comparison goes into the headless-server side of the Pi 4 if camera work isn’t your only use case.
Total bill of materials: Pi 4 + HQ Camera + a kit lens + an SD card + a 3A PSU. Under $200 for a 12 MP imaging rig that you fully own.

