在这文章之后,我试图了解如何使用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 < it.count; i++, ++it)
{
buf[i] = *(const Vec3b)*it;
printf("%d\n", buf[i]);
}
return 0;
}但它带来了错误:
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会打印出存储在行另一边的值。有人能帮我弄清楚怎么纠正吗?
发布于 2014-06-30 12:05:59
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;https://stackoverflow.com/questions/24488289
复制相似问题