1. 借助opencv的Mat函数
参考这位博主的文章第二部分即可
2. 直接从Azure Kinect SDK提供的函数提取原始数据
k4a_image_t depth_image = k4a_capture_get_depth_image(originalCapture);
int depthWidth = k4a_image_get_width_pixels(depth_image);
int depthHeight = k4a_image_get_height_pixels(depth_image);
uint16_t *depthData = (uint16_t*)(void *)k4a_image_get_buffer(depth_image);
QFile outfile(GlobalDirPath::getUserDataPath()
+ "/" + GlobalDirPath::userFolder
+ "/" + "TestPictures/depth_data.dat");
if(outfile.open(QIODevice::WriteOnly)){
QTextStream stream(&outfile);
stream.setCodec("utf-8");
for(int i=0; i<depthHeight; ++i){
for(int j=0; j<depthWidth; ++j){
stream << (float)depthData[i*depthWidth+j] << ",";
}
stream << endl;
}
outfile.close();
}