Esempio n. 1
0
        private void matchFeatureButton_Click(object sender, RoutedEventArgs e)
        {
            if (templateSurfFeature != null)
            {
                Image <Bgr, byte> observedContourRectImg = DetectObjects.GetBoundingBoxImage(topContours[matchIndex], loadTestImg);

                observedContourRectImg.Resize(templateSurfFeature.GetImg().Width, templateSurfFeature.GetImg().Height, INTER.CV_INTER_LINEAR);

                MatchRecognition.MatchSURFFeature(templateSurfFeature, observedContourRectImg, true); //先使用原影像
            }
        }
Esempio n. 2
0
 ////////////////////////////////////////////////////////////////////////////
 #endregion
 /// <summary>
 /// 執行辨識
 /// </summary>
 /// <param name="isDrawResultToShowOnDialog">是否要顯示出辨識的結果</param>
 /// <returns>回傳商品資訊, 格式=>"商品名稱,商品售價" ;請記得做字串切割,若無比對到或有任何問題則會回傳null</returns>
 public string RunRecognition(bool isDrawResultToShowOnDialog)
 {
     if (surfFiles.Count != 0)
     {
         //匹配特徵並取回匹配到的特徵
         KeyValuePair <String, SURFMatchedData> mathedGoodsData = MatchRecognition.MatchSURFFeature(surfFiles, objectImg, true);
         if (mathedGoodsData.Key != null && mathedGoodsData.Value != null)
         {
             //透過樣板檔案名稱取出匹配到的商品資訊
             string matchedFileName = mathedGoodsData.Key;
             //切割出商品檔案ID=> 特徵檔案名稱命名規則:(商品ID+特徵點編號),因為一種商品可能需要多張畫面的特徵點
             string[] split = matchedFileName.Split('-');
             string   goodsMsg;
             //特徵檔案名稱使否有存在此商品
             if (goodsData.TryGetValue(split[0], out goodsMsg))
             {
                 return(goodsMsg);
             }
             else
             {
                 //System.Windows.MessageBox.Show("特徵檔案並無存在可對應的商品資料!");
                 return("Does not exist for this product!");
             }
         }
         else
         {
             //System.Windows.MessageBox.Show("沒有對應到的商品或是不存在此商品");
             return("Does not exist for this product");
         }
     }
     else
     {
         // System.Windows.MessageBox.Show("沒有特徵資料");
         return("Does not exist for this product");
     }
 }