private List <Match> findObjects(Image <Bgr, byte> image, out long preprocessTime, out long matchTime) { var grayIm = image.Convert <Gray, byte>(); var bestRepresentatives = new List <Match>(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); linPyr = LinearizedMapPyramid.CreatePyramid(grayIm); //prepeare linear-pyramid maps preprocessTime = stopwatch.ElapsedMilliseconds; stopwatch.Restart(); List <Match> matches = linPyr.MatchTemplates(templPyrs, threshold); stopwatch.Stop(); matchTime = stopwatch.ElapsedMilliseconds; var matchGroups = new MatchClustering(minDetectionsPerGroup).Group(matches.ToArray()); foreach (var group in matchGroups) { bestRepresentatives.Add(group.Representative); } return(bestRepresentatives); }
/// <summary> /// find the matches in the given image with stopwatch included. /// </summary> /// <param name="image">input image.</param> /// <param name="templPyrs">input template list.</param /// <param name="preprocessTime">Time for preprocessing .</param> /// <param name="matchTime">The time it takes to find matches</param> /// <param name="Threshold">the threshold for the matching algor.</param> /// <param name="labels">the specific label(s) that included in the returned List /// set to null to find all matches</param> /// <param name="userFunc">Input User Function for customization and diversity</param> /// <returns>List of found matches.</returns> public static List <Match> findObjects(Bgr <byte>[,] image, List <TemplatePyramid> templPyrs, out long preprocessTime, out long matchTime, int Threshold = 80, String[] labels = null, int minDetectionsPerGroup = 0, Func <List <Match>, List <Match> > userFunc = null) { var grayIm = image.ToGray(); var bestRepresentatives = new List <Match>(); //userFunc = (userFunc != null) ? userFunc : (inputList) => inputList; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); LinearizedMapPyramid linPyr = LinearizedMapPyramid.CreatePyramid(grayIm); //prepare linear-pyramid maps preprocessTime = stopwatch.ElapsedMilliseconds; stopwatch.Restart(); List <Match> matches = linPyr.MatchTemplates(templPyrs, Threshold); stopwatch.Stop(); matchTime = stopwatch.ElapsedMilliseconds; var matchGroups = new MatchClustering(minDetectionsPerGroup).Group(matches.ToArray()); foreach (var group in matchGroups) { if (labels == null ? true : labels.Contains(group.Representative.Template.ClassLabel)) { bestRepresentatives.Add(group.Representative); } } if (userFunc != null) { bestRepresentatives = userFunc(bestRepresentatives); } return(bestRepresentatives); }
private List<Match> findObjects(Bgr<byte>[,] image, out long preprocessTime, out long matchTime) { var grayIm = image.ToGray(); var bestRepresentatives = new List<Match>(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); linPyr = LinearizedMapPyramid.CreatePyramid(grayIm); //prepare linear-pyramid maps preprocessTime = stopwatch.ElapsedMilliseconds; stopwatch.Restart(); List<Match> matches = linPyr.MatchTemplates(templPyrs, threshold); stopwatch.Stop(); matchTime = stopwatch.ElapsedMilliseconds; var matchGroups = new MatchClustering(minDetectionsPerGroup).Group(matches.ToArray()); foreach (var group in matchGroups) { bestRepresentatives.Add(group.Representative); } return bestRepresentatives; }