2011-11-08 12 views
2

こんにちは、パターンのすべてのオカレンスを取得できますか、すでに持っているソリューションを機能が、1つの問題:Emgu CVは - 私は、画像内

  // The screenshot will be stored in this bitmap. 
      Bitmap capture = new Bitmap(rec.Width, rec.Height, PixelFormat.Format24bppRgb); 
      using (Graphics g = Graphics.FromImage(capture)) 
      { 
       g.CopyFromScreen(rec.Location, new System.Drawing.Point(0, 0), rec.Size); 
      } 

      MCvSURFParams surfParam = new MCvSURFParams(500, false); 
      SURFDetector surfDetector = new SURFDetector(surfParam); 

      // Template image 
      Image<Gray, Byte> modelImage = new Image<Gray, byte>("template.jpg"); 
      // Extract features from the object image 
      ImageFeature[] modelFeatures = surfDetector.DetectFeatures(modelImage, null); 

      // Prepare current frame 
      Image<Gray, Byte> observedImage = new Image<Gray, byte>(capture); 
      ImageFeature[] imageFeatures = surfDetector.DetectFeatures(observedImage, null); 


      // Create a SURF Tracker using k-d Tree 
      Features2DTracker tracker = new Features2DTracker(modelFeatures); 

      Features2DTracker.MatchedImageFeature[] matchedFeatures = tracker.MatchFeature(imageFeatures, 2); 
      matchedFeatures = Features2DTracker.VoteForUniqueness(matchedFeatures, 0.8); 
      matchedFeatures = Features2DTracker.VoteForSizeAndOrientation(matchedFeatures, 1.5, 20); 
      HomographyMatrix homography = Features2DTracker.GetHomographyMatrixFromMatchedFeatures(matchedFeatures); 

      // Merge the object image and the observed image into one image for display 
      Image<Gray, Byte> res = modelImage.ConcateVertical(observedImage); 

      #region draw lines between the matched features 

      foreach (Features2DTracker.MatchedImageFeature matchedFeature in matchedFeatures) 
      { 
       PointF p = matchedFeature.ObservedFeature.KeyPoint.Point; 
       p.Y += modelImage.Height; 
       res.Draw(new LineSegment2DF(matchedFeature.SimilarFeatures[0].Feature.KeyPoint.Point, p), new Gray(0), 1); 
      } 

      #endregion 

      #region draw the project region on the image 

      if (homography != null) 
      { 
       // draw a rectangle along the projected model 
       Rectangle rect = modelImage.ROI; 
       PointF[] pts = new PointF[] { 
        new PointF(rect.Left, rect.Bottom), 
        new PointF(rect.Right, rect.Bottom), 
        new PointF(rect.Right, rect.Top), 
        new PointF(rect.Left, rect.Top) 
       }; 

       homography.ProjectPoints(pts); 

       for (int i = 0; i < pts.Length; i++) 
        pts[i].Y += modelImage.Height; 

       res.DrawPolyline(Array.ConvertAll<PointF, Point>(pts, Point.Round), true, new Gray(255.0), 2); 
      } 

      #endregion 

      pictureBoxScreen.Image = res.ToBitmap(); 

結果は次のとおりです。

enter image description here

そして、私の問題は、ということです、関数homography.ProjectPoints(pts); パターンの最初の出現(上記の図の白い矩形)を取得する

すべてのテンプレートの出現、それぞれどのように画像のテンプレート矩形の出現を得ることができます

答えて

1

私は自分の卒業論文に似た問題に直面しています。基本的には2つのオプションがあります。

  1. Hierarchical k-meansなどのクラスタリングまたは点密度を使用し1のようなDBSCAN(それは二つのパラメータに依存するが、あなたはそれがしきい値二次元R^2空間で自由に作ることができます)
  2. 使用JLinkageのような複数のロバストなモデルフィッティング推定手法。この高度な技術では、ユークリッド空間で互いに近いクラスタポイントの代わりにホモグラフィを共有するポイントをクラスタリングします。

"クラスタ"で一致を分割すると、対応するクラスタに属する一致間の相同性を推定できます。

+0

Thx、良いリンク、私はそれがいくつかの有用なものを試してみてください。 –

関連する問題