capture.get_color_image() return null in 1536P
Describe the bug
Hi, capture.get_color_image() return null ,when I set color resolution 1536P and use body tracker.
To Reproduce
‘’‘ Expected behavior
I want to use opencv to show the rgb camera data.It return null in 1536P. but it can run in 1080P.
Logs
[2022-05-07 20:52:11.183] [error] [t=23428] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (51): k4a_image_t_get_context(). Invalid k4a_image_t 0000000000000000 [2022-05-07 20:52:11.183] [error] [t=23428] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (389): Invalid argument to image_get_buffer(). image_handle (0000000000000000) is not a valid handle of type k4a_image_t [2022-05-07 20:52:11.183] [error] [t=23428] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (51): k4a_image_t_get_context(). Invalid k4a_image_t 0000000000000000 [2022-05-07 20:52:11.183] [error] [t=23428] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (420): Invalid argument to image_get_width_pixels(). image_handle (0000000000000000) is not a valid handle of type k4a_image_t [2022-05-07 20:52:11.183] [error] [t=23428] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (51): k4a_image_t_get_context(). Invalid k4a_image_t 0000000000000000 [2022-05-07 20:52:11.183] [error] [t=23428] D:\a\1\s\extern\Azure-Kinect-Sensor-SDK\src\image\image.c (427): Invalid argument to image_get_height_pixels(). image_handle (0000000000000000) is not a valid handle of type k4a_image_t [ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\highgui\src\registry.impl.hpp (114) cv::highgui_backend::UIBackendRegistry::UIBackendRegistry UI: Enabled backends(4, sorted by priority): GTK(1000); GTK3(990); GTK2(980); WIN32(970) + BUILTIN(WIN32UI) [ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load C:\WINDOWS\SYSTEM32\opencv_highgui_gtk455_64.dll => FAILED [ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load opencv_highgui_gtk455_64.dll => FAILED [ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load C:\WINDOWS\SYSTEM32\opencv_highgui_gtk3455_64.dll => FAILED [ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load opencv_highgui_gtk3455_64.dll => FAILED [ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load C:\WINDOWS\SYSTEM32\opencv_highgui_gtk2455_64.dll => FAILED [ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load opencv_highgui_gtk2455_64.dll => FAILED [ INFO:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\highgui\src\backend.cpp (90) cv::highgui_backend::createUIBackend UI: using backend: WIN32 (priority=970) [ INFO:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\highgui\src\window_w32.cpp (3013) cv::impl::Win32BackendUI::createWindow OpenCV/UI: Creating Win32UI window: DepthImage (1) OpenCV(4.5.5) Error: Assertion failed (!_src.empty()) in cv::cvtColor, file C:\build\master_winpack-build-win64-vc15\opencv\modules\imgproc\src\color.cpp, line 182 Failed with exception: OpenCV(4.5.5) C:\build\master_winpack-build-win64-vc15\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
Screenshots
Desktop (please complete the following information):
- OS with Version: windows 11 10.0.22000
- SDK Version: sensor:1.4.1 bodytracking:1.1.1
- Firmware version: Additional context
#pragma once // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License.
#include <assert.h>
#include
#include <k4a/k4a.hpp> #include <k4abt.hpp> #include<opencv2/opencv.hpp>
int display_run() { try { k4a_device_configuration_t device_config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL; device_config.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED; device_config.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32; device_config.color_resolution = K4A_COLOR_RESOLUTION_1536P; device_config.camera_fps = K4A_FRAMES_PER_SECOND_30;
k4a::device device = k4a::device::open(0);
device.start_cameras(&device_config);
k4a::calibration sensor_calibration = device.get_calibration(device_config.depth_mode, device_config.color_resolution);
k4abt::tracker tracker = k4abt::tracker::create(sensor_calibration);
int frame_count = 0;
do
{
k4a::capture sensor_capture;
if (device.get_capture(&sensor_capture, std::chrono::milliseconds(K4A_WAIT_INFINITE)))
{
k4a::image color_img = sensor_capture.get_color_image();
k4a::image depth_img = sensor_capture.get_depth_image();
//color_img = depth_img;
cv::Mat cv_img(color_img.get_height_pixels(), color_img.get_width_pixels(), CV_8UC4, color_img.get_buffer());
cv::namedWindow("DepthImage");
cv::imshow("DepthImage", cv_img);
cv::waitKey(1);
frame_count++;
std::cout << "Start processing frame " << frame_count << std::endl;
if (!tracker.enqueue_capture(sensor_capture))
{
// It should never hit timeout when K4A_WAIT_INFINITE is set.
std::cout << "Error! Add capture to tracker process queue timeout!" << std::endl;
break;
}
k4abt::frame body_frame = tracker.pop_result();
if (body_frame != nullptr)
{
uint32_t num_bodies = body_frame.get_num_bodies();
std::cout << num_bodies << " bodies are detected!" << std::endl;
for (uint32_t i = 0; i < num_bodies; i++)
{
k4abt_body_t body = body_frame.get_body(i);
print_body_information(body);
}
k4a::image body_index_map = body_frame.get_body_index_map();
if (body_index_map != nullptr)
{
print_body_index_map_middle_line(body_index_map);
}
else
{
std::cout << "Error: Failed to generate bodyindex map!" << std::endl;
}
}
else
{
// It should never hit timeout when K4A_WAIT_INFINITE is set.
std::cout << "Error! Pop body frame result time out!" << std::endl;
break;
}
}
else
{
// It should never hit time out when K4A_WAIT_INFINITE is set.
std::cout << "Error! Get depth frame time out!" << std::endl;
break;
}
} while (frame_count < 100);
std::cout << "Finished body tracking processing!" << std::endl;
}
catch (const std::exception& e)
{
std::cerr << "Failed with exception:" << std::endl
<< " " << e.what() << std::endl;
return 1;
}
return 0;
}
int main() { display_run(); return 0; }