Skip to main content

Package to control and image with a lensless camera running on a Raspberry Pi.

Project description

Documentation Status

A Hardware and Software Toolkit for Lensless Computational Imaging with a Raspberry Pi

Lensless imaging example

This toolkit has everything you need to perform imaging with a lensless camera. We make use of a low-cost implementation of DiffuserCam [1], where we use a piece of tape instead of the lens and the Raspberry Pi HQ camera sensor (the V2 sensor is also supported). Similar principles and methods can be used for a different lensless encoder and a different sensor.

If you are interested in exploring reconstruction algorithms without building the camera, that is entirely possible! The provided reconstruction algorithms can be used with the provided data or simulated data.

We’ve also written a few Medium articles to guide users through the process of building the camera, measuring data with it, and reconstruction. They are all laid out in this post.

Setup

If you are just interested in using the reconstruction algorithms and plotting / evaluation tools you can install the package via pip:

pip install lensless

For plotting, you may also need to install Tk.

For performing measurements, the expected workflow is to have a local computer which interfaces remotely with a Raspberry Pi equipped with the HQ camera sensor (or V2 sensor). Instructions on building the camera can be found here.

The software from this repository has to be installed on both your local machine and the Raspberry Pi. Note that we highly recommend using Python 3.9, as some Python library versions may not be available with earlier versions of Python. Moreover, its end-of-life is Oct 2025.

Local machine

Below are commands that worked for our configuration (Ubuntu 21.04), but there are certainly other ways to download a repository and install the library locally.

# download from GitHub
git clone git@github.com:LCAV/LenslessPiCam.git

# install in virtual environment
cd LenslessPiCam
python3 -m venv lensless_env
source lensless_env/bin/activate
pip install -e .

# -- extra dependencies for local machine for plotting/reconstruction
pip install -r recon_requirements.txt

# (optional) try reconstruction on local machine
python scripts/recon/admm.py

Note (25-04-2023): for using reconstruction method based on Pycsou lensless.apgd.APGD, V2 has to be installed:

pip install git+https://github.com/matthieumeo/pycsou.git@v2-dev

If PyTorch is installed, you will need to be sure to have PyTorch 2.0 or higher, as Pycsou V2 is not compatible with earlier versions of PyTorch. Moreover, Pycsou requires Python within [3.9, 3.11).

Moreover, numba (requirement for Pycsou V2) may require an older version of NumPy:

pip install numpy==1.23.5

Raspberry Pi

After flashing your Raspberry Pi with SSH enabled, you need to set it up for passwordless access. Do not set a password for your SSH key pair, as this will not work with the provided scripts.

On the Raspberry Pi, you can then run the following commands (from the home directory):

# dependencies
sudo apt-get install -y libimage-exiftool-perl libatlas-base-dev \
python3-numpy python3-scipy python3-opencv
sudo pip3 install -U virtualenv

# download from GitHub
git clone git@github.com:LCAV/LenslessPiCam.git

# install in virtual environment
cd LenslessPiCam
virtualenv --system-site-packages -p python3 lensless_env
source lensless_env/bin/activate
pip install --no-deps -e .
pip install -r rpi_requirements.txt

Acknowledgements

The idea of building a lensless camera from a Raspberry Pi and a piece of tape comes from Prof. Laura Waller’s group at UC Berkeley. So a huge kudos to them for the idea and making tools/code/data available! Below is some of the work that has inspired this toolkit:

Citing this work

If you use these tools in your own research, please cite the following:

@misc{lenslesspicam,
    url = {https://infoscience.epfl.ch/record/294041?&ln=en},
    author = {Bezzam, Eric and Kashani, Sepand and Vetterli, Martin and Simeoni, Matthieu},
    title = {Lensless{P}i{C}am: A Hardware and Software Platform for Lensless Computational Imaging with a {R}aspberry {P}i},
    publisher = {Infoscience},
    year = {2022},
}

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lensless-1.0.4.tar.gz (50.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page