Skip to content

Commit 9e03d92

Browse files
committed
Board refactoring.
1 parent e2ba6ca commit 9e03d92

9 files changed

+19
-26
lines changed

modules/aruco/samples/calibrate_camera.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ int main(int argc, char *argv[]) {
154154
}
155155

156156
// create board object
157-
Ptr<aruco::GridBoard> gridboard =
158-
aruco::GridBoard::create(markersX, markersY, markerLength, markerSeparation, dictionary);
157+
Ptr<aruco::GridBoard> gridboard = new aruco::GridBoard(Size(markersX, markersY), markerLength, markerSeparation, dictionary);
159158
Ptr<aruco::Board> board = gridboard.staticCast<aruco::Board>();
160159

161160
// collected frames for calibration
@@ -176,7 +175,7 @@ int main(int argc, char *argv[]) {
176175
detector.detectMarkers(image, corners, ids, rejected);
177176

178177
// refind strategy to detect more markers
179-
if(refindStrategy) detector.refineDetectedMarkers(image, board, corners, ids, rejected);
178+
if(refindStrategy) detector.refineDetectedMarkers(image, *board, corners, ids, rejected);
180179

181180
// draw results
182181
image.copyTo(imageCopy);

modules/aruco/samples/calibrate_camera_charuco.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ int main(int argc, char *argv[]) {
154154
}
155155

156156
// create charuco board object
157-
Ptr<aruco::CharucoBoard> charucoboard =
158-
aruco::CharucoBoard::create(squaresX, squaresY, squareLength, markerLength, dictionary);
157+
Ptr<aruco::CharucoBoard> charucoboard = new aruco::CharucoBoard(Size(squaresX, squaresY), squareLength, markerLength, dictionary);
159158
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>();
160159

161160
// collect data from each frame

modules/aruco/samples/create_board.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ int main(int argc, char *argv[]) {
115115
return 0;
116116
}
117117

118-
Ptr<aruco::GridBoard> board = aruco::GridBoard::create(markersX, markersY, float(markerLength),
119-
float(markerSeparation), dictionary);
118+
aruco::GridBoard board(Size(markersX, markersY), float(markerLength), float(markerSeparation), dictionary);
120119

121120
// show created board
122121
Mat boardImage;
123-
board->generateImage(imageSize, boardImage, margins, borderBits);
122+
board.generateImage(imageSize, boardImage, margins, borderBits);
124123

125124
if(showImage) {
126125
imshow("board", boardImage);

modules/aruco/samples/create_board_charuco.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ int main(int argc, char *argv[]) {
115115
imageSize.width = squaresX * squareLength + 2 * margins;
116116
imageSize.height = squaresY * squareLength + 2 * margins;
117117

118-
Ptr<aruco::CharucoBoard> board = aruco::CharucoBoard::create(squaresX, squaresY, (float)squareLength,
119-
(float)markerLength, dictionary);
118+
aruco::CharucoBoard board(Size(squaresX, squaresY), (float)squareLength, (float)markerLength, dictionary);
120119

121120
// show created board
122121
Mat boardImage;
123-
board->generateImage(imageSize, boardImage, margins, borderBits);
122+
board.generateImage(imageSize, boardImage, margins, borderBits);
124123

125124
if(showImage) {
126125
imshow("board", boardImage);

modules/aruco/samples/detect_board.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ int main(int argc, char *argv[]) {
150150
markerSeparation);
151151

152152
// create board object
153-
Ptr<aruco::GridBoard> gridboard =
154-
aruco::GridBoard::create(markersX, markersY, markerLength, markerSeparation, dictionary);
153+
Ptr<aruco::GridBoard> gridboard = new aruco::GridBoard(Size(markersX, markersY), markerLength, markerSeparation, dictionary);
155154
Ptr<aruco::Board> board = gridboard.staticCast<aruco::Board>();
156155

157156
double totalTime = 0;
@@ -172,7 +171,7 @@ int main(int argc, char *argv[]) {
172171

173172
// refind strategy to detect more markers
174173
if(refindStrategy)
175-
detector.refineDetectedMarkers(image, board, corners, ids, rejected, camMatrix,
174+
detector.refineDetectedMarkers(image, gridboard, corners, ids, rejected, camMatrix,
176175
distCoeffs);
177176

178177
// estimate board pose

modules/aruco/samples/detect_board_charuco.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ int main(int argc, char *argv[]) {
145145
float axisLength = 0.5f * ((float)min(squaresX, squaresY) * (squareLength));
146146

147147
// create charuco board object
148-
Ptr<aruco::CharucoBoard> charucoboard =
149-
aruco::CharucoBoard::create(squaresX, squaresY, squareLength, markerLength, dictionary);
148+
Ptr<aruco::CharucoBoard> charucoboard = new aruco::CharucoBoard(Size(squaresX, squaresY), squareLength, markerLength, dictionary);
150149
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>();
151150

152151
double totalTime = 0;

modules/aruco/samples/tutorial_charuco_create_detect.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ static inline void createBoard()
1515
{
1616
cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
1717
//! [createBoard]
18-
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04f, 0.02f, dictionary);
18+
cv::aruco::CharucoBoard board(cv::Size(5, 7), 0.04f, 0.02f, dictionary);
1919
cv::Mat boardImage;
20-
board->generateImage(cv::Size(600, 500), boardImage, 10, 1);
20+
board.generateImage(cv::Size(600, 500), boardImage, 10, 1);
2121
//! [createBoard]
2222
cv::imwrite("BoardImage.jpg", boardImage);
2323
}
@@ -37,7 +37,7 @@ static inline void detectCharucoBoardWithCalibrationPose()
3737
} else {
3838
//! [dictboard]
3939
cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
40-
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04f, 0.02f, dictionary);
40+
cv::Ptr<cv::aruco::CharucoBoard> board = new cv::aruco::CharucoBoard(cv::Size(5, 7), 0.04f, 0.02f, dictionary);
4141
cv::Ptr<cv::aruco::DetectorParameters> params = cv::makePtr<cv::aruco::DetectorParameters>();
4242
//! [dictboard]
4343
while (inputVideo.grab()) {
@@ -90,7 +90,7 @@ static inline void detectCharucoBoardWithoutCalibration()
9090
cv::VideoCapture inputVideo;
9191
inputVideo.open(0);
9292
cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
93-
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04f, 0.02f, dictionary);
93+
cv::Ptr<cv::aruco::CharucoBoard> board = new cv::aruco::CharucoBoard(cv::Size(5, 7), 0.04f, 0.02f, dictionary);
9494

9595
cv::Ptr<cv::aruco::DetectorParameters> params = cv::makePtr<cv::aruco::DetectorParameters>();
9696
params->cornerRefinementMethod = cv::aruco::CORNER_REFINE_NONE;

modules/aruco/src/aruco.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void refineDetectedMarkers(InputArray _image, const Ptr<Board> &_board,
2626
const Ptr<DetectorParameters> &_params) {
2727
RefineParameters refineParams(minRepDistance, errorCorrectionRate, checkAllOrders);
2828
ArucoDetector detector(_board->getDictionary(), *_params, refineParams);
29-
detector.refineDetectedMarkers(_image, _board, _detectedCorners, _detectedIds, _rejectedCorners, _cameraMatrix,
29+
detector.refineDetectedMarkers(_image, *_board, _detectedCorners, _detectedIds, _rejectedCorners, _cameraMatrix,
3030
_distCoeffs, _recoveredIdxs);
3131
}
3232

modules/aruco/src/charuco.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,13 @@ void detectCharucoDiamond(InputArray _image, InputArrayOfArrays _markerCorners,
383383
// current id is assigned to [0], so it is the marker on the top
384384
tmpIds[0] = currentId;
385385
// create Charuco board layout for diamond (3x3 layout)
386-
Ptr<CharucoBoard> _charucoDiamondLayout = CharucoBoard::create(3, 3, squareMarkerLengthRate, 1., *dictionary,
387-
tmpIds);
386+
Ptr<CharucoBoard> _charucoDiamondLayout = new CharucoBoard(Size(3, 3), squareMarkerLengthRate, 1., *dictionary, tmpIds);
388387

389388
// try to find the rest of markers in the diamond
390389
vector< int > acceptedIdxs;
391390
RefineParameters refineParameters(minRepDistance, -1.f, false);
392391
ArucoDetector detector(*dictionary, DetectorParameters(), refineParameters);
393-
detector.refineDetectedMarkers(grey, _charucoDiamondLayout, currentMarker, currentMarkerId, candidates,
392+
detector.refineDetectedMarkers(grey, *_charucoDiamondLayout, currentMarker, currentMarkerId, candidates,
394393
noArray(), noArray(), acceptedIdxs);
395394

396395
// if found, we have a diamond
@@ -456,9 +455,9 @@ void drawCharucoDiamond(const Ptr<Dictionary> &dictionary, Vec4i ids, int square
456455
for(int i = 0; i < 4; i++)
457456
tmpIds[i] = ids[i];
458457
// create a charuco board similar to a charuco marker and print it
459-
Ptr<CharucoBoard> board = CharucoBoard::create(3, 3, (float)squareLength, (float)markerLength, *dictionary, tmpIds);
458+
CharucoBoard board(Size(3, 3), (float)squareLength, (float)markerLength, *dictionary, tmpIds);
460459
Size outSize(3 * squareLength + 2 * marginSize, 3 * squareLength + 2 * marginSize);
461-
board->generateImage(outSize, _img, marginSize, borderBits);
460+
board.generateImage(outSize, _img, marginSize, borderBits);
462461
}
463462

464463
}

0 commit comments

Comments
 (0)