I picked up the new Raspberry Pi High Quality camera last week. It’s pretty impressive. In this article, I’ll show you some ways to interact with this camera and do some cool stuff with it.
This is my current setup for this article. I built little stage with Mario, and I have the camera with a lens, into my Pi, and a temp/humidity sensor hooked to it. It’s the same I used in my previous live stream with this camera.
In this article, we’ll learn:
So this camera has some pretty impressive specs for the price.
It’s a 12MP camera with a decent sensor. Far better than previous Raspberry Pi Cameras.
It comes with a ribbon, and a sensor cap out of the box. However you will need to provide a lens for it (C or CS Mount.)
Assembly is pretty straightforward. So enough about the camera, let’s look at how to use it.
First, you’ll need to open up your Raspberry Pi Configuration:
In the configuration, enable “Camera”:
And reboot your Pi.
If you want to know right away the camera is working, get qv4l2.
This is the V3L2 Test Bench. It will help you get your camera into focus, and you can change various settings.
sudo apt-get install qv4l2
After installing it you’ll need to load this into your kernel:
sudo modprobe bcm2835-qv4l2
Then run the program:
This application will give you a realtime view of your camera:
This will help you focus the lens and adjust your lighting, contrast, etc.
You can adjust the base focal length of the lens with the camera. You can adjust back and forth depending on what subject you’re focusing on then set it with a set screw. This will make it easier to get the camera focused in.
With this, I just used a laptop to view the live preview, so I could make adjustments and fine-tune the lens focus.
Once you dial it in, you can start taking some pictures!
The easiest way to test this camera is by using Raspistill. It’s available by default in Raspberry Pi OS/Buster. Its usage is simple:
raspistill -o test.jpg
This will output a high res image like this one:
Which is exactly what we were looking at with the V4L2 capture.
Here are just a few things we can do with Raspistill:
Type in “raspistill” by itself to see the options.
Let’s try to add the date and time to our image. We’ll set it to a 1024 x 768 image while we’re at it:
raspistill -n -t 1000 -w 1024 -h 768 -a 1036 -ae +25+25 -o test2.jpg
So one thing that Raspistill doesn’t allow is free form annotation or adding any text I want to the image.
With Raspistill, you can take still pictures with the camera, and they look great. There are many things you could do with this, including:
Security camera - Take one picture a minute, and rotate out after a couple of hours
Webcam - take pictures every minute and upload it to a web page, like the old webcams of the 90s
Motion detection - you could set up a motion detector and have it take pictures and store them when motion is present.
There are many cool things you could do with Raspistill.
Let’s look at video!
Raspivid is another cool application for interacting with the Raspberry Pi Camera Module. It’s a similar interface as Raspistill, and it’s pretty easy to use. Here’s how you can record ten seconds of video:
raspivid -t 10000 -o test.h264
You can do lots with this program as well, including changing bitrate, levels, and just about anything you can think of.
Here’s an example of the resolution far away, if you wanted to use this as a security camera:
You can even record out in something like MP4. From the Raspberry Pi documentation:
You can install MP4 box:
sudo apt install -y gpac
# Capture 30 seconds of raw video at 640x480 and 150kB/s bit rate into a pivideo.h264 file: raspivid -t 30000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o pivideo.h264 # Wrap the raw video with an MP4 container: MP4Box -add pivideo.h264 pivideo.mp4 # Remove the source raw file, leaving the remaining pivideo.mp4 file to play rm pivideo.h264
This produces a nice little MP4 file:
It’s easy and simple to convert.
There are many things you can do with this camera, and I plan to expand on it a lot more. My takeaways:
So if you’re thinking about picking one up, I’d highly recommend it. There are a ton of great projects you can do with this.
If you want to learn more:
If you build any cool projects with this Let me know! I’d love to hear about it!
Previously published at https://www.jeremymorgan.com/tutorials/raspberry-pi/raspberry-pi-high-quality-camera-tutorial/