PyArray_SimpleNewFromData 从 uint8_t 到 NPY_UINT16。适用于 linux 但不适用于 windows

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

我正在使用带有 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

这可能可以通过移位或类似方法解决,但我更愿意理解为什么 windows.

上的行为不同

有什么想法吗?

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