gpt4 book ai didi

c++ - Opencv C++ : error: 'it' does not name a type

转载 作者:太空宇宙 更新时间:2023-11-03 22:58:02 25 4
gpt4 key购买 nike

这段代码在 windows 上运行完美,但我试图在 linux 上运行它,但它给出了这个错误:

In function ‘void kmline(cv::Mat, std::vector >&)’:| error: ‘it’ does not name a type| error: expected‘;’ before ‘it’| error: ‘it’ was not declared in this scope| ||=== Build failed: 3 error(s), 0

warning(s) (0 minute(s), 3 second(s)) ===|

代码:

void kmline( Mat image, std::vector<Point>& points )

{.
.
.
.
if (points.size() > 1) //we have 2 points
{

for (auto it = points.begin(); it != points.end(); ++it)
{


}
}

}

最佳答案

使用g++ main.cpp -std=c++11 -lopencv_core -lopencv_highgui 编译并添加using namespace cv;使用命名空间标准;并包含对我有用的内容。

#include <vector>
#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

void kmline( Mat image, std::vector<Point>& points )

{
if (points.size() > 1) //we have 2 points
{

for (auto it = points.begin(); it != points.end(); ++it)
{


}

}
}

int main()
{
return 0;
}

关于c++ - Opencv C++ : error: 'it' does not name a type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24848651/

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