c++ - OpenCV 3.0.0 SurfFeatureDetector and SurfDescriptorExtractor Errors -


i attempting implement opencv 3.0.0 surf feature description , detection after running sample code on opencv site, receive load of errors related surf. idea of going wrong? thanks!

#include <stdio.h> #include <iostream> #include "opencv2/core.hpp" #include "opencv2/features2d.hpp" #include "opencv2/highgui.hpp" #include "opencv2/calib3d.hpp" #include "opencv2/xfeatures2d.hpp" #include <opencv2/nonfree/nonfree.hpp>  using namespace cv; using namespace cv::xfeatures2d;  void readme();  /** @function main */ int main(int argc, char** argv) {     if (argc != 3)     {         readme(); return -1;     }      mat img_object = imread(argv[1], imread_grayscale);     mat img_scene = imread(argv[2], imread_grayscale);      if (!img_object.data || !img_scene.data)     {         std::cout << " --(!) error reading images " << std::endl; return -1;     }      //-- step 1: detect keypoints using surf detector     int minhessian = 400;      ptr<surf> detector = surf.create(minhessian);      std::vector<keypoint> keypoints_object, keypoints_scene;      detector.detect(img_object, keypoints_object);     detector.detect(img_scene, keypoints_scene);      //-- step 2: calculate descriptors (feature vectors)     surfdescriptorextractor extractor;      mat descriptors_object, descriptors_scene;      extractor.compute(img_object, keypoints_object, descriptors_object);     extractor.compute(img_scene, keypoints_scene, descriptors_scene);      //-- step 3: matching descriptor vectors using flann matcher     flannbasedmatcher matcher;     std::vector< dmatch > matches;     matcher.match(descriptors_object, descriptors_scene, matches);      double max_dist = 0; double min_dist = 100;      //-- quick calculation of max , min distances between keypoints     (int = 0; < descriptors_object.rows; i++)     {         double dist = matches[i].distance;         if (dist < min_dist) min_dist = dist;         if (dist > max_dist) max_dist = dist;     }      printf("-- max dist : %f \n", max_dist);     printf("-- min dist : %f \n", min_dist);      //-- draw "good" matches (i.e. distance less 3*min_dist )     std::vector< dmatch > good_matches;      (int = 0; < descriptors_object.rows; i++)     {         if (matches[i].distance < 3 * min_dist)         {             good_matches.push_back(matches[i]);         }     }      mat img_matches;     drawmatches(img_object, keypoints_object, img_scene, keypoints_scene,         good_matches, img_matches, scalar::all(-1), scalar::all(-1),         std::vector<char>(), drawmatchesflags::not_draw_single_points);      //-- localize object     std::vector<point2f> obj;     std::vector<point2f> scene;      (int = 0; < good_matches.size(); i++)     {         //-- keypoints matches         obj.push_back(keypoints_object[good_matches[i].queryidx].pt);         scene.push_back(keypoints_scene[good_matches[i].trainidx].pt);     }      mat h = findhomography(obj, scene, ransac);      //-- corners image_1 ( object "detected" )     std::vector<point2f> obj_corners(4);     obj_corners[0] = cvpoint(0, 0); obj_corners[1] = cvpoint(img_object.cols, 0);     obj_corners[2] = cvpoint(img_object.cols, img_object.rows); obj_corners[3] = cvpoint(0, img_object.rows);     std::vector<point2f> scene_corners(4);      perspectivetransform(obj_corners, scene_corners, h);      //-- draw lines between corners (the mapped object in scene - image_2 )     line(img_matches, scene_corners[0] + point2f(img_object.cols, 0), scene_corners[1] + point2f(img_object.cols, 0), scalar(0, 255, 0), 4);     line(img_matches, scene_corners[1] + point2f(img_object.cols, 0), scene_corners[2] + point2f(img_object.cols, 0), scalar(0, 255, 0), 4);     line(img_matches, scene_corners[2] + point2f(img_object.cols, 0), scene_corners[3] + point2f(img_object.cols, 0), scalar(0, 255, 0), 4);     line(img_matches, scene_corners[3] + point2f(img_object.cols, 0), scene_corners[0] + point2f(img_object.cols, 0), scalar(0, 255, 0), 4);      //-- show detected matches     imshow("good matches & object detection", img_matches);      waitkey(0);     return 0; }  /** @function readme */ void readme() {     std::cout << " usage: ./surf_descriptor <img1> <img2>" << std::endl; } 

errors:

1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(34): warning c4832: token '.' illegal after udt 'cv::xfeatures2d::surf' 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(111) : see declaration of 'cv::xfeatures2d::surf' 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(34): error c2275: 'cv::xfeatures2d::surf' : illegal use of type expression 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(111) : see declaration of 'cv::xfeatures2d::surf' 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(34): error c2228: left of '.create' must have class/struct/union 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(38): error c2039: 'detect' : not member of 'cv::ptr<cv::xfeatures2d::surf>' 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(39): error c2039: 'detect' : not member of 'cv::ptr<cv::xfeatures2d::surf>' 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(42): error c2259: 'cv::xfeatures2d::surf' : cannot instantiate abstract class 1>          due following members: 1>          'void cv::xfeatures2d::surf::sethessianthreshold(double)' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(127) : see declaration of 'cv::xfeatures2d::surf::sethessianthreshold' 1>          'double cv::xfeatures2d::surf::gethessianthreshold(void) const' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(128) : see declaration of 'cv::xfeatures2d::surf::gethessianthreshold' 1>          'void cv::xfeatures2d::surf::setnoctaves(int)' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(130) : see declaration of 'cv::xfeatures2d::surf::setnoctaves' 1>          'int cv::xfeatures2d::surf::getnoctaves(void) const' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(131) : see declaration of 'cv::xfeatures2d::surf::getnoctaves' 1>          'void cv::xfeatures2d::surf::setnoctavelayers(int)' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(133) : see declaration of 'cv::xfeatures2d::surf::setnoctavelayers' 1>          'int cv::xfeatures2d::surf::getnoctavelayers(void) const' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(134) : see declaration of 'cv::xfeatures2d::surf::getnoctavelayers' 1>          'void cv::xfeatures2d::surf::setextended(bool)' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(136) : see declaration of 'cv::xfeatures2d::surf::setextended' 1>          'bool cv::xfeatures2d::surf::getextended(void) const' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(137) : see declaration of 'cv::xfeatures2d::surf::getextended' 1>          'void cv::xfeatures2d::surf::setupright(bool)' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(139) : see declaration of 'cv::xfeatures2d::surf::setupright' 1>          'bool cv::xfeatures2d::surf::getupright(void) const' : abstract 1>          c:\users\belayachiry\documents\opencv\opencv\build\include\opencv2\nonfree\nonfree.hpp(140) : see declaration of 'cv::xfeatures2d::surf::getupright' 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(87): warning c4018: '<' : signed/unsigned mismatch 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(105): warning c4244: 'argument' : conversion 'int' 'float', possible loss of data 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(105): error c3861: 'line': identifier not found 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(106): warning c4244: 'argument' : conversion 'int' 'float', possible loss of data 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(106): error c3861: 'line': identifier not found 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(107): warning c4244: 'argument' : conversion 'int' 'float', possible loss of data 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(107): error c3861: 'line': identifier not found 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(108): warning c4244: 'argument' : conversion 'int' 'float', possible loss of data 1>c:\users\belayachiry\documents\visual studio 2013\projects\imagewatch\imagewatch\source.cpp(108): error c3861: 'line': identifier not found 

occurred modifications in opencv 3.0 these tools.

where is

  • detector.detect(img_object, keypoints_object); should detector->detect(img_object, keypoints_object);
  • surfdescriptorextractor extractor; should ptr<surf> extractor = surf::create();

take @ website

the others erros should desapear now, guess.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -