How do you feel about this article? Help us to provide better content for you.
Thank you! Your feedback has been received.
There was a problem submitting your feedback, please try again later.
What do you think of this article?
Setting up the Raspberry Pi HQ Camera with a Pi 4 and 7” Touch Screen
The Raspberry Pi High Quality (HQ) Camera was announced at the end of April this year, around 7 years after the first Pi Camera board was introduced, which was then followed by the second version of the Camera in 2016. Both of these cameras featured a fixed focus lens, similar to those you would find in contemporary mobile phones. However, as phone cameras have improved massively in recent years, it seems right that the Raspberry Pi should get a better quality camera also.
The Raspberry Pi HQ Camera (201-2852) features:
- 12.3 megapixel Sony IMX477 sensor
- 1.55μm × 1.55μm pixel size – double the pixel area of IMX219
- Back-illuminated sensor architecture for improved sensitivity
- Support for off-the-shelf C- and CS-mount lenses
- Integrated back-focus adjustment ring and tripod mount
Of course, the other relatively new introduction on the Raspberry Pi front is the Pi 4 (182-2096) and, as well as the HQ Camera, I have finally got my hands on one of those, so it seemed sensible to put the two together. To complement them I also have a touch screen (899-7466) and a nice case to put these in (193-5380) . So I got to work putting my new Pi/camera/screen setup together.
I fitted the Pi to my new 7” Touch Screen and then fitted them into the case. I found it was quite difficult to get the HDMI and USB sockets on the Pi lined up properly with the holes in the case since it is a pretty snug fit.
The best way seemed to be to loosen the screws holding the Pi to the screen, until they were almost undone, then screwing the screen into its case and then wiggling the Pi carefully until it was correctly positioned, before finally tightening all the screws. If you follow this procedure you will find one of the screws on the Pi is very difficult to get at – I just about managed it, although you would probably be OK leaving it off. Alternatively, maybe using a socket screw would make it easier to tighten, as I find an Allen key is much easier to get into a tricky space than a screwdriver.
The case works best with the sockets at the top, resting on its rubber feet on the bottom. The only thing is when it is like this, the picture is upside down. The easy way to fix this is to add a line to the Raspbian configuration file that it runs at startup, to flip the screen by 180 degrees. To do this:
- Open Terminal from the Pi’s Start / Accessories menu
- In Terminal, type "sudo nano /boot/config.txt"
- Add the line "lcd_rotate=2" to the top of the file.
- Press CTRL+X
- Then Y and then Enter
- Restart your Pi
The official Raspberry Pi Camera Guide is an invaluable resource and is obviously aimed at a young audience, but gives clear instructions on how how to get the best out of your camera, and it is free to download as a PDF. As well as information on setting up the camera, this lists the commands you can use to take pictures and has some cool projects to try out.
I followed the instructions to connect my camera using a long ribbon cable and removing the back of the screen case for access to the Pi’s camera connector. Once it was connected I enabled the camera by opening the Raspberry Pi Configuration in the Preferences section of the Pi’s start menu. I found the Camera listed under the Interfaces tab and selected Enable before clicking the OK button.
Lenses
One of the great things about the HD camera is that is has a standard CS lens mount and comes with a C-CS adapter. This means it can take all sorts of standard lenses – typically those designed for close circuit TV and similar applications.
I had a CCTV lens (776-9396) with a CS-mount handy so thought I would give that a go. It has a back focal length of 9.75 – 20.46mm – that is the distance between the back of the lens and the surface of the Pi’s sensor at which the lens can focus. The HQ Camera’s back focal length is around 17mm (7mm without the CS adapter). This means even adjusting the focus ring on the camera to its maximum I can only get my lens to function in macro – i.e. it will only focus on very close objects. So I thought I would see how it performed with some super close-ups.
The other thing about the lens is that has an electronically controlled shutter, so to open it I had to apply a small voltage to the correct pins of its connector cable.
I referred to its datasheet and worked out which pins to use and then tried connecting them to my bench power supply with a low current limit.
Initially, I used the raspistill command in Terminal — again referring to the Pi Camera Guide — and took some pictures which show off the excellent quality that can be achieved with the camera.
First a thistle head.
Then a detail from a feather from a hatband.
Video
I was then eager to see how it would perform recording video. Rather than use the raspivid command, I decided I would have a little more control if I installed RPi Cam Web Interface and use that. I was familiar with it from the setup that monitors our laser cutter and my experiments looking into using a kite and Pi Camera for aerial photography. It is straightforward to install following the step by step instructions. Once that was done I could connect to it via a browser on my laptop.
I tried saving a few still images first and then started wondering what moving image I could record in macro. I came up with a psychedelic light show effect using household stuff I could lay my hands on, as I am still working from home. So this is what you get when you mix olive oil, chilli oil, water with a bit of ink from a felt tip, and some sequins ...
I was quite pleased with the effect given the limitations of the ingredients and it made me think about getting hold of some proper water and oil-soluble inks, hooking the laptop up to a projector, and seeing if I could recreate a 1960s Pink Floyd light show!
Apart from that, I am eager to try out some lenses that have fewer limitations so I can try some wildlife photography and recording some of my future adventures in electronics.
Comments