Exemplo n.º 1
0
 /// <summary>
 /// 取得對應出物體的ROI座標點
 /// </summary>
 /// <param name="homography">保存了相關匹配後的資訊(用來投影至商品上的匹配位置)</param>
 /// <param name="template">樣板特徵類別</param>
 /// <returns>回傳座標點</returns>
 public static PointF[] GetMatchBoundingBox(HomographyMatrix homography, SURFFeatureData template)
 {
     if (homography != null) //Get RoI box
     {
         //draw a rectangle along the projected model
         PointF[] pts = new PointF[] {
             new PointF(template.GetImg().ROI.Left, template.GetImg().ROI.Bottom),
             new PointF(template.GetImg().ROI.Right, template.GetImg().ROI.Bottom),
             new PointF(template.GetImg().ROI.Right, template.GetImg().ROI.Top),
             new PointF(template.GetImg().ROI.Left, template.GetImg().ROI.Top)
         };
         homography.ProjectPoints(pts); //project points
         return(pts);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 顯示畫出匹配的視窗
        /// </summary>
        /// <param name="matchData">匹配後回傳的資料類別</param>
        /// <param name="observedScene">觀察景象特徵資料</param>
        public static void ShowSURFMatchForm(SURFMatchedData matchData, SURFFeatureData observedScene)
        {
            PointF[] matchPts = GetMatchBoundingBox(matchData.GetHomography(), matchData.GetTemplateSURFData());
            //Draw the matched keypoints
            Image <Bgr, Byte> result = Features2DToolbox.DrawMatches(matchData.GetTemplateSURFData().GetImg(), matchData.GetTemplateSURFData().GetKeyPoints(), observedScene.GetImg(), observedScene.GetKeyPoints(),
                                                                     matchData.GetIndices(), new Bgr(255, 255, 255), new Bgr(255, 255, 255), matchData.GetMask(), Features2DToolbox.KeypointDrawType.DEFAULT);

            if (matchPts != null)
            {
                result.DrawPolyline(Array.ConvertAll <PointF, Point>(matchPts, Point.Round), true, new Bgr(Color.Red), 2);
            }
            new ImageViewer(result, "顯示匹配圖像").Show();
        }