Kornia-rs is a low-level computer vision library primarily written in Rust, offering high-performance image I/O, processing, and 3D operations through Python bindings. It leverages Rust's memory safety and speed for demanding computer vision tasks, integrating efficiently into machine learning and data science workflows via zero-copy data transfer with frameworks like NumPy and PyTorch. The library is actively developed by the Kornia organization and is currently at version 0.1.10.
pip install kornia-rsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to read an image using `kornia-rs`, convert the resulting `kornia_rs.Tensor` to a NumPy array via DLPack for seamless integration with Python data science tools, perform a basic image processing operation like resizing, and then convert the result back to a NumPy array. This highlights the library's high-performance I/O and interoperability.
Always consult the latest GitHub README and release notes when upgrading, and adapt your code to new API signatures. Pin your minor version to ensure stability within a project (e.g., `kornia-rs==0.1.*`).
Check the `kornia-rs` GitHub documentation for a full list of optional system dependencies relevant to the features you intend to use and install them manually if needed.
Refer to the `kornia` (PyTorch) documentation or `kornia-rs` specific documentation for the exact Python-exposed functions and objects. Avoid assuming direct parity with the Rust API.
Be mindful of shared memory when performing operations on tensors converted via DLPack. If independent copies are needed, explicitly clone the tensor after conversion (e.g., `np_array = np.from_dlpack(image_tensor).copy()`).
Ensure you have a working Rust toolchain installed (e.g., by running `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`). Also, make sure `pip` and `setuptools` are up-to-date (`pip install --upgrade pip setuptools`). If building from source is necessary, confirm your system has the required build tools for Rust and Python bindings.
Install `kornia-rs` using pip (`pip install kornia-rs`). If already installed, ensure your Python virtual environment is correctly activated and that `kornia_rs` is installed for the specific Python interpreter you are using. Verify installation with `pip show kornia-rs`.
Install the missing system dependency using your operating system's package manager. For `libturbojpeg` on Debian/Ubuntu-based systems, run `sudo apt-get install libturbojpeg0`. For `nasm` (a common dependency for `turbojpeg`), run `sudo apt-get install nasm`. For GStreamer support, install development packages like `sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev`.