Building a lensless camera with the Raspberry HQ camera, cardboard, and tape

Eric Bezzam
5 min readDec 4, 2021

--

In this tutorial, we will see how to build a lensless camera with a Raspberry Pi components and some cheap materials (cardboard/tape). This tutorial is largely inspired by the DiffuserCam work of Prof. Laura Waller’s group at UC Berkeley. We provide some additional software utilities, and use the HQ camera instead of the v2 camera which yields much better quality images!

What you need:

1) Dismantling the HQ camera

The Raspberry Pi HQ camera (below) comes without a lens.

We will need to remove the black mount, which also has an infrared filter (the blue film). This can be done by removing the screws from the back.

Carefully remove the black mount in front of the sensor. It is glued so you will have to use a bit of force.

And now we have direct access to the sensor. Be careful not to touch the sensor or to get any dust on it. If you do, it will probably still work fine. You can gently blow off any dust that falls on the sensor.

2) Find focal distance of your diffuser

In the building guide of the original tutorial (Section 3.1), they talk about finding the correct focal distance for the chosen diffuser. This requires moving the diffuser (double-sided tape in our case) in front of the sensor in order to determine at which distance the autocorrelation of the PSF has optimal properties.

This PSF measurement requires a setup similar to what we have in another tutorial (and as shown below). The distance between the point source and the camera sensor is around 40cm, i.e. sufficiently far enough to be considered far-field.

Without some precision hardware and software, it is not straightforward to determine the focal distance, as holding the piece of tape in place and determining its exact distance from the sensor is difficult. At best you can determine if a certain material is a good diffuser by live streaming while moving the diffuser back and forth. Note that you should be in as dark of a room as possible so that the only light is coming from the point source.

If at one point you see a PSF with lots of sharp white lines curving in all directions (as below, color doesn’t matter for now), you can be quite sure that your material is a good diffuser. The resulting PSF should be a caustic pattern, similar to what you see at the bottom of a swimming pool.

Figure 4 of the building guide compares PSFs in- and out-of focus. They found 3mm to be the best distance for their double-sided tape. We can confirm that a few millimeters works well.

3) Building the mount

After determining a reasonable distance we can built a mount, namely the separation material in between the sensor and the diffuser. To this end, we will use some cardboard. We cut a 4cm x 4cm section such that it has a thickness of a few millimeters. We taped two pieces together to obtain a separation material that was thick enough.

Cut a 1.2cm x 1.2cm from the middle to make space for the sensor.

Tape the edges with electric / opaque tape to prevent any stray light from entering through the sides.

Now we can place our diffuser (double-sided tape) in front of the sensor.

4) Constructing the aperture

The last step in constructing our lensless camera is to place an aperture around the diffuser (Section 3.3 of building guide). We need this aperture so that shifting a point source corresponds to shifting the PSF we have already observed / measured. This allows us to calibrate our lensless camera with a single PSF measurement. Otherwise shifting the point source can correspond to new caustic patterns, and we would need PSF measurements for each of these shifts.

We will again use the live stream to build our aperture.

Below is what we observe from our live steam without an aperture.

Constructing an aperture would result in a black frame around our caustic pattern. To this end, we will place electric / opaque tape on our diffuser.

Below is what we observe from the live feed.

In the next tutorial, we will talk more about measuring and analyzing the quality of our lensless camera’s PSF with Python.

Useful links

Original DiffuserCam tutorial website: https://waller-lab.github.io/DiffuserCam/tutorial.html

--

--

Eric Bezzam

PhD student at EPFL. Previously at Snips/Sonos, DSP Concepts, Fraunhofer IDMT, and Jacobs University. Most of past work in audio and now breaking into optics!