Low level implementations for computer vision in Rust
Project description
kornia-rs: Low level implementations for Computer Vision in Rust.
This project provides low level functionality for Computer Vision written in Rust to be consumed by machine learning and data-science frameworks, specially those working with images. We mainly aim to provide I/O functionality for images (future: video, cameras), and visualisation in future.
- The library is written in Rust.
- Python bindings are created with PyO3/Maturin.
- We package with support for Linux [amd64/arm64], Macos and WIndows.
- Supported Python versions are 3.7/3.8/3.9/3.10/3.11
Basic Usage
Load an image, that is converted to cv::Tensor
wich is a centric structure to the DLPack protocol to share tensor data across frameworks with a zero-copy cost.
import kornia_rs as K
from kornia_rs import Tensor as cvTensor
# load an image with Rust `image-rs` as backend library
cv_tensor: cvTensor = K.read_image_rs("dog.jpeg")
assert cv_tensor.shape == [195, 258, 3]
# convert to dlpack to import to torch
th_tensor = torch.utils.dlpack.from_dlpack(cv_tensor)
assert th_tensor.shape == (195, 258, 3)
assert np_tensor.shape == (195, 258, 3)
# or to numpy with same interface
np_tensor = np.from_dlpack(cv_tensor)
Advanced usage
Encode or decoda image streams using the turbojpeg
backend
# load image using turbojpeg
cv_tensor = K.read_image_jpeg("dog.jpeg")
image: np.ndarray = np.from_dlpack(cv_tensor) # HxWx3
# encode the image with jpeg
image_encoder = K.ImageEncoder()
image_encoder.set_quality(95) # set the encoding quality
# get the encoded stream
image_encoded: List[int] = image_encoder.encode(image.tobytes(), image.shape)
# write to disk the encoded stream
K.write_image_jpeg("dog_encoded.jpeg", image_encoded)
# decode back the image
image_decoder = K.ImageDecoder()
decoded_tensor = image_decoder.decode(bytes(image_encoded))
decoded_image: np.ndarray = np.from_dlpack(decoded_tensor) # HxWx3
TODO: short/mid-terrm
- [infra] Automate packaging for manywheels.
- [kornia] integrate with the new
Image
API - [dlpack] move dlpack implementation to dlpack-rs.
- [dlpack] implement test for torch and numpy.
- [dlpack] update dlpack version >=0.8
- [dlpack] implement
DLPack
tocv::Tensor
.
TODO: not priority for now
- [io] Implement image encoding and explore video.
- [viz] Fix minor issues and implement a full
VizManager
to work on the browser. - [tensor] implement basic functionality to test: add, sub, mul, etc.
- [tensor] explore xnnpack and openvino integration.
Development
To test the project in lyour local machine use the following instructions:
- Clone the repository in your local directory
git clone https://github.com/kornia/kornia-rs.git
2.1 (optional) Build the devel.Dockerfile
Let's prepare the development environment with Docker. Make sure you have docker in your system: https://docs.docker.com/engine/install/ubuntu/
cd ./docker && ./build_devel.sh
KORNIA_RS_DEVEL_IMAGE="kornia_rs/devel:local" ./devel.sh
2.2 Enter to the devel
docker container.
./devel.sh
- Build the project
(you should now be inside the docker container)
# maturin needs you to be a `venv`
python3 -m venv .venv
source .venv/bin/activate
# build and generate linked wheels
maturin develop --extras dev
- Run the tests
pytest test/
Contributing
This is a child project of Kornia. Join the community to get in touch with us, or just sponsor the project: https://opencollective.com/kornia
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for kornia_rs-0.0.8-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0384bc24518525769dfb1ffa2347a40148e559822aff89dee1ce3cd6ac29df0 |
|
MD5 | 80f8b52122b5f7d7208921aa0b9964e5 |
|
BLAKE2b-256 | fda89edaeec99ef5c8a15669e743666459f823dfbe4338be07f0e3f9d8f191fa |
Hashes for kornia_rs-0.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e748421465827b10b7b54a1f566d44a423abd87016ca85f95841726578ad56a7 |
|
MD5 | 617d8c1df7eb46fe214d9bd0c27b45d4 |
|
BLAKE2b-256 | 400eebf8a307e84365d2de3a851939739f0593bf4c6e86e12a3dac30321dfa38 |
Hashes for kornia_rs-0.0.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de19c0bbf90a4c9fd5443e6902b292cd8d4d0c5d01babfad73d6a0618694a2d9 |
|
MD5 | 2968abac23cef057be39986c50ca1393 |
|
BLAKE2b-256 | 9bcadb06b4b0c39508703458f174b0df1f2fe896cf890751f64ee9aed56fcb73 |
Hashes for kornia_rs-0.0.8-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e195910ec6139c2436996f62076a6e64e86388e686321656fc174b744a1f0d85 |
|
MD5 | 8c3f5eb964f77446cceb9cc297a7848b |
|
BLAKE2b-256 | 27b11659669ec17d04ba83dad3fa165fe8206f19971a2095b43cc4d8ba2776f3 |
Hashes for kornia_rs-0.0.8-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 735a512441e6d7e21d6270a8ac322d3f3a580bc2882be8a0dbc01aabe7393e69 |
|
MD5 | 343a8be42ef31012a99878ee397ba003 |
|
BLAKE2b-256 | 33b6db696e68de563024a79493181b14fa013d9a08188ab2f4f1ffa60d82e02b |
Hashes for kornia_rs-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8df027cabb442c39a49db97efcfc76cb4f32edabe4929889a6ecdae5d010eef |
|
MD5 | 5f3bc42e018d01b0af39fb64cd7aa9e8 |
|
BLAKE2b-256 | 72ff1f6c67c083aeddecaef4ac8ab75249082a2b526ccc63b78ddf569f93817d |
Hashes for kornia_rs-0.0.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3cdbd17bc66042cddc66c015f9dbae96695abea14068d8249385e48314a009a |
|
MD5 | d13cc83a45b5f97a134e17c043f79ec8 |
|
BLAKE2b-256 | 04212c228cdbba478f2eb323bf7fd8d6706179ae9dd0385159929ad258ef1258 |
Hashes for kornia_rs-0.0.8-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e3ec471a1ab2fecbdec2ce75cc77be9755237ded75fa82fc8a19e7ae4fa478e |
|
MD5 | 62138c48d14f4f39d17901a7d4be8a45 |
|
BLAKE2b-256 | 440521b96a0ed5ad886bf5d68f5547c3eb3ff0e7b5afdc640fb5eba337f5b3e7 |
Hashes for kornia_rs-0.0.8-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a21bd3ed364da55829a07a25c067935a6c571302e95b0eec371f34ce73a1df80 |
|
MD5 | 9a4641574a2f7b5391e189b6be22ec67 |
|
BLAKE2b-256 | bd0498fc1299bdedc06e5e5651de11a8f66b5f2f81c525af17e4a9abd419c32c |
Hashes for kornia_rs-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 340e8d504c824321cf8a2598abdf1399a3a559f3cd9e2468f0ad374ba45ec369 |
|
MD5 | 228757ff10c50f35c431ab8ce15aea81 |
|
BLAKE2b-256 | 874d306cc99d7da853b68ab2223ad7832b2f31356f313ccbf54386ca8f671ecf |
Hashes for kornia_rs-0.0.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6a36c0eafcfd0bfcd4755e54000857be3af1b2163ee103c5cc64d96b53f17be |
|
MD5 | 5d7ae268e62c3d3c4f8aa81326a6bce5 |
|
BLAKE2b-256 | 6a29d043f4d074744ad7e146a1f6aed0f644f3bcc7fe025be0e0d032306bdd53 |
Hashes for kornia_rs-0.0.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b61b75689c128c97ab0a0d6af6cae1ab4b59e05e33dfdb18790f557547ad44b |
|
MD5 | 6063e6d1257a3ab9496ac8fe53eb0770 |
|
BLAKE2b-256 | b20bd750e7d72f343d7fcd9a2fb7f053420a15be3afcbbfcf4dea1db0c18e9b5 |
Hashes for kornia_rs-0.0.8-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ef18e70e3ef9a4d746c9c1fae1e61992bd33286a1937e67cc103935792c1220 |
|
MD5 | 848768e084d46589b1d6821c7fdba5a7 |
|
BLAKE2b-256 | 9dba4b4ec25784b15a400cbe3415fa6b60fe3e5aef2109c29fb40e16fb9e5763 |
Hashes for kornia_rs-0.0.8-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4b8243f72a7fe801155f0a874c0a7cf60b6d59de0dd900174068c53a902e9f7 |
|
MD5 | 8968853c7373786093ac2720720829ec |
|
BLAKE2b-256 | 7c9909601e441e1175c6f8094bdc8e661c9d870f46a8b7095d1b73fb48b84f24 |
Hashes for kornia_rs-0.0.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdfc529327a2fdc3091cc14c52f24e19fa1f158f841eba651c9eda843b2a89d0 |
|
MD5 | c0daf26f1eb6d3cecb5e75628a72089f |
|
BLAKE2b-256 | 73fabc26d7285da1166e5f9d8d31be5f841dbb56540b198f08a36638a57159a3 |
Hashes for kornia_rs-0.0.8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2d1ebee784b33b7d27afbf473fb0fb4f97e52872b3dd7814e9e0c1c1e97f169 |
|
MD5 | 0d2a02d13e896ffecf42ed925ca87b02 |
|
BLAKE2b-256 | 0a7c1d608445bf3c41e0c15d8c52866f0d970404c083c7c65fbd8eabc4bc2888 |
Hashes for kornia_rs-0.0.8-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ab8e5de1f8839b69b3ab675d5e9a250d240ae6540bc51cafa2ca4fc53169fbd |
|
MD5 | f4821827d2d7fee361ca23cfa6cefcbd |
|
BLAKE2b-256 | 5946dc493fdda68dee95230a20c658a8ef6dae023b3cf9f2d9369e6979630df7 |
Hashes for kornia_rs-0.0.8-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30dc55ec390d5ebf949a8243346cc95c07a0ce776c0da01b3d25ce7efaf8ffad |
|
MD5 | 2bd32b6aef6147027caf3f90c5e594db |
|
BLAKE2b-256 | 85b9e70442ca52e6c6999e34b5405265e9ef45b021e6f18a8ffdf17dd3470828 |
Hashes for kornia_rs-0.0.8-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84f78c2ddb1f17ee0ffd5fb2cd0a27415cf5a844b51602142c933473dd78f54a |
|
MD5 | 59fbf83fdeb957566ef7b58190c6a86d |
|
BLAKE2b-256 | 9d96182a9e849cdade106202802ea3e996dc45410bedd57b1de83d85090c77ff |
Hashes for kornia_rs-0.0.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52adb6b062cb5fbc5f45a8aa3af0219c8df17bad6fe735aecc6ae45eeaf1c1ee |
|
MD5 | 4ea8cdc4f3c3823694fc72c69a6bcef4 |
|
BLAKE2b-256 | 78dff2d83da9de128d040750001f8dec655057ae2bd522419b6f322d025298d2 |
Hashes for kornia_rs-0.0.8-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a79f15868bea2a546e3ddc16f863498ce91bb312391290675ed0dfd645e54ec |
|
MD5 | 1ef31d22a26782673d7970af19291695 |
|
BLAKE2b-256 | 7c51ac4bf3ecd1a7c7a438485ed4d5dfd3e5a4c9836671908bbd33e4a4e0a721 |
Hashes for kornia_rs-0.0.8-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5960e586efb3b04defe4238734d1170bc79a6e38107a2d13627155c116becf12 |
|
MD5 | c06fa616733a87a0774c44fd3265a948 |
|
BLAKE2b-256 | 4a2db336a748a348cd93dee5e59ed269698c3e2cecec349f4ffc1d0f5f4b5112 |