PyArray_SimpleNewFromData从uint8_t到NPY_UINT16。在Linux上有效,但在Windows上无效

问题描述 投票:0回答:1

我正在将kinect 4 azure sdk与k4a python包装器一起使用。深度的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上的行为不同。

有什么想法吗?

python c++ numpy kinect
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.