//private IntPtr _sharedPtr; /// <summary> /// Create a shape context distance extractor /// </summary> /// <param name="comparer">The histogram cost extractor, use ChiHistogramCostExtractor as default</param> /// <param name="transformer">The shape transformer, use ThinPlateSplineSphapeTransformer as default</param> /// <param name="nAngularBins">Establish the number of angular bins for the Shape Context Descriptor used in the shape matching pipeline.</param> /// <param name="nRadialBins">Establish the number of radial bins for the Shape Context Descriptor used in the shape matching pipeline.</param> /// <param name="innerRadius">Set the inner radius of the shape context descriptor.</param> /// <param name="outerRadius">Set the outer radius of the shape context descriptor.</param> /// <param name="iterations">Iterations</param> public ShapeContextDistanceExtractor( HistogramCostExtractor comparer, IShapeTransformer transformer, int nAngularBins = 12, int nRadialBins = 4, float innerRadius = 0.2f, float outerRadius = 3, int iterations = 3) { _ptr = ShapeInvoke.cveShapeContextDistanceExtractorCreate(nAngularBins, nRadialBins, innerRadius, outerRadius, iterations, comparer, transformer.ShapeTransformerPtr, ref _shapeDistanceExtractorPtr, ref _sharedPtr); }
/// <summary> /// Create a shape context distance extractor /// </summary> /// <param name="comparer">The histogram cost extractor, use ChiHistogramCostExtractor as default</param> /// <param name="transformer">The shape transformer, use ThinPlateSplineSphapeTransformer as default</param> /// <param name="nAngularBins">Establish the number of angular bins for the Shape Context Descriptor used in the shape matching pipeline.</param> /// <param name="nRadialBins">Establish the number of radial bins for the Shape Context Descriptor used in the shape matching pipeline.</param> /// <param name="innerRadius">Set the inner radius of the shape context descriptor.</param> /// <param name="outerRadius">Set the outer radius of the shape context descriptor.</param> /// <param name="iterations">Iterations</param> public ShapeContextDistanceExtractor( HistogramCostExtractor comparer, IShapeTransformer transformer, int nAngularBins = 12, int nRadialBins = 4, float innerRadius = 0.2f, float outerRadius = 3, int iterations = 3) { _ptr = ShapeInvoke.cvShapeContextDistanceExtractorCreate(nAngularBins, nRadialBins, innerRadius, outerRadius, iterations, comparer, transformer.ShapeTransformerPtr, ref _shapeDistanceExtractorPtr); }
/// <summary> /// Apply a transformation, given a pre-estimated transformation parameters. /// </summary> /// <param name="transformer">The shape transformer</param> /// <param name="input">Contour (set of points) to apply the transformation.</param> /// <param name="output">Output contour.</param> /// <returns></returns> public static float ApplyTransformation( this IShapeTransformer transformer, IInputArray input, IOutputArray output = null) { using (InputArray iaInput = input.GetInputArray()) using (OutputArray oaOutput = output == null ? OutputArray.GetEmpty() : output.GetOutputArray()) { return(cveShapeTransformerApplyTransformation( transformer.ShapeTransformerPtr, iaInput, oaOutput)); } }
/// <summary> /// Estimate the transformation parameters of the current transformer algorithm, based on point matches. /// </summary> /// <param name="transformer">The shape transformer</param> /// <param name="transformingShape">Contour defining first shape.</param> /// <param name="targetShape">Contour defining second shape (Target).</param> /// <param name="matches">Standard vector of Matches between points.</param> public static void EstimateTransformation( this IShapeTransformer transformer, IInputArray transformingShape, IInputArray targetShape, VectorOfDMatch matches) { using (InputArray iaTransformingShape = transformingShape.GetInputArray()) using (InputArray iaTargetShape = targetShape.GetInputArray()) { cveShapeTransformerEstimateTransformation( transformer.ShapeTransformerPtr, iaTransformingShape, iaTargetShape, matches); } }
/// <summary> /// Apply a transformation, given a pre-estimated transformation parameters, to an Image. /// </summary> /// <param name="transformer">The shape transformer</param> /// <param name="transformingImage">Input image.</param> /// <param name="output">Output image.</param> /// <param name="flags">Image interpolation method.</param> /// <param name="boarderMode">border style.</param> /// <param name="borderValue">border value.</param> public static void WarpImage( this IShapeTransformer transformer, IInputArray transformingImage, IOutputArray output, CvEnum.Inter flags = Inter.Linear, CvEnum.BorderType boarderMode = BorderType.Constant, MCvScalar borderValue = new MCvScalar()) { using (InputArray iaTransformingImage = transformingImage.GetInputArray()) using (OutputArray oaOutput = output.GetOutputArray()) { cveShapeTransformerWarpImage( transformer.ShapeTransformerPtr, iaTransformingImage, oaOutput, flags, boarderMode, ref borderValue); } }