Merge pull request #24228 from AleksandrPanov:fix_extendDictionary

fix extendDictionary
pull/24247/head
Alexander Smorkalov 1 year ago committed by GitHub
commit 757d296382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      modules/objdetect/src/aruco/aruco_dictionary.cpp
  2. 8
      modules/objdetect/test/test_boarddetection.cpp

@ -355,6 +355,7 @@ static int _getSelfDistance(const Mat &marker) {
Dictionary extendDictionary(int nMarkers, int markerSize, const Dictionary &baseDictionary, int randomSeed) {
CV_Assert(nMarkers > 0);
RNG rng((uint64)(randomSeed));
Dictionary out = Dictionary(Mat(), markerSize);
@ -370,7 +371,7 @@ Dictionary extendDictionary(int nMarkers, int markerSize, const Dictionary &base
// if baseDictionary is provided, calculate its intermarker distance
if(baseDictionary.bytesList.rows > 0) {
CV_Assert(baseDictionary.markerSize == markerSize);
out.bytesList = baseDictionary.bytesList.clone();
out.bytesList = baseDictionary.bytesList.rowRange(0, min(nMarkers, baseDictionary.bytesList.rows)).clone();
int minDistance = markerSize * markerSize + 1;
for(int i = 0; i < out.bytesList.rows; i++) {

@ -318,4 +318,12 @@ TEST(CV_ArucoGenerateBoard, regression_1226) {
});
}
TEST(CV_ArucoDictionary, extendDictionary) {
aruco::Dictionary base_dictionary = aruco::getPredefinedDictionary(aruco::DICT_4X4_250);
aruco::Dictionary custom_dictionary = aruco::extendDictionary(150, 4, base_dictionary);
ASSERT_EQ(custom_dictionary.bytesList.rows, 150);
ASSERT_EQ(cv::norm(custom_dictionary.bytesList, base_dictionary.bytesList.rowRange(0, 150)), 0.);
}
}} // namespace

Loading…
Cancel
Save