Added ArUco marker size check for Aruco and Charuco boards.

pull/24349/head
Alex 1 year ago committed by Alexander Smorkalov
parent f3c724d449
commit e5b114e5b8
  1. 5
      doc/pattern_tools/gen_pattern.py
  2. 14
      modules/objdetect/src/aruco/aruco_board.cpp

@ -186,6 +186,8 @@ class PatternMaker:
yspacing = (self.height - self.rows * self.square_size) / 2.0
ch_ar_border = (self.square_size - self.aruco_marker_size)/2
if ch_ar_border < side*0.7:
print("Marker border {} is less than 70% of ArUco pin size {}. Please increase --square_size or decrease --marker_size for stable board detection".format(ch_ar_border, int(side)))
marker_id = 0
for y in range(0, self.rows):
for x in range(0, self.cols):
@ -283,6 +285,9 @@ def main():
else:
raise ValueError("The marker {},{} is outside the checkerboard".format(x, y))
if p_type == "charuco_board" and aruco_marker_size >= square_size:
raise ValueError("ArUco markers size must be smaller than square size")
pm = PatternMaker(columns, rows, output, units, square_size, radius_rate, page_width, page_height, markers, aruco_marker_size, dict_file)
# dict for easy lookup of pattern type
mp = {"circles": pm.make_circles_pattern, "acircles": pm.make_acircles_pattern,

@ -3,6 +3,7 @@
// of this distribution and at http://opencv.org/license.html
#include "../precomp.hpp"
#include <opencv2/core/utils/logger.hpp>
#include "opencv2/objdetect/aruco_board.hpp"
#include <opencv2/objdetect/aruco_dictionary.hpp>
@ -250,7 +251,11 @@ GridBoard::GridBoard() {}
GridBoard::GridBoard(const Size& size, float markerLength, float markerSeparation,
const Dictionary &dictionary, InputArray ids):
Board(new GridBoardImpl(dictionary, size, markerLength, markerSeparation)) {
float onePin = markerLength / ((float)(dictionary.markerSize+2));
if (markerSeparation < onePin*.7f) {
CV_LOG_WARNING(NULL, "Marker border " << markerSeparation << " is less than 70% of ArUco pin size "
<< onePin << ". Please increase markerSeparation or decrease markerLength for stable board detection");
}
size_t totalMarkers = (size_t) size.width*size.height;
CV_Assert(ids.empty() || totalMarkers == ids.total());
vector<vector<Point3f> > objPoints;
@ -541,7 +546,12 @@ CharucoBoard::CharucoBoard(const Size& size, float squareLength, float markerLen
Board(new CharucoBoardImpl(dictionary, size, squareLength, markerLength)) {
CV_Assert(size.width > 1 && size.height > 1 && markerLength > 0 && squareLength > markerLength);
float onePin = markerLength / ((float)(dictionary.markerSize+2));
float markerSeparation = (squareLength - markerLength)/2.f;
if (markerSeparation < onePin*.7f) {
CV_LOG_WARNING(NULL, "Marker border " << markerSeparation << " is less than 70% of ArUco pin size "
<< onePin <<". Please increase markerSeparation or decrease markerLength for stable board detection");
}
ids.copyTo(impl->ids);
static_pointer_cast<CharucoBoardImpl>(impl)->createCharucoBoard();

Loading…
Cancel
Save