opencv 错误中的(自适应)阈值(cvarrToMat 中的错误参数(未知数组类型))

发布于 2024-12-17 23:47:51 字数 768 浏览 2 评论 0原文

我试图在我的视频流上使用阈值,但它不起作用。

我的视频流:

Mat *depthImage = new Mat(480, 640, CV_8UC1, Scalar::all(0));

然后我尝试进行自适应阈值处理(也不适用于常规阈值处理)

for(;;){

    if( wrapper->update()){


        wrapper->getDisplayDepth(depthImage);

        cvAdaptiveThreshold(depthImage, depthImage,255,CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY,75,10);


        imshow("Depth", *depthImage);

    }

    int k = waitKey(25);
    if(k == 27 ) exit(0);
}

我收到此错误:

OpenCV 错误:cvarrToMat 中的错误参数(未知数组类型),文件 /Users/olivierjanssens/source/OpenCV-2.3.1/modules/core/src/matrix.cpp,第 646 行 终止调用抛出异常

我做错了什么,我可以完美地显示并看到流。但是当我添加这个阈值时,我得到了前面提到的错误。 (顺便说一句,我对 opencv 相当陌生)。

提前谢谢!

I'm trying to use thresholding on my video stream but it is not working.

My video stream:

Mat *depthImage = new Mat(480, 640, CV_8UC1, Scalar::all(0));

Then i try to do the adaptive thresholding, (also doesn't work with regular thresholding)

for(;;){

    if( wrapper->update()){


        wrapper->getDisplayDepth(depthImage);

        cvAdaptiveThreshold(depthImage, depthImage,255,CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY,75,10);


        imshow("Depth", *depthImage);

    }

    int k = waitKey(25);
    if(k == 27 ) exit(0);
}

I get this error :

OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /Users/olivierjanssens/source/OpenCV-2.3.1/modules/core/src/matrix.cpp, line 646
terminate called throwing an exception

What am i doing wrong, i can get display and see the stream perfectly.But when i add this thresholding i get the error previously mentioned. (i'm rather new to opencv btw).

Thx in advance !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

错爱 2024-12-24 23:47:51

你的 heightImage 是一个指向 cv::Mat 的指针,这对我来说似乎很奇怪......

但是,如果你使用 C++ 语法,那么你会想要使用 C++ 版本的adaptiveThreshold,它处理cv::Mat,具有以下定义:

void adaptiveThreshold(InputArray src, OutputArray dst, double maxValue,
    int adaptiveMethod, int thresholdType, int blockSize, double C);

如果您尚未使用该命名空间,则需要以 cv:: 为前缀。

例如:

Mat *depthImage; // Obtain this using your method
Mat image = *depthImage;  // Obtain a regular Mat to use (doesn't copy data, just headers)

adaptiveThreshold(image, image,255,CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY,75,10);

imshow("Depth Image", *depthImage);
// OR
imshow("Depth Image", image);

Your depthImage is a pointer to a cv::Mat, which to me seems strange...

...but, if you're using the C++ syntax then you'll want to use the C++ version of adaptiveThreshold, which deals with cv::Mat, with the following definition:

void adaptiveThreshold(InputArray src, OutputArray dst, double maxValue,
    int adaptiveMethod, int thresholdType, int blockSize, double C);

which will need prefixed by cv:: if you're not using that namespace already.

For example:

Mat *depthImage; // Obtain this using your method
Mat image = *depthImage;  // Obtain a regular Mat to use (doesn't copy data, just headers)

adaptiveThreshold(image, image,255,CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY,75,10);

imshow("Depth Image", *depthImage);
// OR
imshow("Depth Image", image);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文