title: SURF error while tracking object
body: <p>I am trying to find an object in the videos by calling SURF function for each frame ... 
  this is the SURF Function 
  {</p>
  
  <pre><code>void Identify_SURF_Frame (Mat img_object , Mat img_scene , CvRect in_box) 
  { 
  //-- Step 1: Detect the keypoints using SURF Detector
  int minHessian = 1;
  SurfFeatureDetector detector( minHessian , 15 , 3 );
  std::vector&lt;KeyPoint&gt; 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;
  BruteForceMatcher &lt; L2 &lt; float &gt; &gt; matcher;
  //BFMatcher matcher( cv::NORM_L2SQR , false );
  std::vector&lt; DMatch &gt; matches;
  matcher.match( descriptors_object, descriptors_scene, matches );
  double max_dist = 0; double min_dist = 100;
  
  //-- Quick calculation of max and min distances between keypoints
  for( int i = 0; i &lt; descriptors_object.rows; i++ )
  { 
      double dist = matches[i].distance;
      if( dist &lt; min_dist ) min_dist = dist;
      if( dist &gt; max_dist ) max_dist = dist;
  }
  
  //-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
  std::vector&lt; DMatch &gt; good_matches;
  for( int i = 0; i &lt; descriptors_object.rows; i++ )
  { 
      if( matches[i].distance &lt; 4 * 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), vector&lt;char&gt;(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
  
  //-- Localize the object
  std::vector&lt;Point2f&gt; obj;
  std::vector&lt;Point2f&gt; scene;
      for( int i = 0; i &lt; good_matches.size(); i++ )
      {
          //-- Get the keypoints from the good 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, CV_RANSAC );
      //-- Get the corners from the image_1 ( the object to be "detected" )
      std::vector&lt;Point2f&gt; obj_corners(2);
      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&lt;Point2f&gt; scene_corners(2);
      perspectiveTransform( obj_corners, scene_corners, H);
      int x1 , x2 , y1 , y2 ;
      x1 = scene_corners[0].x + Point2f( img_object.cols, 0).x ; 
      y1 = scene_corners[0].y + Point2f( img_object.cols, 0).y ; 
      x2 = scene_corners[0].x + Point2f( img_object.cols, 0).x + in_box.width ; 
      y2 = scene_corners[0].y + Point2f( img_object.cols, 0).y + in_box.height ; 
  
      rectangle(img_matches , cvPoint(x1, y1) , cvPoint(x2, y2)  , Scalar( 255, 255, 255), 1 );
              // square is the global CvRect to use it in main 
      square.x = x1 - in_box.width ; 
      square.y = y1 ; 
      square.width = in_box.width ; 
      square.height = in_box.height ;  
  
  //-- Show detected matches
  imshow( "Good Matches &amp; Object detection", img_matches );
  }
  }
  </code></pre>
  
  <p>using this function I am trying to draw fixed size square around the object when I find it 
  the problem is .... some time I got this error which I do not what it mean .. sometime the program work fine without this error .. when this error happen the program scratch </p>
  
  <pre><code> {     
   OpenCV Error: Assertion failed (count &gt;= 4) in cvFindHomography, file /Users/seereen2004/Desktop/OpenCV-2.4.3/modules/calib3d/src/fundam.cpp, line 235
   terminate called after throwing an instance of 'cv::Exception'
     what():  /Users/seereen2004/Desktop/OpenCV-2.4.3/modules/calib3d/src/fundam.cpp:235:    error: (-215) count &gt;= 4 in function cvFindHomography
  
   Program received signal:  “SIGABRT”.
   sharedlibrary apply-load-rules all
   }
  </code></pre>
  
  <p>any explanation please ?
  Thanks in Advance  </p>