ubuntu上opencv中的错误/usr/include/opencv2/nonfree/features2d.hpp错误向量
Posted
技术标签:
【中文标题】ubuntu上opencv中的错误/usr/include/opencv2/nonfree/features2d.hpp错误向量【英文标题】:error /usr/include/opencv2/nonfree/features2d.hpp error vector in opencv on ubuntu 【发布时间】:2015-08-06 09:13:53 【问题描述】:这段代码是Opencv的冲浪算法。我的代码不起作用。我正在使用带有 Opencv 3.0.0 和 gcc/g++ 4.8.4 的 Ubuntu 14.04.2。我要遵守“冲浪算法”
错误内容
/usr/include/opencv2/nonfree/features2d.hpp:73:21: 错误: “向量”尚未声明 矢量和关键点)常量; ^
/usr/include/opencv2/nonfree/features2d.hpp:73:27: 错误: 在“
/usr/include/opencv2/nonfree/features2d.hpp:77:21: 错误: “向量”尚未声明 矢量和关键点, ^
/usr/include/opencv2/nonfree/features2d.hpp:77:27: 错误: 在“
'test_surf.cpp'
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
if( argc != 3)
cout <<" Usage: sift input_image output_image" << endl;
return -1;
//cv::initModule_nonfree();
//cout <<"initModule_nonfree() called" << endl;
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
if(! image.data )
cout << "Could not open or find the image" << std::endl ;
return -1;
vector<KeyPoint> keypoints;
Mat descriptors;
// Create a SIFT keypoint detector.
SiftFeatureDetector detector;
detector.detect(image, keypoints);
cout << "Detected " << (int) keypoints.size() << " keypoints" <<endl;
// Compute feature description.
detector.compute(image,keypoints, descriptors);
cout << "Computed feature."<<endl;
// Store description to "descriptors.des".
FileStorage fs;
fs.open("descriptors.des", FileStorage::WRITE);
cout << "Opened file to store the features."<<endl;
fs << "descriptors" << descriptors;
cout << "Finished writing file."<<endl;
fs.release();
cout << "Released file."<<endl;
// Show keypoints in the output image.
Mat outputImg;
Scalar keypointColor = Scalar(255, 0, 0);
drawKeypoints(image, keypoints, outputImg, keypointColor, DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
cout << "Drew keypoints in output image file."<<endl;
//
#ifdef WIN32
namedWindow("Output image", CV_WINDOW_AUTOSIZE );
imshow("Output image", outputImg);
waitKey(0);
#endif
cout << "Generate the output image."<<endl;
imwrite(argv[2], outputImg);
cout << "Done."<<endl;
return 0;
【问题讨论】:
您是否尝试包含标题包含头文件向量
#include <vector>
参考http://www.cplusplus.com/reference/vector/vector/vector/
【讨论】:
以上是关于ubuntu上opencv中的错误/usr/include/opencv2/nonfree/features2d.hpp错误向量的主要内容,如果未能解决你的问题,请参考以下文章
OpenCV、Qt 和 Ubuntu 的 imshow 错误
使用 OpenCV 库(ubuntu)编译错误 Qt Creator
ubuntu 14.04lts 上的奇怪编译错误 c++ opencv 2.4.10
Ubuntu 14.04 的 OpenCV 3.1.0 中缺少文件