Package: pyk4a
pyk4aThis 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/PrerequisitesTheAzure-Kinect-Sensor-SDKis required to build this library.
To use the SDK, refer to the installation instructionshere.InstallLinuxLinux specific installation instructionshereInstall both packageslibk4a<major>.<minor>andlibk4a<major>.<minor>-dev. The latter contains the headers and CMake files to build pyk4a.Make sure yourLD_LIBRARY_PATHcontains the directory of k4a.libpipinstallpyk4aWindowsIn most casespip install pyk4ais enough to install this package.When using an anaconda environment, you need to set the environment variableCONDA_DLL_SEARCH_MODIFICATION_ENABLE=1https://github.com/conda/conda/issues/10897Because 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.pipinstallpyk4a--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.dllis required. The automatic detection should be able to find this file.
It is also possible to specify the DLL's directory with the environment variableK4A_DLL_DIR.
IfK4A_DLL_DIRis used, the automatic DLL search is not performed.ExampleFor 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 theexamplefolder.
To execute itopencv-pythonis required.git clone https://github.com/etiennedub/pyk4a.git
cd pyk4a/example
python viewer.pyDocumentationNo documentation is available but all functinos are properlytype hinted.
The code of the main class is a good place to startPyK4A.You can also follow the variousexample folderscripts as reference.Bug ReportsSubmit 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 onwindows.Module DevelopmentInstall required packages:make setupInstall local pyk4a version (compiles pyk4a.cpp):make buildContributionFeel 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:makebuild
makefmtlint
maketestNote: you needclang-formattool(v 11.0+) for formatting CPP code.