【问题标题】:OpenCV 3.0 cvAbsDiff() - No matching function for call to 'cvAbsDiff'OpenCV 3.0 cvAbsDiff() - 没有用于调用“cvAbsDiff”的匹配函数
【发布时间】:2015-10-05 02:56:04
【问题描述】:

所以我明白了 - 没有匹配函数调用“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;



    }



}

【问题讨论】:

    标签: c++ xcode opencv opencv3.0


    【解决方案1】:

    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++ 变体。

    【讨论】:

      猜你喜欢
      • 2012-10-10
      • 1970-01-01
      • 2018-01-08
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 2020-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多