c – 将OpenCV阈值与Kinect图像一起使用

我正在尝试使用OpenCV阈值和OpenCV VideoCapture模块检索的depthImage,但是我收到以下错误:

OpenCV Error: Bad argument in unknown function,
file PATHTOOPENCV\opencv\modules\core\src\matrix.cpp line 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接口混合在一起,它们不应混合在一起!

cv :: Mat属于C接口,cvThreshold()属于C.你应该使用cv::threshold()代替:

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

Parameters:

06001

上一篇:[ToneTuneToolkit][019]安卓平台下对象的旋转及缩放


下一篇:Kinect数据