首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >试着理解Lineiterator的用法

试着理解Lineiterator的用法
EN

Stack Overflow用户
提问于 2014-06-30 10:42:16
回答 1查看 4.9K关注 0票数 3

文章之后,我试图了解如何使用lineiterator。我编写了以下代码:

代码语言:javascript
复制
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;


int main( )
{

     Mat img = imread("C:\\Users\\Acme\\Desktop\\image-processing\\2.bmp");


LineIterator it(img, 1, 200, 8);
LineIterator it2 = it;

vector<Vec3b> buf(it.count);

for(int i = 0; i < it.count; i++, ++it)
{
    buf[i] = *(const Vec3b)*it;
printf("%d\n", buf[i]);

}

      return 0;

}

但它带来了错误:

代码语言:javascript
复制
Error   1   error C2664: 'cv::LineIterator::LineIterator(const cv::Mat &,cv::Point,cv::Point,int,bool)' : cannot convert parameter 2 from 'int' to 'cv::Point'  c:\users\acme\documents\visual studio 2010\projects\iterator\opencv1\helloworld.cpp 15


Error   2   error C2100: illegal indirection    c:\users\acme\documents\visual studio 2010\projects\iterator\opencv1\helloworld.cpp 22


3   IntelliSense: no instance of constructor "cv::LineIterator::LineIterator" matches the argument list c:\users\acme\documents\visual studio 2010\projects\iterator\opencv1\helloworld.cpp 15



4   IntelliSense: no operator "*" matches these operands    c:\users\acme\documents\visual studio 2010\projects\iterator\opencv1\helloworld.cpp 22

我期望buf会打印出存储在行另一边的值。有人能帮我弄清楚怎么纠正吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-30 12:05:59

代码语言:javascript
复制
LineIterator it(img, Point(1,1), Point(20,20), 8);

vector<Vec3b> buf;   

for(int i=0; i<it.count; i++)
{
    buf.push_back( Vec3b(*it) );
    it++;
}

cerr << Mat(buf) << endl;
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24488289

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档