static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); long matchTime; int Inliers = 10, OutLiers; string mImage = "C:\\inetpub\\wwwroot\\memomface\\UserContent\\Member\\2\\1f99e8d4-be1d-4ca1-b094-67a45e298f65.JPG"; string oImage = "C:\\inetpub\\wwwroot\\memomface\\UserContent\\Album\\1\\45d2c5b1-2079-408a-af48-e60edad56f5f--IMG_0185-3.JPG"; //using(Image<Gray, Byte> modelImage = new Image<Gray, byte>("FaceBoy.jpg")) //using (Image<Gray, Byte> observedImage = new Image<Gray, byte>("YesBoy.jpg")) using (Image <Gray, Byte> modelImage = new Image <Gray, byte>(mImage)) using (Image <Gray, Byte> observedImage = new Image <Gray, byte>(oImage)) { //Image<Bgr, byte> result = DrawMatches.Draw(modelImage, observedImage, out matchTime); Image <Bgr, byte> result = BruteForceMatcher.Draw(modelImage, observedImage, out matchTime, out Inliers, out OutLiers); ImageViewer.Show(result, String.Format("Matched using {0} in {1} milliseconds", GpuInvoke.HasCuda ? "GPU" : "CPU", matchTime)); } }
public static FindMatchResult FindMatchInSource(MatchInput matchInput) { FindMatchResult matchResult = new FindMatchResult(); long matchTime; int inLiers, outLiers; string MatchFolderPath, MatchFile, MatchAbsolutePath, MatchedFaceFile; MatchFolderPath = MatchFile = MatchedFaceFile = MatchAbsolutePath = ""; //file folders assignment MatchFolderPath = matchInput.WebFolderPath; MatchAbsolutePath = matchInput.FindInFile.DirectoryName + "\\" + "MatchFiles"; using (Image <Gray, Byte> modelImage = new Image <Gray, byte>(matchInput.MatchFile.FullName)) using (Image <Gray, Byte> observedImage = new Image <Gray, byte>(matchInput.FindInFile.FullName)) { Image <Bgr, byte> result = BruteForceMatcher.Draw(modelImage, observedImage, out matchTime, out inLiers, out outLiers); //ImageViewer.Show(result, String.Format("Matched using {0} in {1} milliseconds", GpuInvoke.HasCuda ? "GPU" : "CPU", matchTime)); if (inLiers > matchInput.InlierThreshold) { matchResult.Matched = true; MatchedFaceFile = Guid.NewGuid().ToString(); bool exists = System.IO.Directory.Exists(MatchAbsolutePath); if (!exists) { System.IO.Directory.CreateDirectory(MatchAbsolutePath); } result.Save(MatchAbsolutePath + "\\" + MatchedFaceFile + matchInput.FindInFile.Extension); } matchResult.Inliers = inLiers; matchResult.Outliers = outLiers; matchResult.FolderPath = MatchFolderPath; matchResult.AbsolutePath = MatchAbsolutePath + "\\"; matchResult.MatchedFaceFile = MatchedFaceFile; } return(matchResult); }