Coder Social home page Coder Social logo

py-k4a's Introduction

Alpha python library for Azure Kinect

This library is pre-alpha, weekend hack quality. It can capture single frames correctly, but it likely has lots of bugs, and there are definitely missing features.

Prereqs.

  • You have the Kinect SDK installed and k4viewer works for you.
  • You have Python3 development libraries installed. (apt-get install python3-dev)
  • You have an Azure Kinect device

Build/Install

git clone https://github.com/brendandburns/py-k4a.git
cd py-k4a
python3 setup.py build
sudo python3 setup.py install
python3 example.py

If all goes well, this will leave a file named test.jpg in your directory with a single frame capture from your device.

TODO

Add support for Audio and IMU. Fix bugs. Accept PRs.

Instructions for Window Install

This may not be the most elegant or minimal solution, but it worked for me on two different Windows 10 machines.

Prereqs.

  • You have the Kinect SDK installed and k4viewer works for you.
    • Find (corresponding on your install) following directories/files:
      • C:\Program Files\Azure Kinect SDK v1.2.0\sdk\include\k4a
      • C:\Program Files\Azure Kinect SDK v1.2.0\sdk\windows-desktop\x86\release\lib\k4a.lib
      • C:\Program Files\Azure Kinect SDK v1.2.0\sdk\windows-desktop\x86\release\bin\k4a.dll
      • C:\Program Files\Azure Kinect SDK v1.2.0\sdk\windows-desktop\x86\release\bin\k4a.pyd
      • C:\Program Files\Azure Kinect SDK v1.2.0\sdk\windows-desktop\x86\release\bin\depthengine_2_0.dll
  • You have Python 3.6 or newer development libraries installed.
    • This may be installed on your computer simply as Python.
    • Note the following directories and add them to your user Path
      • C:\Users\amy\AppData\Local\Programs\Python\Python37\include
      • C:\Users\amy\AppData\Local\Programs\Python\Python37\DLLs
      • C:\Users\amy\AppData\Local\Programs\Python\Python37\libs
  • You have a C compiler
    • e.g., VS2019 with C++ desktop development tools, C++/CLI, and most recent Windows 10 SDK installed
      • Make sure your environmental variables are set, i.e. CMAKE_C_COMPILER should point to cl.exe inside VS2019
        • e.g., C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx86\x86\cl.exe
  • Copy elements from the SDK to your Python directories and set environment and path variables
    • Add following directory (equivalent on your machine) to your user Path
      • C:\Program Files\Azure Kinect SDK v1.2.0\sdk\include
      • at this time, make sure you also have the Python paths listed above
    • Copy the k4a folder of the SDK to your Python "include" folder (see example directories above)
    • Copy the k4a.dll and k4a.pyd of the SDK to your Python DLLs folder (see example directories above)
    • Copy the k4a.lib to your Python lib folder (see example directories above)
    • Create an environmental variable LINK pointing to k4a.lib, with quotes!
      • e.g., "C:\Program Files\Azure Kinect SDK v1.2.0\sdk\windows-desktop\amd64\release\lib\k4a.lib"
  • You have an Azure Kinect device

Build/Install

git clone https://github.com/brendandburns/py-k4a.git
cd py-k4a
python setup.py build
python setup.py install
python example.py

If all goes well, this will leave a file named test.jpg in your directory with a single frame capture from your device.

TODO

Add support for Audio and IMU. Fix bugs. Accept PRs.

py-k4a's People

Contributors

amy-caali avatar brendandburns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

py-k4a's Issues

build\lib.win-amd64-3.7\k4a.cp37-win_amd64.pyd : fatal error LNK1120: 18 unresolved externals

Followed the steps in the documentation. Getting error as follows:

capture.obj : error LNK2001: unresolved external symbol __imp_k4a_image_release
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_capture_get_depth_image
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_image_get_buffer
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_image_get_stride_bytes
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_image_get_size
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_capture_release
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_capture_get_ir_image
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_device_get_capture
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_capture_get_color_image
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_image_get_height_pixels
capture.obj : error LNK2001: unresolved external symbol __imp_k4a_image_get_width_pixels
device.obj : error LNK2001: unresolved external symbol __imp_k4a_device_get_version
device.obj : error LNK2001: unresolved external symbol __imp_k4a_device_stop_cameras
device.obj : error LNK2001: unresolved external symbol __imp_k4a_device_open
device.obj : error LNK2001: unresolved external symbol __imp_k4a_device_get_serialnum
device.obj : error LNK2001: unresolved external symbol __imp_k4a_device_get_installed_count
device.obj : error LNK2001: unresolved external symbol __imp_k4a_device_close
device.obj : error LNK2001: unresolved external symbol __imp_k4a_device_start_cameras

k4a_capture_t_get_context(). Invalid k4a_capture_t 000002B26D409130

(KinectDK3.7) D:\InstallPath\Source\py-k4a>python example.py
Opened device 000204192912 (('rgb', (1, 6, 102)), ('depth', (1, 6, 75)), ('audio', (1, 6, 14)), ('depth_sensor', (6109, 7, 0)))

Capture: 2160 x 3840 @ 0.0
Closed
[2020-08-21 17:57:45.783] [error] [t=25180] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\allocator\allocator.c (118): k4a_capture_t_get_context(). Invalid k4a_capture_t 000002B26D409130
[2020-08-21 17:57:45.783] [error] [t=25180] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\allocator\allocator.c (295): Invalid argument to capture_dec_ref(). capture_handle (000002B26D409130) is not a valid handle of type k4a_capture_t
Windows fatal exception: access violation

Current thread 0x0000625c (most recent call first):

Get the Depth Data

Thank you for this python library for Kinect Azure.

I could run the example.py successfully. But how can I get access to the depth data? I want the depth information to further be processed by some other algorithms.

I added depth = k4a.capture_get_depth_image(capture) and k4a.image_release(depth). But it did not obtain the depth.

Thanks

lacking image and capture release

I noticed this doesn't have image and capture release support, which most online examples show as part of the proper way to grab images from the kinect, e.g, https://docs.microsoft.com/en-us/azure/kinect-dk/retrieve-images. (I also ran into buffer/memory overload issues when I did not use image release.)

The attached files contain the updates needed to port k4a_image_release(img) to this Python module; I also tried to implement k4a_capture_release(capture) but am not sure if it's working. Would love further input!

files.zip

k4a.pyd file

Hello everyone:
I am running this on windows, and goes on to the last step "python example.py".
But it did not find k4a module.
I was also do not find k4a.pyd in SDK folder.
I guess it is because of the vision of Azure Kinect SDK . who can send k4a.pyd to me?

Running on Docker

Has anyone tried to run this on a docker image? I'm starting this with this command :

docker run -it --rm --privileged \
-v ~/includes:/usr/include/k4a \
-v /usr/lib/aarch64-linux-gnu/libk4arecord.so:/usr/lib/aarch64-linux-gnu/libk4arecord.so \
-v /usr/lib/aarch64-linux-gnu/libk4arecord.so.1.4:/usr/lib/aarch64-linux-gnu/libk4arecord.so.1.4 \
-v /usr/lib/aarch64-linux-gnu/libk4arecord.so.1.4.0:/usr/lib/aarch64-linux-gnu/libk4arecord.so.1.4.0 \
-v /usr/lib/aarch64-linux-gnu/libk4a.so:/usr/lib/aarch64-linux-gnu/libk4a.so \
-v /usr/lib/aarch64-linux-gnu/libk4a.so.1.4:/usr/lib/aarch64-linux-gnu/libk4a.so.1.4 \
-v /usr/lib/aarch64-linux-gnu/libk4a.so.1.4.0:/usr/lib/aarch64-linux-gnu/libk4a.so.1.4.0 \
-v /usr/lib/aarch64-linux-gnu/libdepthengine.so.2.0:/usr/lib/aarch64-linux-gnu/libdepthengine.so.2.0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=:0 \
tf113opencv:latest /bin/bash

and tf113opencv:latest... works for many other things in my case. Point is that when running example.py, I get this output :

root@df76993e312f:~/py-k4a# python3 example.py
Opened device 000211394812 (('rgb', (1, 6, 107)), ('depth', (1, 6, 78)), ('audio', (1, 6, 14)), ('depth_sensor', (6109, 7, 0)))

Fatal Python error: Segmentation fault

Thread 0x0000007f8a297010 (most recent call first):
  File "example.py", line 19 in <module>
Segmentation fault (core dumped)

This runs on ubnutu on ARM64. The example runs well outside of Docker, but I would like to containerize this. Thoughts?

build issue on windows

Hello! I am trying to build your code with Python 3.7 and Visual Studio 2017 both installed on a Windows 10 machine. I'm not an expert at compiling c-code with Python, but I'm getting an error that makes me think I might be missing a header file. See below and let me know if you have any suggestions. Thanks so much!

capture.c(3): fatal error C1083: Cannot open include file: 'k4a/k4a.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe' failed with exit status 2

Should recoding and playback functionalities be in its own libary?

Hello, thank you for starting this project.

I think about adding the capabilities for the recording. I noticed that in the C++ project the record functions are separated in an extra library. Before starting to putting work on this project, should the recording and playback functionalities be added into this python package or should it kept separate as in the C++ library. Something like py-k4arecord
From my point of view, it seems like that this could be implemented in one package, however I am happy to hear some other opinions.

See recording library here

Dependency on Library Version

Hello,

Thank your for this awesome project, I was wondering if there is a strong dependency to the k4a Version, currently there is the version 1.3.0 out, however the Readme suggests that this was built on 1.2.0 - is there a major difference one should be aware of?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.