aruco_map: fix drawing maps with pitch/roll rotated markers

This commit is contained in:
Oleg Kalachev
2019-03-10 02:28:14 +03:00
parent c9768cce4d
commit f2b37d8ea2
2 changed files with 10 additions and 18 deletions

View File

@@ -74,24 +74,14 @@ void _drawPlanarBoard(Board *_board, Size outSize, OutputArray _img, int marginS
dictionary.drawMarker(_board->ids[m], side, marker, borderBits);
try {
if((outCorners[0].y == outCorners[1].y) && (outCorners[1].x == outCorners[2].x)) {
// marker is aligned to image axes
marker.copyTo(out(Rect(outCorners[0], dst_sz)));
continue;
}
// interpolate tiny marker to marker position in markerZone
inCorners[0] = Point2f(-0.5f, -0.5f);
inCorners[1] = Point2f(marker.cols - 0.5f, -0.5f);
inCorners[2] = Point2f(marker.cols - 0.5f, marker.rows - 0.5f);
// interpolate tiny marker to marker position in markerZone
inCorners[0] = Point2f(-0.5f, -0.5f);
inCorners[1] = Point2f(marker.cols - 0.5f, -0.5f);
inCorners[2] = Point2f(marker.cols - 0.5f, marker.rows - 0.5f);
// remove perspective
Mat transformation = getAffineTransform(inCorners, outCorners);
warpAffine(marker, out, transformation, out.size(), INTER_LINEAR,
BORDER_TRANSPARENT);
} catch(cv::Exception& e) {
ROS_INFO("Skip drawing marker %d", m);
}
// remove perspective
Mat transformation = getAffineTransform(inCorners, outCorners);
warpAffine(marker, out, transformation, out.size(), INTER_LINEAR,
BORDER_TRANSPARENT);
}
}

View File

@@ -3,3 +3,5 @@
3 0.33 0 1 0 0 0 0
4 0.33 1 1 0 0 0 0
10 0.5 0.5 2 0 1.2 0 0
11 0.2 0.5 0.5 0 0.0 -1 1
12 0.4 0.2 0.5 0 0.1 -1.2 -0.5