从uint8_t到NPY_UINT16 PyArray_SimpleNewFromData.适用于Linux,但不适用于

PyArray_SimpleNewFromData from uint8_t to NPY_UINT16. Works on linux but not on windows

本文关键字:适用于 Linux 不适用 SimpleNewFromData UINT16 uint8 NPY PyArray      更新时间:2023-10-16

我正在使用带有k4a python包装器的kinect 4 azure sdk。 深度的 dtype 是 uint16。它适用于Linux,但不适用于Windows。 在 Windows 上,生成的图像似乎带有锯齿。两个像素中的一个是黑色的。

是什么可以使这段代码在 Linux 和 Windows 上的行为不同?

这是包装器中的相关代码:

uint8_t* buffer = k4a_image_get_buffer(depth_image);
npy_intp dims[2];
dims[0] = k4a_image_get_height_pixels(depth_image);
dims[1] = k4a_image_get_width_pixels(depth_image);
PyArrayObject* np_depth_image = (PyArrayObject*) 
PyArray_SimpleNewFromData(2, (npy_intp*) dims, NPY_UINT16, buffer);
return PyArray_Return(np_depth_image);

https://github.com/etiennedub/pyk4a/blob/master/pyk4a/pyk4a.cpp#L161

我尝试更改第一行,就像我们在 kinect 4 azure sdk 中看到的那样

uint16_t* buffer = (uint16_t*)(void*) k4a_image_get_buffer(depth_image);

https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/82b850ba3c6c5fcebb3e74679896546029379dc5/examples/undistort/main.cpp#L237

这可以通过位移或类似方法解决,但我更愿意了解为什么窗口上的行为不同。

有什么想法吗?

必须更新Surface Pro设备的GPU驱动程序。 https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/840