OpenCV is today’s most popular image processing library, covering everything from classic image processing algorithms to cutting-edge deep learning pretrained models. However because OpenCV is not differentiable it mainly focuses on pre-processing tasks and cannot be embedded in an entire training process. That shortcoming motivated OpenCV.org research scientist Edgar Riba to propose a new differentiable computer vision library, “Kornia,” which has now been open-sourced on GitHub.

Inspired by OpenCV, Kornia is based on PyTorch and designed to solve generic computer vision problems. It contains a set of routines for performing color space conversions, and differentiable modules for performing tasks such as image filtering and edge detection. Kornia’s core code can efficiently define and compute the gradient of complex functions with reverse-mode auto-differentiation.

How Kornia deals with differentiation processing

Kornia consists of subset packages containing operators which can be inserted into neural networks to enable models to perform tasks such as image transformations, epipolar geometry, and depth estimation.

Main components of the Kornia library

Kornia is easy to use, and its API documentation and tutorials are available on the Kornia project page.

The Kornia project also offers a number of Jupyter Notebooks that showcase various use cases. The following example shows the steps involved in extracting image features for local descriptors using Kornia:

Input an image (similar to OpenCV or other image processing libraries).

Load the predefined detection features.

Extract image patches based on the features and prepare for subsequent processing.

The extracted image patches can be used to further construct tensors using the SIFT method.

One of the main Kornia contributors, Dmytro Mishkin from the Faculty of Electrical Engineering at the Czech Technical University, says the research team welcomes feedback from the AI community to help expand and improve Kornia and its various filters, geometry, and local features.

The paper Kornia: An Open Source Differentiable Computer Vision Library for PyTorch is on arXiv.