gpt4 book ai didi

c++ - 试图了解 Lineiterator 的用法

转载 作者:太空狗 更新时间:2023-10-29 21:42:53 49 4
gpt4 key购买 nike

正在关注 this文章 我试图了解如何使用 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 会打印出存储在该行中的值。有人可以帮助我了解如何纠正这个问题吗?

最佳答案

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;

关于c++ - 试图了解 Lineiterator 的用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24488289/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com