Skip to main content

Python wrapper over Azure Kinect SDK

Project description

pyk4a

CI codecov

pyk4a

This library is a simple and pythonic wrapper in Python 3 for the Azure-Kinect-Sensor-SDK.

Images are returned as numpy arrays and behave like python objects.

This approach incurs almost no overhead in terms of CPU, memory or other resources. It also simplifies usage. Kinect C api image buffers are directly reused and image releases are performed automatically by the python garbage collector.

Homepage: https://github.com/etiennedub/pyk4a/

Prerequisites

The Azure-Kinect-Sensor-SDK is required to build this library. To use the SDK, refer to the installation instructions here.

Install

Linux

Linux specific installation instructions here

Install both packages libk4a<major>.<minor> and libk4a<major>.<minor>-dev. The latter contains the headers and CMake files to build pyk4a.

Make sure your LD_LIBRARY_PATH contains the directory of k4a.lib

pip install pyk4a

Windows

In most cases pip install pyk4a is enough to install this package.

When using an anaconda environment, you need to set the environment variable CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1 https://github.com/conda/conda/issues/10897

Because of the numerous issues received from Windows users, the installer (setup.py) automatically detects the kinect SDK path.

When the installer is not able to find the path, the following snippet can help. Make sure you replace the paths in these instructions with your own kinect SDK path. It is important to replace 1.4.1 with your installed version of the SDK.

pip install pyk4a --no-use-pep517 --global-option=build_ext --global-option="-IC:\Program Files\Azure Kinect SDK v1.4.1\sdk\include" --global-option="-LC:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\lib"

During execution, k4a.dll is required. The automatic detection should be able to find this file. It is also possible to specify the DLL's directory with the environment variable K4A_DLL_DIR. If K4A_DLL_DIR is used, the automatic DLL search is not performed.

Example

For a basic example displaying the first frame, you can run this code:

from pyk4a import PyK4A

# Load camera with the default config
k4a = PyK4A()
k4a.start()

# Get the next capture (blocking function)
capture = k4a.get_capture()
img_color = capture.color

# Display with pyplot
from matplotlib import pyplot as plt
plt.imshow(img_color[:, :, 2::-1]) # BGRA to RGB
plt.show()

Otherwise, a more avanced example is available in the example folder. To execute it opencv-python is required.

git clone https://github.com/etiennedub/pyk4a.git
cd pyk4a/example
python viewer.py

Documentation

No documentation is available but all functinos are properly type hinted. The code of the main class is a good place to startPyK4A.

You can also follow the various example folder scripts as reference.

Bug Reports

Submit an issue and please include as much details as possible.

Make sure to use the search function on closed issues, especially if your problem is related to installing on windows.

Module Development

  1. Install required packages: make setup

  2. Install local pyk4a version (compiles pyk4a.cpp): make build

Contribution

Feel free to send pull requests. The develop branch should be used.

Please rebuild, format, check code quality and run tests before submitting a pull request:

make build
make fmt lint
make test

Note: you need clang-format tool(v 11.0+) for formatting CPP code.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyk4a_bundle-1.5.0-cp312-cp312-win_amd64.whl (951.6 kB view details)

Uploaded CPython 3.12 Windows x86-64

pyk4a_bundle-1.5.0-cp312-cp312-manylinux_2_35_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.35+ x86-64

pyk4a_bundle-1.5.0-cp311-cp311-win_amd64.whl (951.4 kB view details)

Uploaded CPython 3.11 Windows x86-64

pyk4a_bundle-1.5.0-cp311-cp311-manylinux_2_35_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.35+ x86-64

pyk4a_bundle-1.5.0-cp310-cp310-win_amd64.whl (951.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

pyk4a_bundle-1.5.0-cp310-cp310-manylinux_2_35_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.35+ x86-64

pyk4a_bundle-1.5.0-cp39-cp39-win_amd64.whl (952.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

pyk4a_bundle-1.5.0-cp39-cp39-manylinux_2_35_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.35+ x86-64

pyk4a_bundle-1.5.0-cp38-cp38-win_amd64.whl (952.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

pyk4a_bundle-1.5.0-cp38-cp38-manylinux_2_35_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.35+ x86-64

pyk4a_bundle-1.5.0-cp37-cp37m-win_amd64.whl (952.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

pyk4a_bundle-1.5.0-cp36-cp36m-win_amd64.whl (952.3 kB view details)

Uploaded CPython 3.6m Windows x86-64

File details

Details for the file pyk4a_bundle-1.5.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c6ac35c84394785b18455cc34aff6bd4c25c77e7e65b7f32d4dcc61c8a508e9b
MD5 bd973ef26ac55a89f08118869b185543
BLAKE2b-256 056e31b708a645f55cb76b27f52679740c3fc113be6c2e49b7ea2e7969dcc37b

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 d270de3142febdfc3a5868e03dd5726a68b518530eb4403034695fdea787ac02
MD5 ad37d1c0b2dae67d2d5d1c2e41d193d2
BLAKE2b-256 ddba45e1898f2adc1991a27c7d49f8bd2b8e41576b348161ac0e2b5176e9b89f

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 74c22e7fae023043fd6be06441cf3f17eee1c6b3b70d5639c30df28d49dc7ad6
MD5 872f5635e6591f614874669509e162b2
BLAKE2b-256 8c47093ef9f81df5d92dfbf1b2f50ea51bf57007d6d95e116472b2cb49594fbb

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp311-cp311-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 f99ff435cf04747828954a3a08b45622a43dcba0852a8aa3a5bfd7028cab8a7e
MD5 dd98f96842cc8e0d76b6880dc8a533a9
BLAKE2b-256 a729e3f5c5eaef27bc129b4b1c9d7161fe379f9058e2efc5cc5100efb172e5d2

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 806f6ee503d98135e57917cb59ac5754777cde5932f0b4a491db66796a2d1a23
MD5 8dfc4bb995809796c04596ba8f743981
BLAKE2b-256 1395bc91e335bc98eb7674694100ebbfa9112e5bc1d84a03645aeea34aaf195f

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7b09ce618cfcbcec2c63cb15f0bcded1a125484fe834f33c8f821fb397e3cfe1
MD5 09febae298a699e171b8a2a43f51bea8
BLAKE2b-256 ae30fd535346510b01f4941c260106ebb130fce1ac16220533c0bd1caf1b82cf

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1cec319de3ccbaa3ad6fdf42ad023cc996efaa7295e13b7a6270d7ca660d90a6
MD5 3a54d1ba5de1ab41a9b4f627300e59c4
BLAKE2b-256 4d5ae639c1b0316584c38a7711bafde3da0278779b4308ecf2a5f308f106fd01

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp39-cp39-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp39-cp39-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 40bf3b7f53c56e6f9f5a4d72fe262b3749a0a2e2394b3fa91d6cb0125b6fdb5c
MD5 201e6fd39e3f407e9b5e56e4a85e6b1d
BLAKE2b-256 d8c199e02d33a9aeae07a109bb74b996da90fae63dd34774c068ebf9ccf1e588

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a8edfcde1f84f87ab0244c56491e6bb0a4963f21d6921cd711fa692207730e0f
MD5 549c1323a6fd6b882dc4f4ed9a7e068b
BLAKE2b-256 04fa6eac52e3ce59fad8c359affc35658262e9b92a55b8c7b91c5672e7d61902

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp38-cp38-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp38-cp38-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 4b3e52838d7d13442378651e94a54c7359d4106aac053c053b84b7526dfe2fce
MD5 6c5d03a4f7a4797907311e61b38e07cc
BLAKE2b-256 05b0571811bc53b6fb60cf00726e025c1f5db59bbb9a1b7f0e8b9472c3ceb9ff

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f3f6f9875a0fb271e4a43eeecbbf7de388c5cc35c4c3ca1803f3ea203d6f7a66
MD5 879ad05da3ef1fa700027e8455b26358
BLAKE2b-256 54963b03b251eb3b35a39e3c9a36efad9c93e447a2dee94acff50dd626296af0

See more details on using hashes here.

File details

Details for the file pyk4a_bundle-1.5.0-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for pyk4a_bundle-1.5.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 02c469029e8b1fe56c2658470bcd17cffcef98b3cc869f8b7599aba7d9fbf1d7
MD5 8ea557f7a7e1413e50f4e5379fb98047
BLAKE2b-256 3b23ecacbf4d88da06de0dcfeaa5de8c1ff89045c71a45ed7046fce70ad8d66c

See more details on using hashes here.

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