/// <summary> /// matches two contours using one of the available algorithms /// </summary> /// <param name="contour1"></param> /// <param name="contour2"></param> /// <param name="method"></param> /// <param name="parameter"></param> /// <returns></returns> public static double MatchShapes(InputArray contour1, InputArray contour2, MatchShapesMethod method, double parameter = 0) { if (contour1 == null) throw new ArgumentNullException("contour1"); if (contour2 == null) throw new ArgumentNullException("contour2"); return NativeMethods.imgproc_matchShapes_InputArray(contour1.CvPtr, contour2.CvPtr, (int)method, parameter); }
/// <summary> /// matches two contours using one of the available algorithms /// </summary> /// <param name="contour1"></param> /// <param name="contour2"></param> /// <param name="method"></param> /// <param name="parameter"></param> /// <returns></returns> public static double MatchShapes(IEnumerable<Point> contour1, IEnumerable<Point> contour2, MatchShapesMethod method, double parameter = 0) { if (contour1 == null) throw new ArgumentNullException("contour1"); if (contour2 == null) throw new ArgumentNullException("contour2"); Point[] contour1Array = EnumerableEx.ToArray(contour1); Point[] contour2Array = EnumerableEx.ToArray(contour2); return NativeMethods.imgproc_matchShapes_Point(contour1Array, contour1Array.Length, contour2Array, contour2Array.Length, (int)method, parameter); }
/// <summary> /// Huモーメントによる形状比較を行う /// </summary> /// <param name="sourceImage"></param> /// <param name="templateImagePath"></param> /// <returns>比較結果(0.0で完全一致)</returns> private static double CompareShapeMoment(IplImage sourceImage, String templateImagePath, MatchShapesMethod matchShapesMethod = MatchShapesMethod.I1) { double result = 1; using (IplImage template = Cv.LoadImage(templateImagePath, LoadMode.GrayScale)) { result = Cv.MatchShapes(sourceImage, template, matchShapesMethod); } return result; }