/// <summary> /// 比配特徵,對所有檔案匹配並找出最好的匹配檔 /// </summary> /// <param name="surfFiles">載入所有可能作為匹配的特徵資料</param> /// <param name="observedImg">要比對觀察的影像</param> /// <param name="viewer">顯示出匹配結果的物件</param> /// <returns>回傳匹配到的相關資訊類別,String是檔案名稱,如果未匹配到,則Key與Values皆會回傳null,因此要先做檢查</returns> public static SURFMatchedData MatchSURFFeatureForVideoObjs(SURFFeatureData templateSURFData, SURFFeatureData obervedSurfData, ImageViewer viewer) { SURFMatchedData matchedData; //縮放到一樣大小 (系統修改成可讀圖片時才能加入) //observedImg = observedImg.Resize(3, INTER.CV_INTER_LINEAR); //Console.WriteLine("### One-by-One Mathed Start.....\n============================"); if (obervedSurfData.GetDescriptors() != null) { matchedData = SURFMatch.MatchSURFFeatureByFLANNForObjs(templateSURFData, obervedSurfData); if (matchedData != null) { if (viewer != null) { SURFMatch.ShowSURFMatchForm(matchedData, obervedSurfData, viewer); } return(matchedData); } else { return(null); } } else { return(null); } }
////////////////////////////////////////////////////////////////////////////////////////////// #endregion #region 商家看板辨識 ////////////////////////////////////////////////////////////////////////////////////////////// public static SURFMatchedData MatchSURFFeature(SURFFeatureData template, Image <Bgr, Byte> observedImg, bool isShowResult) { //縮放到一樣大小 (系統修改成可讀圖片時才能加入) //observedImg = observedImg.Resize(3, INTER.CV_INTER_LINEAR); SURFFeatureData observed = SURFMatch.CalSURFFeature(observedImg); if (observed.GetDescriptors() != null) { SURFMatchedData matchedData = SURFMatch.MatchSURFFeatureByFLANNForObjs(template, observed); if (matchedData != null && isShowResult) { SURFMatch.ShowSURFMatchForm(matchedData, observed, new ImageViewer()); } return(matchedData); } else { return(null); } }