Skip to content

Commit fd5431c

Browse files
committed
Merge pull request #1230 from sovrasov:aruco_draw_fix
2 parents c19a1df + dc332c7 commit fd5431c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

modules/aruco/src/aruco.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,7 @@ void _drawPlanarBoardImpl(Board *_board, Size outSize, OutputArray _img, int mar
16761676

16771677
// get marker
16781678
Size dst_sz(outCorners[2] - outCorners[0]); // assuming CCW order
1679+
dst_sz.width = dst_sz.height = std::min(dst_sz.width, dst_sz.height); //marker should be square
16791680
dictionary.drawMarker(_board->ids[m], dst_sz.width, marker, borderBits);
16801681

16811682
if((outCorners[0].y == outCorners[1].y) && (outCorners[1].x == outCorners[2].x)) {

modules/aruco/test/test_misc.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html.
4+
5+
#include "test_precomp.hpp"
6+
#include <opencv2/aruco/charuco.hpp>
7+
8+
TEST(CV_ArucoDrawMarker, regression_1226)
9+
{
10+
int squares_x = 7;
11+
int squares_y = 5;
12+
int bwidth = 1600;
13+
int bheight = 1200;
14+
15+
cv::Ptr<cv::aruco::Dictionary> dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
16+
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(squares_x, squares_y, 1.0, 0.75, dict);
17+
cv::Size sz(bwidth, bheight);
18+
cv::Mat mat;
19+
20+
ASSERT_NO_THROW(
21+
{
22+
board->draw(sz, mat, 0, 1);
23+
});
24+
}

0 commit comments

Comments
 (0)