public static Dictionary <string, double> CalculateMatrix(IPattern from, IPattern to) { Point2f[] from_ = new Point2f[from.Points.Count]; Point2f[] to_ = new Point2f[to.Points.Count]; int i = 0; from.Points.ForEach(pt => { from_[i++] = new Point2f((float)pt.X, (float)pt.Y); }); i = 0; to.Points.ForEach(pt => { to_[i++] = new Point2f((float)pt.X, (float)pt.Y); }); Mat inliers = new Mat(); Mat affineMatrix = Cv2.EstimateAffine2D(InputArray.Create(from_), InputArray.Create(to_), inliers, RobustEstimationAlgorithms.RANSAC, 300.0, 2000, 0.99, 10); PrintMatAsync(inliers); return(TransformToDict(affineMatrix)); }
public static Dictionary <string, double> CalculateMatrix(ObservableCollection <Spot> from, ObservableCollection <Spot> to) { Point2f[] from_ = new Point2f[from.Count]; Point2f[] to_ = new Point2f[to.Count]; int i = 0; from.ToList().ForEach(sp => { from_[i++] = new Point2f((float)sp.Position.X, (float)sp.Position.Y); }); i = 0; to.ToList().ForEach(sp => { to_[i++] = new Point2f((float)sp.Position.X, (float)sp.Position.Y); }); Mat affineMatrix = Cv2.EstimateAffine2D(InputArray.Create(from_), InputArray.Create(to_)); return(TransformToDict(affineMatrix)); }