此代码在 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
block 引用>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;使用命名空间 std;并包括对我有用的内容。
#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/