[英]Opencv c++: error: 'it' does not name a type
這段代碼可以在Windows上完美運行,但是我試圖在linux上運行,但出現此錯誤:
在函數'void kmline(cv :: Mat,std :: vector>&)':| 錯誤:“它”沒有命名類型| 錯誤:預期為';' 在“它”之前| 錯誤:未在此范圍中聲明“它” | || ===構建失敗:3個錯誤,0
警告(0分鍾,3秒)=== |
碼:
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
編譯,並使用命名空間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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.