/// <summary> /// Process single image: calculate score then add the occurence to imgList List<WeightedImage> /// </summary> /// <param name="completeImage"></param> /// <param name="detailImage"></param> private void ProcessImage(string completeImage, string detailImage) { if (completeImage == detailImage) { return; } try { long score; long matchTime; using (Mat modelImage = CvInvoke.Imread(detailImage, ImreadModes.Color)) using (Mat observedImage = CvInvoke.Imread(completeImage, ImreadModes.Color)) { Mat homography; VectorOfKeyPoint modelKeyPoints; VectorOfKeyPoint observedKeyPoints; using (var matches = new VectorOfVectorOfDMatch()) { Mat mask; DrawMatches.FindMatch(modelImage, observedImage, out matchTime, out modelKeyPoints, out observedKeyPoints, matches, out mask, out homography, out score); } imgList.Add(new WeightedImages() { ImagePath = completeImage, Score = score }); } } catch { } }
/// <summary> /// Button used to show the result image in emImageViewer instance. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnShow_Click(object sender, System.EventArgs e) { string imgPath = resultGrid.CurrentRow.Cells[0].Value.ToString(); long score; long matchTime; using (Mat modelImage = CvInvoke.Imread(_detailedImage, ImreadModes.Color)) using (Mat observedImage = CvInvoke.Imread(imgPath, ImreadModes.Color)) { var result = DrawMatches.Draw(modelImage, observedImage, out matchTime, out score); var iv = new emImageViewer(result, score); iv.Show(); } }