Solving the Raspberry Pi Camera V2 Focus Issue with An Auto-Focus Camera Module
The Focus Distance of a V2 Camera Module
The viewing distance of the offical Raspberry Pi cameras is 1m to infinity, which means that you will extra works if you need to shoot closer than 1m.
Problems with Fixed Focus
In some simple applications, it’s fine to go with a fixed-focus camera. However, that’s never a satisfying choice, and the fixed-focus camera is phasing out in some industries. Take the mobile phone industry as an example, almost every smartphone now comes with auto-focus front and rear-facing cameras. So, what’s the problem with a fixed focus? Or we can ask it in this way: why would major smartphone manufacturers abandon the fixed-focus camera?
Capturing an image is not always an autonomous process, and it involves human intentions. You will have something you care about in a frame, and that thing becomes your focus. To some extent, a fixed-focus camera is a passive camera, and it captures the images in a static focus state.
The official 5MP V1 cameras do not come with a decent focus control mechanism, so it’s impossible for it to see close-up objects in a clear way. And you might tear the camera module apart trying to adjusting the lens focus. The 8MP V2 cameras include a lens adjustment tool, and you can use it to refocus the camera module. However, if you refocus on the closer, you will stay blurry with objects in the distance until the next manual adjustment. In other words, it’s not feasible to see objects close to the lens and in the distance on the same camera without manual tweaking.
What is Autofocus and Why Do You Need It
An autofocus camera is a camera equipped with a moveable motor-controlled lens, driven by an algorithm to detect the scene and focus the camera. Unlike a fixed-focus or manual-focus camera, the focusing process of an autofocus camera is handled by the software. Therefore, you can concentrate on framing the best image.
As mentioned above, the fixed-focus camera is passive when it comes to image capturing. On the other hand, a camera with software focus control mechanism is an active camera, because you can easily shift the focus in the capturing process to adapt to your interests.
If it’s possible for you to shoot objects less than 1m from the lens, if you may shoot several objects in the different distance on a single camera module, or if you find it troublesome to manually adjust the lens back and forth, you will need an autofocus camera. Everything is handled remotely with software, easy and neat.
To learn more about autofocus with Raspberry Pi camera modules, we recommend you read Raspberry Pi Camera Autofocus: The Complete Guide.
Two Autofocus Camera Modules for Raspberry Pi
The standard pi camera is fixed focus lens, some of them are glued which cannot be adjusted by users, and some of them are not glued which can adjust the lens focus manually. But in certain circumstance, you want to programmable control the focus distance remotely where the device can not be reached. The ArduCAM team now designed motorized control focus 5MP and an 8MP camera module for Raspberry Pi series boards to address this problem. Now the autofocus function is also implemented by the Arducam team, now the auto-focus demo source code is available on our GitHub.
- High-Definition video camera for Raspberry Pi Model A/B/B+ and Raspberry Pi 2 Pi 3B, Pi 3B+ and Pi Zero
- 5MP OV5647 or 8MP IMX219 sensor with motorized focus lens
- Integral IR filter
- Angle of View: 54 x 41 degrees
- Field of View: 2.0 x 1.33 m at 2 m
- Full-frame SLR lens equivalent: 35 mm
- Focus distance: 4 cm to infinity
- Size: 25 x 24 mm
- 15 cm flat ribbon cable to 15-pin MIPI Camera Serial Interface (CSI) connector
The Raspberry Pi officially supports two camera modules – 5MP OV5647 and 8MP IMX219, so we’ve also built solutions for each model to fill the gap in the Raspberry Pi autofocus camera. The key to building such an upgrade is to get a motorized focus lens and build a focusing mechanism.
The 5MP camera is easier to customize, and we’ve customized both the camera board and the motorized lens to build a new camera module. The 8MP V2 camera is encrypted to prevent third-party manufacturing, so we’ve designed an autofocus drop-in replacement to replace the original image sensor and camera lens.
With the hardware ready, we’ve included example codes for both autofocus and manual keyboard control. The autofocus is powered by OpenCV, and the keyboard control allows for step-by-step precise focus control with up and down arrow keys.