c++ - 是否可以创建和使用 MatIterator 数组?

标签 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 数组吗?如果是这样,我该如何正确使用它们。

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

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

感谢您的帮助。

最佳答案

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

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
}

对于这样一个普通的错误感到抱歉。

关于c++ - 是否可以创建和使用 MatIterator 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21739535/

相关文章:

c++ - 重定位 vector c++之前的剩余内存

c++ - Visual Studio 静态链接(freeglut,glew)

c++ - 串行通信 - 我无法将传入的 char 数组转换为 int

html - 使用Qwebview将数据发送到嵌入在QT gui中的html网站

python - 阻止QFileDialog中的文件操作,例如复制、查看、删除等

c++ - 如何制作透明代理模型: QAbstractProxyModel?

C++ 不同 -> 和 "."

c++ - SDL: Blitting BMP to window surface 黑屏之谜

php - 将包含对象的数组展平/简化为数组数组

javascript - 如何使用 lodash 根据值对嵌套数组进行排序?