是否可以创建和使用MatIterators数组?

时间:2014-02-12 21:02:27

标签: c++ arrays qt opencv

示例代码:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/video/video.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{    
    Mat a = Mat::zeros(4,4,CV_8UC1);
    Mat b = Mat::zeros(4,4,CV_8UC1);

    MatIterator_<uchar> it[2];
    it[0] = a.begin<uchar>;
    it[1] = b.begin<uchar>;
}

我目前正在开发一个具有多个相关图像的项目,其中制作一个迭代器数组可以简化代码并使其易于遵循,我更愿意遵守。

甚至可以使用MatIterators数组吗?如果是这样,我将如何正确使用它们。

我还有其他几个问题的解决方案,例如使用颜色通道将图像集成在一起,然后使用一个MatIterator处理所有内容,或者为每个单独的图像创建单独的MatIterator,然后从那里开始。

目前在Ubuntu 12.04的最新版QT中使用OpenCV 2.4(更新和升级)

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

代表我出错。上面代码中的所有内容都是正确的,除了我在使用指针后忘记包含括号。正确的代码如下:

int main()
{    
    Mat a = Mat::zeros(4,4,CV_8UC1);
    Mat b = Mat::zeros(4,4,CV_8UC1);

    MatIterator_<uchar> it[2];
    it[0] = a.begin<uchar>(); //<--------- the brackets that I forgot
    it[1] = b.begin<uchar>(); //<--------- same here
}

抱歉这样一个世俗的错误。

相关问题