شاهد إطارًا أسود بدلاً من صورة عمق مع Asus Xtion Pro و OpenCV

StackOverflow https://stackoverflow.com/questions/19823873

  •  04-07-2022
  •  | 
  •  

سؤال

يمكنني بالفعل الحصول على صورة RGB من Asus Xtion الخاص بي ولكن لا يمكنني الحصول على أي صورة عمق. أرى صورة سوداء بدلاً من ذلك ولا تظهر أي خطأ.

عينة SimpleView المقدمة مع OpenNi Works ، لذلك أعتقد أنها ليست المستشعر ، وليس المكتبة و 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 نموذج رمز يستخدم هذا الرمز في الواقع لاسترداد وعرض خريطة العمق:

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 );
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top