/lensfunpy

📷 Lens distortion correction for Python, a wrapper for lensfun

Primary LanguageCythonMIT LicenseMIT

lensfunpy

lensfunpy is an easy-to-use Python wrapper for the lensfun library.

API Documentation

Sample code

How to find cameras and lenses:

How to correct lens distortion:

It is also possible to apply the correction via SciPy instead of OpenCV. The lensfunpy.util module contains convenience functions for RGB images which handle both OpenCV and SciPy.

How to correct lens vignetting:

Installation

Install lensfunpy by running: `sh pip install lensfunpy`

64-bit binary wheels are provided for Linux, macOS, and Windows.

Installation from source on Linux/macOS

If you have the need to use a specific lensfun version or you can't use the provided binary wheels then follow the steps in this section to build lensfunpy from source.

First, install the lensfun library on your system.

On Ubuntu, you can get (an outdated) version with:

Or install the latest developer version from the Git repository:

After that, install lensfunpy using:

On Linux, if you get the error "ImportError: liblensfun.so.0: cannot open shared object file: No such file or directory" when trying to use lensfunpy, then do the following:

The lensfun library is installed in /usr/local/lib when compiled from source, and apparently this folder is not searched for libraries by default in some Linux distributions. Note that on some systems the installation path may be slightly different, such as /usr/local/lib/x86_64-linux-gnu or /usr/local/lib64.

Installation from source on Windows

These instructions are experimental and support is not provided for them. Typically, there should be no need to build manually since wheels are hosted on PyPI.

You need to have Visual Studio installed to build lensfunpy.

In a PowerShell window:

The above will download all build dependencies (including a Python installation) and is fully configured through the four environment variables. Set USE_CONDA = '0' to build within an existing Python environment.

NumPy Dependency

lensfunpy depends on NumPy. The minimum supported NumPy version depends on your Python version:

Python numpy
3.7 >= 1.14
3.8 >= 1.17
3.9 >= 1.19
3.10 >= 1.21
3.11 >= 1.23