Pregunta

De hecho, puedo obtener una imagen RGB de mi ASUS Xtion pero no puedo obtener ninguna imagen de profundidad. En su lugar, veo una imagen negra y no aparece ningún error.

La muestra de SimpleView dada con OpenNi funciona, por lo que supongo que no es el sensor, ni la biblioteca y OpenCV parece funcionar correctamente.

¿Alguna idea?

Aquí está mi código:

#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;
}

¡Gracias!

¿Fue útil?

Solución

los Código de muestra de OpenCV realmente usa este código para recuperar y mostrar el mapa de profundidad:

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 );
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top