【问题标题】:Use OpenCV Threshold with Kinect Image将 OpenCV 阈值与 Kinect 图像结合使用
【发布时间】:2012-02-27 18:40:50
【问题描述】:

我正在尝试将 OpenCV 阈值与 OpenCV VideoCapture 模块检索到的 depthImage 一起使用,但出现以下错误:

OpenCV 错误:未知函数中的参数错误, 文件 PATHTOOPENCV\opencv\modules\core\src\matrix.cpp 第 646 行

我的代码如下:

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

cv::VideoCapture kinect;
cv::Mat rgbMap;
cv::Mat dispMap;
bool newFrame;

void setup()
{
    kinect.open(CV_CAP_OPENNI);
    newFrame = false;
}

void update()
{
    if(kinect.grab())
    {
        kinect.retrieve( rgbMap, CV_CAP_OPENNI_BGR_IMAGE);
        kinect.retrieve( dispMap, CV_CAP_OPENNI_DISPARITY_MAP );
        newFrame = true;
    }
}

void draw()
{
    if(newFrame)
    {
        cv::Mat * _thresSrc = new cv::Mat(dispMap);
        cv::Mat * _thresDst = new cv::Mat(dispMap);

        cvThreshold(_thresSrc, _thresDst, 24, 255, CV_THRESH_BINARY);

        // Draw _thresDst;

        delete _thresSrc;
        delete _thresDst;
        newFrame = false;
    }
}

非常感谢您的帮助

【问题讨论】:

    标签: c++ c opencv image-processing kinect


    【解决方案1】:

    首先,您将 C 接口与 C++ 接口混合在一起,它们不应该混合在一起!

    cv::Mat 属于 C++ 接口,cvThreshold() 属于 C。您应该改用cv::threshold()

    double cv::threshold(const Mat& src, Mat& dst, double thresh, double maxVal, int thresholdType)
    

    参数:

    src – Source array (single-channel, 8-bit of 32-bit floating point)
    dst – Destination array; will have the same size and the same type as src
    thresh – Threshold value
    maxVal – Maximum value to use with THRESH_BINARY and THRESH_BINARY_INV thresholding types
    thresholdType – Thresholding type (see the discussion)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      • 2021-08-02
      相关资源
      最近更新 更多