此代码是Opencv的冲浪算法。我的代码不起作用。我正在使用Ubuntu 14.04.2与Opencv 3.0.0和gcc / g ++ 4.8.4。我想要编译"冲浪算法"
错误内容
/usr/include/opencv2/nonfree/features2d.hpp:73:21:错误: 'vector'尚未宣布 矢量&安培;关键点)const; ^
/usr/include/opencv2/nonfree/features2d.hpp:73:27:错误: 在'<'标记之前预期','或'...' 矢量&安培;关键点)const; ^
/usr/include/opencv2/nonfree/features2d.hpp:77:21:错误: 'vector'尚未宣布 矢量&安培;关键点, ^
/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;
}
答案 0 :(得分:1)