gpt4 book ai didi

c++ - 使用 ASUS Xtion Pro 和 OpenCV 查看黑框而不是深度图像

转载 作者:行者123 更新时间:2023-11-28 07:18:50 25 4
gpt4 key购买 nike

我实际上可以从我的 ASUS Xtion 获取 RGB 图像,但无法获取任何深度图像。我看到的是黑色图像,没有错误显示。

OpenNI 提供的示例 SimpleView 有效,所以我猜它不是传感器,不是库,OpenCV 似乎可以正常工作。

有什么想法吗?

这是我的代码:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char* argv[] )
{

cout << "Device opening ..." << endl;
VideoCapture captureStream;
captureStream.open(CV_CAP_OPENNI_ASUS);


if( !captureStream.isOpened() ){
cout << "Can not open capture object." << endl;
return -1;
}

for(;;){
Mat depth;

if( !captureStream.grab() ){
cout << "ASUS Xtion can not grab images." << endl;
return -1;
}else
if( captureStream.retrieve( depth, CV_CAP_OPENNI_DEPTH_MAP) )
imshow("depth",depth);

if( waitKey( 30 ) == 27 ) break;

}

return 0;
}

谢谢!

最佳答案

OpenCV sample code实际上使用此代码来检索和显示深度图:

Mat depth;
capture.retrieve( depth, CV_CAP_OPENNI_DEPTH_MAP )
const float scaleFactor = 0.05f;
Mat show;
depth.convertTo( show, CV_8UC1, scaleFactor );
imshow( "depth map", show );

关于c++ - 使用 ASUS Xtion Pro 和 OpenCV 查看黑框而不是深度图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19823873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com