OpenCV 3.0 cvAbsDiff() - 没有用于调用 'cvAbsDiff' 的匹配函数
OpenCV 3.0 cvAbsDiff() - No matching function for call to 'cvAbsDiff'
所以我明白了 - 没有匹配函数调用 'cvAbsDiff' 消息,我不知道为什么,但我无法编译这段代码。
Xcode 建议将 cv::Mat 转换为 CvArr。但这是疯狂的方式。
cv::Mat firstFrame;
- (void)processImage:(Mat&)image;
{
cv::Mat diffFrame=image.clone();
cv::Mat currentFrame=image.clone();
cvtColor(image, currentFrame, CV_BGR2GRAY);
if (countNonZero(firstFrame) < 1){firstFrame=currentFrame;}
else
{
cvAbsDiff(firstFrame,currentFrame,image);
// image=diffFrame;
}
}
cvAbsDiff
函数旨在与较旧的 C api 一起使用,它使用 IplImage
而不是 cv::Mat
来存储图像。相反,当使用 C++ 时,您可以只使用 cv::absdiff
函数:
cv::absdiff(firstFrame, currentFrame, image);
为了将来的参考,如果您需要将 cv::Mat
转换为 IplImage
,您可以通过指定它来完成,但通常您应该尽量避免将两者混用 API 风格。
IplImage ipl = myMatImage;.
如果您查看 OpenCV array operations documentation,您将看到列出了各种函数及其 C 和 C++ 变体。
所以我明白了 - 没有匹配函数调用 'cvAbsDiff' 消息,我不知道为什么,但我无法编译这段代码。
Xcode 建议将 cv::Mat 转换为 CvArr。但这是疯狂的方式。
cv::Mat firstFrame;
- (void)processImage:(Mat&)image;
{
cv::Mat diffFrame=image.clone();
cv::Mat currentFrame=image.clone();
cvtColor(image, currentFrame, CV_BGR2GRAY);
if (countNonZero(firstFrame) < 1){firstFrame=currentFrame;}
else
{
cvAbsDiff(firstFrame,currentFrame,image);
// image=diffFrame;
}
}
cvAbsDiff
函数旨在与较旧的 C api 一起使用,它使用 IplImage
而不是 cv::Mat
来存储图像。相反,当使用 C++ 时,您可以只使用 cv::absdiff
函数:
cv::absdiff(firstFrame, currentFrame, image);
为了将来的参考,如果您需要将 cv::Mat
转换为 IplImage
,您可以通过指定它来完成,但通常您应该尽量避免将两者混用 API 风格。
IplImage ipl = myMatImage;.
如果您查看 OpenCV array operations documentation,您将看到列出了各种函数及其 C 和 C++ 变体。