【问题标题】:See a black frame instead of a depth image with ASUS Xtion Pro and OpenCV使用 ASUS Xtion Pro 和 OpenCV 查看黑框而不是深度图像
【发布时间】:2013-11-06 22:10:28
【问题描述】:

我实际上可以从我的 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;
}

谢谢!

【问题讨论】:

  • 深度缓冲区实际上是全零还是只是非常小的数字,所以看起来像黑色?
  • 如何检查深度缓冲区? (对不起,愚蠢的问题)
  • 啊抱歉,我的意思是检查 depth Mat 在某些点的内容,看看它包含什么样的值。原因:深度图可能是正确的,但您可能需要对其进行缩放才能看到。
  • Mmmmmh,现在我出现以下错误:OpenNI_OpenCV_TrackingColorObject(4077,0x7fff7658e310) malloc: *** error for object 0x106c08000: pointer being free was not assigned.
  • 哦,我得到了以下信息:[43, 4, 43] [4, 43, 4] [43, 4, 46] [4, 46, 4] [46, 4, 49] [4, 46, 4] [0, 0, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0 ] [0, 0, 0] [0, 0, 0] [0, 0, 0] [0, 0, 0]

标签: c++ opencv openni asus-xtion


【解决方案1】:

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 );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    • 2013-11-25
    • 1970-01-01
    • 2018-01-05
    • 2016-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多