Not able to record RGB or Depth Images using the simple example python script
bhomaidan1990 opened this issue · 1 comments
Describe the bug
When I run the simple example:
import matplotlib.pyplot as plt
# This will import all the public symbols into the k4a namespace.
import k4a
# Open a device using the static function Device.open().
device = k4a.Device.open()
# In order to start capturing frames, need to start the cameras.
# The start_cameras() function requires a device configuration which
# specifies the modes in which to put the color and depth cameras.
# For convenience, the k4a package pre-defines some configurations
# for common usage of the Azure Kinect device, but the user can
# modify the values to set the device in their preferred modes.
device_config = k4a.DEVICE_CONFIG_BGRA32_2160P_WFOV_2X2BINNED_FPS15
device.start_cameras(device_config)
# Get a capture.
# The -1 tells the device to wait forever until a capture is available.
capture = device.get_capture(-1)
# Open a matplotlib figure to display images.
fig = plt.figure()
ax = []
ax.append(fig.add_subplot(1, 3, 1, label="Color"))
ax.append(fig.add_subplot(1, 3, 2, label="Depth"))
ax.append(fig.add_subplot(1, 3, 3, label="IR"))
# The capture has the following fields that can be read right away:
# color : the color image
# depth : the depth image
# ir : the ir image
im = []
im.append(ax[0].imshow(capture.color.data))
im.append(ax[1].imshow(capture.depth.data, cmap='jet'))
im.append(ax[2].imshow(capture.ir.data, cmap='gray'))
ax[0].title.set_text('Color')
ax[1].title.set_text('Depth')
ax[2].title.set_text('IR')
# Note: The data in the images is in BGRA planes, but the matplotlib
# library expects them to be in RGBA. This results in an inverted color
# display if not properly handled. The user can splice the planes as
# appropriate or use opencv which has a function call to transform
# BGRA into RGBA.
while fig is not None:
# Draw the figure with the images.
plt.pause(.1)
plt.draw()
# Get a new capture.
capture = device.get_capture(-1)
if capture is None:
del fig
break
# Update the images in the figures.
im[0].set_data(capture.color.data)
im[1].set_data(capture.depth.data)
im[2].set_data(capture.ir.data)
# There is no need to delete the capture since Python will take care of
# that in the object's deleter.
# There is no need to stop the cameras since the deleter will stop
# the cameras, but it's still prudent to do it explicitly.
device.stop_cameras()
# There is no need to delete resources since Python will take care
# of releasing resources in the objects' deleters.
I get the following Errors:
[2023-04-03 12:57:24.907] [error] [t=5374] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/dynlib/dynlib_linux.c (82): dynlib_create(). Failed to load shared object libdepthengine.so.2.0 with error: libdepthengine.so.2.0: cannot open shared object file: No such file or directory
[2023-04-03 12:57:24.907] [error] [t=5374] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/deloader/deloader.cpp (75): deloader_init_once(). Failed to Load Depth Engine Plugin (depthengine). Depth functionality will not work
[2023-04-03 12:57:24.907] [error] [t=5374] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/deloader/deloader.cpp (76): deloader_init_once(). Make sure the depth engine plugin is in your loaders path
[2023-04-03 12:57:24.907] [error] [t=5374] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/deloader/deloader.cpp (113): deloader_depth_engine_create_and_initialize(). Failed to load depth engine plugin
[2023-04-03 12:57:24.907] [error] [t=5374] /__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: 108.
[2023-04-03 12:57:24.907] [error] [t=5374] /__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()
[2023-04-03 12:57:24.907] [error] [t=5374] /__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()
[2023-04-03 12:57:24.907] [error] [t=5367] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/dewrapper/dewrapper.c (552): dewrapper_start(). Depth Engine thread failed to start
[2023-04-03 12:57:24.907] [error] [t=5367] /__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()
[2023-04-03 12:57:24.911] [error] [t=5367] /__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()
[2023-04-03 12:57:24.911] [error] [t=5367] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/depth_mcu/depth_mcu.c (362): depthmcu_depth_stop_streaming(). ERROR: cmd_status=0x00000063
[2023-04-03 12:57:24.915] [error] [t=5367] /__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()
[2023-04-03 12:57:24.915] [error] [t=5367] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/queue/queue.c (112): queue_pop(). Queue "Queue_capture" was popped in a disabled state.
[2023-04-03 12:57:24.915] [error] [t=5367] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/sdk/k4a.c (269): capturesync_get_capture(device->capturesync, capture_handle, timeout_in_ms) returned failure in k4a_device_get_capture()
Traceback (most recent call last):
File "./test.py", line 82, in <module>
im.append(ax[0].imshow(capture.color.data))
AttributeError: 'NoneType' object has no attribute 'color'
To Reproduce
Run the past python script after installing k4a
python wheel.
Expected behavior
To be able to run the camera using Python wrapper.
Desktop (please complete the following information):
- OS with Version: Ubuntu 20.04
- SDK Version: 1.41
Additional context
Same Issue on AMD64 or ARM64.
It appears that the program fails to properly load the k4a package/library, the problem here (I think) is that you didn't include the DLLs. The depth engine from the k4a library is proprietary, hance it isn't included by default. Download the depth engine DLL from the SDK github and put it in your project folder. See instructions for more information. I hope this helps.
I am not a developer for this SDK btw.