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

标签 c++ opencv

此代码在 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;使用命名空间 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/

相关文章:

python - 调整不适合内存的大图像

c++ - 在 Switch 语句中声明变量

c++ - 如何在 win32 中更改工具栏按钮的位图?

c++ - 需要从输入文件中跳过换行符 (\n)

c++ - 创建巨大的低多边形地形

opencv - 找到矩形内角点

c++ - 将缓冲区内容返回到 OpenGL 中的纹理

python - Opencv:检测 FFT 上最亮的线

opencv - 将Cmake与PCL和OpenCV一起使用

visual-c++ - HaarTraining 与 OpenCV 错误