### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- shape. Shape Distance and Matching »

# Shape Transformers and Interfaces

A virtual interface that ease the use of transforming algorithms in some pipelines, such as the Shape Context Matching Algorithm. Thus, all objects that implement shape transformation techniques inherit the `ShapeTransformer` interface.

## ShapeTransformer

class `ShapeTransformer` : public `Algorithm`

Abstract base class for shape transformation algorithms.

    class CV_EXPORTS_W ShapeTransformer : public Algorithm
    {
    public:
        CV_WRAP virtual void estimateTransformation(InputArray transformingShape, InputArray targetShape,
                                                     std::vector<DMatch>& matches) = 0;

        CV_WRAP virtual float applyTransformation(InputArray input, OutputArray output=noArray()) = 0;

        CV_WRAP virtual void warpImage(InputArray transformingImage, OutputArray output,
                                       int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT,
                                       const Scalar& borderValue=Scalar()) const = 0;
    };

## ShapeTransformer::estimateTransformation

Estimate the transformation parameters of the current transformer algorithm, based on point matches.

C++:`` void `estimateTransformation`(InputArray transformingShape, InputArray targetShape, std::vector<DMatch>& matches)

  Parameters: | transformingShape – Contour defining first shape. targetShape – Contour defining second shape (Target). matches – Standard vector of Matches between points.

## ShapeTransformer::applyTransformation

Apply a transformation, given a pre-estimated transformation parameters.

C++:`` float `applyTransformation`(InputArray input, OutputArray output=noArray() )

  Parameters: | input – Contour (set of points) to apply the transformation. output – Output contour.

## ShapeTransformer::warpImage

Apply a transformation, given a pre-estimated transformation parameters, to an Image.

C++:`` void `warpImage`(InputArray transformingImage, OutputArray output, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar() )

  Parameters: | transformingImage – Input image. output – Output image. flags – Image interpolation method. borderMode – border style. borderValue – border value.

## ThinPlateSplineShapeTransformer

class `ThinPlateSplineShapeTransformer` : public `Algorithm`

Definition of the transformation ocupied in the paper “Principal Warps: Thin-Plate Splines and Decomposition of Deformations”, by F.L. Bookstein (PAMI 1989).

    class CV_EXPORTS_W ThinPlateSplineShapeTransformer : public ShapeTransformer
    {
    public:
        CV_WRAP virtual void setRegularizationParameter(double beta) = 0;
        CV_WRAP virtual double getRegularizationParameter() const = 0;
    };

    /* Complete constructor */
    CV_EXPORTS_W Ptr<ThinPlateSplineShapeTransformer>
        createThinPlateSplineShapeTransformer(double regularizationParameter=0);

## ThinPlateSplineShapeTransformer::setRegularizationParameter

Set the regularization parameter for relaxing the exact interpolation requirements of the TPS algorithm.

C++:`` void `setRegularizationParameter`(double beta)

  Parameters: | beta – value of the regularization parameter.

## AffineTransformer

class `AffineTransformer` : public `Algorithm`

Wrapper class for the OpenCV Affine Transformation algorithm.

    class CV_EXPORTS_W AffineTransformer : public ShapeTransformer
    {
    public:
        CV_WRAP virtual void setFullAffine(bool fullAffine) = 0;
        CV_WRAP virtual bool getFullAffine() const = 0;
    };

    /* Complete constructor */
    CV_EXPORTS_W Ptr<AffineTransformer> createAffineTransformer(bool fullAffine);

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- shape. Shape Distance and Matching »