2015-08-06 2 views
-1

Ce code est l'algorithme de surf de OpenCV. Mon code ne fonctionne pas. J'utilise Ubuntu 14.04.2 avec Opencv 3.0.0 et gcc/g ++ 4.8.4. Je veux complie sur "algorithme de surf"erreur vecteur d'erreur de /usr/include/opencv2/nonfree/features2d.hpp dans OpenCV sur ubuntu

contenu ERREUR

/usr/include/opencv2/nonfree/features2d.hpp:73:21: error: ‘vector’ has not been declared vector& keypoints) const; ^

/usr/include/opencv2/nonfree/features2d.hpp:73:27: error: expected ‘,’ or ‘...’ before ‘<’ token vector& keypoints) const; ^

/usr/include/opencv2/nonfree/features2d.hpp:77:21: error: ‘vector’ has not been declared vector& keypoints, ^

/usr/include/opencv2/nonfree/features2d.hpp:77:27: error: expected ‘,’ or ‘...’ before ‘<’ token vector& keypoints,

'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

Avez-vous essayé d'inclure l'en-tête ? –

+0

double possible de (http://stackoverflow.com/questions/27418668/nonfree-module-is-missing-in-opencv-3-0) [Module non libre est manquant dans OpenCV 3.0] – Miki

Répondre