title: Facing error with compiling opencv code
body: <p>I am using opencv 2.4 and below is the code I am trying to compile.  I compile my code using this command </p>
  
  <pre><code>g++ -o "match" -ggdb `pkg-config --cflags opencv` match.cpp `pkg-config --libs opencv` 
  </code></pre>
  
  <p>Why I am getting this error:</p>
  
  <pre><code>match.cpp: In function ‘int main(int, const char**)’:
  match.cpp:18:37: error: expected type-specifier before ‘SurfFeatureDetector’
  match.cpp:18:37: error: conversion from ‘int*’ to non-scalar type ‘cv::Ptr&lt;cv::FeatureDetector&gt;’ requested
  match.cpp:18:37: error: expected ‘,’ or ‘;’ before ‘SurfFeatureDetector’
  match.cpp:22:2: error: ‘SurfDescriptorExtractor’ was not declared in this scope
  match.cpp:22:26: error: expected ‘;’ before ‘extractor’
  match.cpp:26:2: error: ‘extractor’ was not declared in this scope
  match.cpp:29:2: error: ‘BruteForceMatcher’ was not declared in this scope
  match.cpp:29:30: error: expected primary-expression before ‘&gt;’ token
  match.cpp:29:32: error: ‘matcher’ was not declared in this scope
  </code></pre>
  
  <p>I think there is some issue with the version of opencv I am using because the same code runs fine on 2.2 version but I am not sure what it is. HELP !!</p>
  
  <pre><code>#include &lt;opencv/cv.h&gt;
  #include &lt;opencv/highgui.h&gt;
  #include &lt;string.h&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  using namespace cv;
  
  
  int main(int argc, const char* argv[])
  {
      cout &lt;&lt; argv[1] &lt;&lt; endl &lt;&lt; argv[2] &lt;&lt; endl;
      Mat img1 = imread(argv[1] , CV_LOAD_IMAGE_GRAYSCALE );
      Mat img2 = imread(argv[2] , CV_LOAD_IMAGE_GRAYSCALE );
  
      vector&lt;KeyPoint&gt; keypoints1;
      vector&lt;KeyPoint&gt; keypoints2;
      Ptr&lt;FeatureDetector&gt; feature = new SurfFeatureDetector(2500);
      feature-&gt;detect(img1,keypoints1);
      feature-&gt;detect(img2,keypoints2);
  
      SurfDescriptorExtractor extractor;
  
      Mat desc1 , desc2;
  
      extractor.compute(img1,keypoints1,desc1);
      extractor.compute(img2,keypoints2,desc2);
  
      BruteForceMatcher&lt;L2&lt;float&gt; &gt; matcher;
  
      vector&lt;vector&lt;DMatch&gt; &gt; matches1;
      vector&lt;vector&lt;DMatch&gt; &gt; matches2;
      vector&lt;DMatch&gt; symMatches;
      vector&lt;DMatch&gt; outMatches;
  
      matcher.knnMatch(desc1,desc2,matches1,2);
      matcher.knnMatch(desc2,desc1,matches2,2);
  
      int count_inliers = 0 , count_matches = 0;
  
      for(vector&lt;vector&lt;DMatch&gt; &gt;::const_iterator matIt1 = matches1.begin(); matIt1 != matches1.end(); ++matIt1){
          count_matches++;
          if(matIt1-&gt;size() &lt; 2)
              continue;
          for(vector&lt;vector&lt;DMatch&gt; &gt;::const_iterator matIt2 = matches2.begin(); matIt2 != matches2.end(); ++matIt2){
              if(matIt2-&gt;size() &lt; 2)
                  continue;
              if((*matIt1)[0].queryIdx == (*matIt2)[0].trainIdx &amp;&amp; (*matIt2)[0].queryIdx == (*matIt1)[0].trainIdx){
                  count_inliers++;
                  symMatches.push_back(DMatch((*matIt1)[0].queryIdx,(*matIt1)[0].trainIdx,(*matIt1)[0].distance));
                  break;
              }
          }
      }
  
      vector&lt;Point2f&gt; points1, points2;
  
      for(vector&lt;DMatch&gt;::const_iterator it = symMatches.begin(); it!=symMatches.end(); ++it){
          float x = keypoints1[it-&gt;queryIdx].pt.x;
          float y = keypoints1[it-&gt;queryIdx].pt.y;
          points1.push_back(Point2f(x,y));
  
          x = keypoints2[it-&gt;trainIdx].pt.x;
          y = keypoints2[it-&gt;trainIdx].pt.y;
          points2.push_back(Point2f(x,y));
      }
  
      vector&lt;uchar&gt; inliers(points1.size(),0);
  
      Mat fundamental;
      fundamental = findFundamentalMat(Mat(points2),Mat(points1),inliers,CV_FM_RANSAC,2,0.8);
  
      vector&lt;uchar&gt;::const_iterator itIn = inliers.begin();
      vector&lt;DMatch&gt;::const_iterator itM = symMatches.begin();
      for(;itIn!=inliers.end();++itIn,++itM){
          if(*itIn){
              outMatches.push_back(*itM);
          }
      }
      cout &lt;&lt; count_inliers &lt;&lt; endl;
      cout &lt;&lt; count_matches &lt;&lt; endl;
      cout &lt;&lt; (float) count_inliers/(float) count_matches &lt;&lt; endl;
  
      float diff = (float) count_inliers/(float) count_matches;
  //  if(diff &gt; 0.30){
  //      cout &lt;&lt; "Similar Images " &lt;&lt; endl &lt;&lt; "-----------------" &lt;&lt; endl;
  //      exit(1);
  //  }
  
  //  vector&lt;uchar&gt; inliers(points1.size(),0);
      Mat homography = findHomography(Mat(points2),Mat(points1),inliers,CV_RANSAC,1);
  
      vector&lt;Point2f&gt;::const_iterator itPts = points1.begin();
  //  vector&lt;uchar&gt;::const_iterator itIn = inliers.begin();
  /*  while(itPts != points1.end()){
          if(*itIn)
              circle(img1,*itPts,3,Scalar(255,255,255),2);
          ++itPts;
          ++itIn;
      }
      itPts = points2.begin();
      itIn = inliers.begin();
      while(itPts != points2.end()){
          if(*itIn)
              circle(img2,*itPts,3,Scalar(255,255,255),2);
          ++itPts;
          ++itIn;
      }
  */
  
      Mat result;
  
      warpPerspective(img2,result,homography,Size(2*img2.cols,img2.rows));
      Mat half(result,Rect(0,0,img1.cols,img1.rows));
  
      img1.copyTo(half);
  
  
  
  
  
      // Add results to image and save.
      char name[1000];
  
  //    strcpy(name,"./surf/surf");
  //    strcat(name,argv[1]);
  
      cv::Mat output1;
      cv::Mat output2;
      cv::drawKeypoints(img1, keypoints1, output1);
      cv::drawKeypoints(img2, keypoints2, output2);
      cv::imwrite("./surf/img11.png", img1);
      cv::imwrite("./surf/img21.png", img2);
      cv::imwrite("./surf/img31.png", result);
      cv::imwrite("./surf/tt.png", result);
      cv::imwrite("./surf/img41.png", half);
      cv::imwrite("./surf/img51.png", output1);
      cv::imwrite("./surf/img61.png", output2);
  
      return 0;
  }
  </code></pre>