public List<VideoPoint> GetVideoImagePoints(Bitmap bmp, float thresh = 0.0002f) { var points = GetImagePoints(bmp, thresh); List<VideoPoint> videoPoints = new List<VideoPoint>(); foreach (var point in points) { VideoPoint videoPoint = new VideoPoint(); videoPoint.CopyFrom(point); videoPoints.Add(videoPoint); } return videoPoints; }
public List<VideoPoint>[] GetMatches(List<VideoPoint> ipts1, List<VideoPoint> ipts2,bool multiThread=false) { double dist; double d1, d2; VideoPoint match = new VideoPoint(); List<VideoPoint>[] matches = new List<VideoPoint>[2]; matches[0] = new List<VideoPoint>(); matches[1] = new List<VideoPoint>(); if (multiThread) { var output=Parallel.For(0,ipts1.Count,i=>{ d1 = d2 = FLT_MAX; for (int j = 0; j < ipts2.Count; j++) { dist = GetDistance(ipts1[i], ipts2[j]); if (dist < d1) // if this feature matches better than current best { d2 = d1; d1 = dist; match = ipts2[j]; } else if (dist < d2) // this feature matches better than second best { d2 = dist; } } // If match has a d1:d2 ratio < 0.65 ipoints are a match if (d1 / d2 < 0.77) //Match { matches[0].Add(ipts1[i]); matches[1].Add(match); } }); } else { for (int i = 0; i < ipts1.Count; i++) { d1 = d2 = FLT_MAX; for (int j = 0; j < ipts2.Count; j++) { dist = GetDistance(ipts1[i], ipts2[j]); if (dist < d1) // if this feature matches better than current best { d2 = d1; d1 = dist; match = ipts2[j]; } else if (dist < d2) // this feature matches better than second best { d2 = dist; } } // If match has a d1:d2 ratio < 0.65 ipoints are a match if (d1 / d2 < 0.77) //Match { matches[0].Add(ipts1[i]); matches[1].Add(match); } } } return matches; }