【问题标题】:Access to pixel value depth map访问像素值深度图
【发布时间】:2012-01-19 17:05:00
【问题描述】:

我正在尝试使用 kinect、openni 和 opencv 访问深度图的像素值。我正在使用此代码

Mat depth;
VideoCapture capture1(CV_CAP_OPENNI);
capture1.grab();
capture1.retrieve(depth,CV_CAP_OPENNI_DEPTH_MAP);
imshow("depth",depth);

waitKey(0);
cout << depth.at<unsigned>(20,20);
system("PAUSE");

程序向我显示深度图,但当我尝试访问该值时,会产生错误。但如果你放:

cout << depth;

然后显示所有值。

【问题讨论】:

  • 这是哪个版本的 OpenCV?

标签: c++ visual-studio-2010 opencv kinect


【解决方案1】:

由于你没有指定错误,我会试一试:问题似乎是你试图从另一个Mat访问元素:你创建的那个是命名为depth,但在cout 调用中引用的名称为depthshow

【讨论】:

    【解决方案2】:

    根据documentation for CAP_OPENNI_DEPTH_MAP,您的Mat 每个像素应该有16 位无符号整数数据,而不是您尝试使用的32 位unsigned int。因此,请改用以下内容:

    // uint16_t available in C++11
    cout << depth.at<uint16_t>(20,20) << " millimetres";
    

    // not 100% sure that all compilers produce 16 bits fields
    cout << depth.at<unsigned short int>(20,20) << " millimetres"; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-21
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-21
      • 1970-01-01
      相关资源
      最近更新 更多