官方文档:OpenCV: cv::ThinPlateSplineShapeTransformer Class Reference
使用方法:
头文件:#include <opencv2/shape/shape_transformer.hpp>
(1)点匹配 一般根据有多少个样本(或者点)来设置,如有M个点,并且下标相同的点是对应点,那么其匹配设置:
std::vector<cv::DMatch> matches;
for(int i=0;i < M; ++i)
matches.append(cv::DMatch(i, i, 0))
(2)计算转换矩阵
//源点及目标点(请自行填充)
vector<Point2f> _dstPts,_srcPts;
//获取转换矩阵
cv::Ptr<cv::ThinPlateSplineShapeTransformer> tps
tps = cv::createThinPlateSplineShapeTransformer(0);
tps->estimateTransformation(_dstPts, _srcPts,matches);
(3)获取任意点的转换值