It is the first time I worked with ArUco markers and was disappointed by weird distortion after perspective transformation based on recognized markers. I assumed that its because of camera calibration errors and decided to test with "ideal" markers.
I calibrated camera with pattern file (not printed and photographed, but just from a source file). Then I generated my marker and put it on JPG image without any distortions. My program found the marker, I generated new position for marked and warped the image:
int side = 100;
resultCorners.push_back(corners[0][0]);
resultCorners.push_back(Point2f(corners[0][0].x + side, corners[0][0].y));
resultCorners.push_back(Point2f(corners[0][0].x + side, corners[0][0].y + side));
resultCorners.push_back(Point2f(corners[0][0].x, corners[0][0].y + side));
Mat w = getPerspectiveTransform(corners[0], resultCorners);
warpPerspective(img_copy, result, w, img_copy.size());
That worked OK: 1.PNG
Then I minimized source image with one pyrDown call and tried to recognize marker again:
Could you please explain, why this weird distortion happens?