diff --git a/modules/shape/src/tps_trans.cpp b/modules/shape/src/tps_trans.cpp index 5818c7973..99a3d31d0 100644 --- a/modules/shape/src/tps_trans.cpp +++ b/modules/shape/src/tps_trans.cpp @@ -48,15 +48,7 @@ namespace cv class ThinPlateSplineShapeTransformerImpl CV_FINAL : public ThinPlateSplineShapeTransformer { public: - /* Constructors */ - ThinPlateSplineShapeTransformerImpl() - { - regularizationParameter=0; - name_ = "ShapeTransformer.TPS"; - tpsComputed=false; - transformCost = 0; - } - + /* Constructor */ ThinPlateSplineShapeTransformerImpl(double _regularizationParameter) { regularizationParameter=_regularizationParameter; @@ -86,6 +78,13 @@ public: writeFormat(fs); fs << "name" << name_ << "regularization" << regularizationParameter; + if( tpsComputed ) + { + fs << "tpsComputed" << tpsComputed + << "transformCost" << transformCost + << "tpsParameters" << tpsParameters + << "shapeReference" << shapeReference; + } } virtual void read(const FileNode& fn) CV_OVERRIDE @@ -176,6 +175,9 @@ float ThinPlateSplineShapeTransformerImpl::applyTransformation(InputArray inPts, Mat pts1 = inPts.getMat(); CV_Assert((pts1.channels()==2) && (pts1.cols>0)); + if (pts1.type() != CV_32F) + pts1.convertTo(pts1, CV_32F); + //Apply transformation in the complete set of points // Ensambling output // if (outPts.needed())