试图了解Lineiterator的用法 [英] Trying to understand the usage of Lineiterator

查看:4358
本文介绍了试图了解Lineiterator的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这篇文章后,我想了解如何使用lineiterator。我写了以下代码:

  #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 {
buf [i] = *(const Vec3b)* it;
printf(%d\\\
,buf [i]);

}

return 0;

}

但它提供错误:

 错误1错误C2664:'cv :: LineIterator :: LineIterator(const cv :: Mat&,cv :: Point,cv :: Point,int ,bool)':不能将参数2从'int'转换为'cv :: Point'c:\users\acme\documents\visual studio 2010\projects\iterator\opencv1\helloworld.cpp 15 


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


3 IntelliSense:没有构造函数cv :: LineIterator :: LineIterator的实例匹配参数列表c:\users\acme\documents\visual studio 2010\\ \\projects\iterator\opencv1\helloworld.cpp 15



4智能感知:没有运算符*匹配这些操作数c:\users\acme\\ \\documents\visual studio 2010\projects\iterator\opencv1\helloworld.cpp 22

我期望buf会打印我存储的值跨线。有人可以帮我理解如何纠正这个?

$

  LineIterator it(img,Point(1,1),Point(20, 20),8); 

vector< Vec3b> f

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

cerr<< Mat(buf)< endl;


Following this article I am trying to understand how to work with lineiterator. I wrote the following code:

#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;

}

But It gives errors:

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

I am expecting that buf would print me the values stored across the line. Can someone help me understand how to rectify this?

解决方案

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;

这篇关于试图了解Lineiterator的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆