How to use the Raspberry Pi High Quality camera on Ubuntu Core
Tags: 12MP , Camera , Raspberry Pi , Tutorial , Ubuntu Core
The new High Quality (HQ) camera from the people over at Raspberry Pi is now available. And as they say, it is really rather good. It has the option for interchangeable lenses, a 12 MP sensor, a distinct improvement from the previous 8MP V2 camera, and a tripod screw mount. In this post, I’ll walk you through the steps to stream video on Ubuntu Core and how to properly focus the camera for different lenses with and without the C mount.
What you will need
If you plan on following along with this guide, this is the list of things you will need:
- A microSD card (4GB minimum, 8GB recommended)
- A computer with a microSD card drive
- A Raspberry Pi 2, 3 or 4
- A micro-USB power cable (USB-C for the Pi 4)
- A Wi-Fi network or an ethernet cable with an internet connection
- A monitor with an HDMI interface
- An HDMI cable for the Pi 2 & 3 and a micro HDMI cable for the Pi 4
- A USB keyboard
- The new HQ Raspberry Pi Camera
- C and or CS-mount compatible lenses.
Setting up Ubuntu Core with the HQ Camera
First, to get going with Ubuntu we’re going to need to install and set up Ubuntu Core on the Raspberry Pi. The best way to do this is to open the tutorial in a new tab, follow along to where you can SSH into the Pi, and come back when you’re done.
Once you’re in, we need to enable the camera for the board. This is a little hacky at the moment as you need to go into the config file to do it, but don’t worry. It’s nice and easy and we are working on making this process much more seamless. More on that later.
Enable the camera to work with Ubuntu Core
Access the uboot config file with this command:
sudo vi /boot/uboot/config.txt
Once the file is open, scroll down to the last line and then type the following commands:
This will initiate insertion mode so you can add to the file. Next scroll to the bottom of the file and type:
This is the line that enables the camera. That’s it. Now to save and exit the file hit ‘Esc’ escape on your keyboard to exit insertion mode and type
to save and exit the file. To be clear:
Next, we need to install picamera-demo-application. This is a snap in the snap store developed and maintained by Ogra, a Canonical engineer. To do this use the following command:
snap install picamera-streaming-demo
Connect the camera and connect to the web
Now we can wire the camera up to the Raspberry Pi. In this example, we use the Raspberry Pi 3 Model B. It is important to connect the camera in the right way, pay attention in the following image to the orientation of the ribbon cable. The blue side facing towards the USB ports.
To connect it in this way, pull the black tab gently upwards until you feel it click. Slot the ribbon, orientated as shown, into the space, and press the black tab back down to secure it.
For clarity, this is an example of how not to connect it (in the wrong port):
Once that’s connected, reboot the Raspberry Pi with:
Wait a few moments and in your browser type:
http://<board IP address>:8000/
And you will be able to see what your camera sees in a web page like this:
Focusing with and without the C-mount
Being able to focus the camera, is of course, crucial. For a photography novice like me, it took a while to work out how to do it. The C-mount is a type of mount usually found on 16mm cameras. Of the two lenses I bought, one required the C-mount, the other a CS-mount. A CS-mount lens is designed to be mounted ~ 5mm closer to the image sensor than a C lens. It’s important to note this before playing around with the lenses and misplacing the C-mount bracket and wondering why your 16mm lens won’t focus for an hour or so.
We are working to do a lot more to improve the user experience of Ubuntu on Raspberry Pi. This tutorial was non-typical. Usually, tutorials live at ubuntu.com/tutorials, where you can find ‘how-tos’ on getting set up with Ubuntu Server, or other projects, like building a Raspberry Pi cluster using MicroK8s.
This tutorial utilises Ubuntu Core, Ubuntu Core is not developer-friendly, we recommend its use for appliances, for fire-and-forget devices and for production. If you want to try other applications or build applications for the Raspberry Pi on Ubuntu we recommend you look into snaps and Ubuntu Server and take it from there.
Ubuntu Desktop for Raspberry Pi
Watch the live event of the 20.10 launch the and find out all the news about the new Ubuntu Desktop image for Raspberry Pi.