diff --git a/modules/aruco/src/aruco.cpp b/modules/aruco/src/aruco.cpp index 05e807935..04ef91da0 100644 --- a/modules/aruco/src/aruco.cpp +++ b/modules/aruco/src/aruco.cpp @@ -1676,6 +1676,7 @@ void _drawPlanarBoardImpl(Board *_board, Size outSize, OutputArray _img, int mar // get marker Size dst_sz(outCorners[2] - outCorners[0]); // assuming CCW order + dst_sz.width = dst_sz.height = std::min(dst_sz.width, dst_sz.height); //marker should be square dictionary.drawMarker(_board->ids[m], dst_sz.width, marker, borderBits); if((outCorners[0].y == outCorners[1].y) && (outCorners[1].x == outCorners[2].x)) { diff --git a/modules/aruco/test/test_misc.cpp b/modules/aruco/test/test_misc.cpp new file mode 100644 index 000000000..db9e83a48 --- /dev/null +++ b/modules/aruco/test/test_misc.cpp @@ -0,0 +1,24 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "test_precomp.hpp" +#include + +TEST(CV_ArucoDrawMarker, regression_1226) +{ + int squares_x = 7; + int squares_y = 5; + int bwidth = 1600; + int bheight = 1200; + + cv::Ptr dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); + cv::Ptr board = cv::aruco::CharucoBoard::create(squares_x, squares_y, 1.0, 0.75, dict); + cv::Size sz(bwidth, bheight); + cv::Mat mat; + + ASSERT_NO_THROW( + { + board->draw(sz, mat, 0, 1); + }); +}