Hey it's me again. S.th. in this Shape Transformer Interface seems to be buggy. Maybe also see my former Question
The following code will only produce a completly gray image again. The error is reproducable by giving the last point the same x/y e.g. 2/2, but will work perfectly fine with 2/3. But thats only one possibility to cause this error. I found other picutres with "real" landmark points which also cause this error but I couldn't figure out a pattern. (Let me know if you need the data) I would be grateful vor any help :)
using namespace cv;
using namespace std;
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
Mat sImg = imread("D:\\Opencv3\\sources\\samples\\data\\graf1.png", IMREAD_GRAYSCALE);
std::vector<cv::Point2f> points;
vector<DMatch> good_matches;
Mat tImg;
points.push_back(Point(0, 0)); //Just to have a few points, works with different combinations
points.push_back(Point(1, 1));
points.push_back(Point(2, 2)); // e.g. this would work perfectly fine! points.push_back(Point(2, 3));
good_matches.push_back(DMatch(0, 0, 0));
good_matches.push_back(DMatch(1, 1, 0));
good_matches.push_back(DMatch(2, 2, 0));
// Apply TPS
Ptr<ThinPlateSplineShapeTransformer> mytps = createThinPlateSplineShapeTransformer(0);
mytps->estimateTransformation(points, points, good_matches); // Using same pointmatrix nothing should change in the target Image
imshow("img1", sImg); // Just to see if I have a good picture
mytps->warpImage(sImg, tImg);
imshow("Tranformed", tImg); //Always completley grey ?
waitKey(0);
}