question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to diagnose K4AException for device.open() error

See original GitHub issue

Hello! This is a great project and I want to thank you for making this. I am getting an error in the last mile.

Summary: I’m trying to test whether I can open my Kinect DK from an Ubuntu 18.04 docker container running on an ARM64 device with pyk4a.

Repro:

  • Create an Ubuntu 18.04 docker container and run on ARM64 device (also running linux, a version of RHEL).
  • Install Azure Kinect Sensor SDK according to the instructions on the GitHub repo here. Version 1.4 and installed from inside the running docker container.
  • Install py4a with pip with Python 3.6.9 (installed with apt-get install python3-dev).
  • Run the example devices.py for device check.

Output and traceback:

Available devices: 1
---------------------------------------------------------------------------
K4AException                              Traceback (most recent call last)
<ipython-input-7-65eaaf62310e> in <module>
      6 for device_id in range(cnt):
      7     device = PyK4A(device_id=device_id)
----> 8     device.open()
      9     print(f"{device_id}: {device.serial}")
     10     device.close()

/usr/local/lib/python3.6/dist-packages/pyk4a/pyk4a.py in open(self)
     66         if self.opened:
     67             raise K4AException("Device already opened")
---> 68         self._device_open()
     69 
     70     def close(self):

/usr/local/lib/python3.6/dist-packages/pyk4a/pyk4a.py in _device_open(self)
     83     def _device_open(self):
     84         res, handle = k4a_module.device_open(self._device_id, self.thread_safe)
---> 85         _verify_error(res)
     86         self._device_handle = handle
     87 

/usr/local/lib/python3.6/dist-packages/pyk4a/errors.py in _verify_error(res)
     16     res = Result(res)
     17     if res == Result.Failed:
---> 18         raise K4AException()
     19     elif res == Result.Timeout:
     20         raise K4ATimeoutException()

K4AException: 

I also tried from the command line and Python interpreter inside the docker container:

Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyk4a import PyK4A, connected_device_count
>>> cnt = connected_device_count()
>>> print(cnt)
1
>>> device = PyK4A(device_id=0)
>>> device.open()
[2021-04-10 16:15:38.616] [error] [t=18753] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/usbcommand/usbcommand.c (370): find_libusb_device(). Unable to open LIBUSB at index 0
[2021-04-10 16:15:38.618] [error] [t=18753] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/depth_mcu/depth_mcu.c (68): usb_cmd_create(USB_DEVICE_DEPTH_PROCESSOR, device_index, NULL, &depthmcu->usb_cmd) returned failure in depthmcu_create()
[2021-04-10 16:15:38.618] [error] [t=18753] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/sdk/k4a.c (133): depthmcu_create(index, &device->depthmcu) returned failure in k4a_device_open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/pyk4a/pyk4a.py", line 68, in open
    self._device_open()
  File "/usr/local/lib/python3.6/dist-packages/pyk4a/pyk4a.py", line 85, in _device_open
    _verify_error(res)
  File "/usr/local/lib/python3.6/dist-packages/pyk4a/errors.py", line 18, in _verify_error
    raise K4AException()
pyk4a.errors.K4AException

Please let me know if you wish for more information. This is likely an SDK issue, but if you have any clues I’d be really grateful. Thanks so much! Best regards.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
shagrencommented, Apr 15, 2021
  1. Please run docker with -v /dev/bus/usb:/dev/bus/usb --privileged
  2. You can use kinect without depth camera:
import pyk4a
config = pyk4a.Config(depth_mode=pyk4a.DepthMode.OFF, synchronized_images_only=False)
device = pyk4a.PyK4A(config=config)
device.open()
print(device.serial)
device.start()
capture = device.get_capture()
print(capture.color)
  1. You cannot start depth camera, next error will be raised:
[2021-04-15 08:41:15.363] [error] [t=74] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/dewrapper/dewrapper.c (154): depth_engine_start_helper(). Depth engine create and initialize failed with error code: 204.
[2021-04-15 08:41:15.363] [error] [t=74] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/dewrapper/dewrapper.c (160): deresult == K4A_DEPTH_ENGINE_RESULT_SUCCEEDED returned failure in depth_engine_start_helper()
[2021-04-15 08:41:15.363] [error] [t=74] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/dewrapper/dewrapper.c (194): depth_engine_start_helper(dewrapper, dewrapper->fps, dewrapper->depth_mode, &depth_engine_max_compute_time_ms, &depth_engine_output_buffer_size) returned failure in depth_engine_thread()
[2021-04-15 08:41:15.363] [error] [t=62] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/dewrapper/dewrapper.c (552): dewrapper_start(). Depth Engine thread failed to start
[2021-04-15 08:41:15.363] [error] [t=62] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/depth/depth.c (398): dewrapper_start(depth->dewrapper, config, depth->calibration_memory, depth->calibration_memory_size) returned failure in depth_start()
[2021-04-15 08:41:15.363] [error] [t=62] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/depth_mcu/depth_mcu.c (359): cmd_status == CMD_STATUS_PASS returned failure in depthmcu_depth_stop_streaming()
[2021-04-15 08:41:15.363] [error] [t=62] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/depth_mcu/depth_mcu.c (362): depthmcu_depth_stop_streaming(). ERROR: cmd_status=0x00000063
[2021-04-15 08:41:15.363] [error] [t=62] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/sdk/k4a.c (895): depth_start(device->depth, config) returned failure in k4a_device_start_cameras()
  1. I think problem with OpenGL which is required for Kinect Depthengine. For linux OpenGL usualy available via X server. You can play with X server inside your container.
  2. Please share you results here 😃
1reaction
lpasselincommented, May 19, 2021

Closing the issue because it is probably not caused by pyk4a. But let’s continue the discussion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to diagnose K4AException for device.open() error
Install Azure Kinect Sensor SDK according to the instructions on the GitHub repo here. Version 1.4 and installed from inside the running docker...
Read more >
Azure Kinect Sensor SDK: k4a::device - Microsoft Open Source
Open a k4a device. Throws error on failure. See also: k4a_device_open. k4a; device; Generated by doxygen 1.8.
Read more >
etiennedub/pyk4a: Python 3 wrapper for Azure-Kinect ... - GitHub
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...
Read more >
azure kinect Failed to open device! - Microsoft Q&A
we open the cmd windows to find some errors bellow. 3 devices has ... (360): find_libusb_device(). libusb device(s) are all unavalable.
Read more >
Azure Kinect unable to open device error - TouchDesigner forum
You can also set the environment variable K4A_ENABLE_LOG_TO_A_FILE to 1 to enable debug logging which might give more information.It will create ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found