mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-17 15:26:00 +08:00
Board refactoring.
This commit is contained in:
@@ -154,8 +154,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// create board object
|
||||
Ptr<aruco::GridBoard> gridboard =
|
||||
aruco::GridBoard::create(markersX, markersY, markerLength, markerSeparation, dictionary);
|
||||
Ptr<aruco::GridBoard> gridboard = new aruco::GridBoard(Size(markersX, markersY), markerLength, markerSeparation, dictionary);
|
||||
Ptr<aruco::Board> board = gridboard.staticCast<aruco::Board>();
|
||||
|
||||
// collected frames for calibration
|
||||
@@ -176,7 +175,7 @@ int main(int argc, char *argv[]) {
|
||||
detector.detectMarkers(image, corners, ids, rejected);
|
||||
|
||||
// refind strategy to detect more markers
|
||||
if(refindStrategy) detector.refineDetectedMarkers(image, board, corners, ids, rejected);
|
||||
if(refindStrategy) detector.refineDetectedMarkers(image, *board, corners, ids, rejected);
|
||||
|
||||
// draw results
|
||||
image.copyTo(imageCopy);
|
||||
|
@@ -154,8 +154,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// create charuco board object
|
||||
Ptr<aruco::CharucoBoard> charucoboard =
|
||||
aruco::CharucoBoard::create(squaresX, squaresY, squareLength, markerLength, dictionary);
|
||||
Ptr<aruco::CharucoBoard> charucoboard = new aruco::CharucoBoard(Size(squaresX, squaresY), squareLength, markerLength, dictionary);
|
||||
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>();
|
||||
|
||||
// collect data from each frame
|
||||
|
@@ -115,12 +115,11 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ptr<aruco::GridBoard> board = aruco::GridBoard::create(markersX, markersY, float(markerLength),
|
||||
float(markerSeparation), dictionary);
|
||||
aruco::GridBoard board(Size(markersX, markersY), float(markerLength), float(markerSeparation), dictionary);
|
||||
|
||||
// show created board
|
||||
Mat boardImage;
|
||||
board->generateImage(imageSize, boardImage, margins, borderBits);
|
||||
board.generateImage(imageSize, boardImage, margins, borderBits);
|
||||
|
||||
if(showImage) {
|
||||
imshow("board", boardImage);
|
||||
|
@@ -115,12 +115,11 @@ int main(int argc, char *argv[]) {
|
||||
imageSize.width = squaresX * squareLength + 2 * margins;
|
||||
imageSize.height = squaresY * squareLength + 2 * margins;
|
||||
|
||||
Ptr<aruco::CharucoBoard> board = aruco::CharucoBoard::create(squaresX, squaresY, (float)squareLength,
|
||||
(float)markerLength, dictionary);
|
||||
aruco::CharucoBoard board(Size(squaresX, squaresY), (float)squareLength, (float)markerLength, dictionary);
|
||||
|
||||
// show created board
|
||||
Mat boardImage;
|
||||
board->generateImage(imageSize, boardImage, margins, borderBits);
|
||||
board.generateImage(imageSize, boardImage, margins, borderBits);
|
||||
|
||||
if(showImage) {
|
||||
imshow("board", boardImage);
|
||||
|
@@ -150,8 +150,7 @@ int main(int argc, char *argv[]) {
|
||||
markerSeparation);
|
||||
|
||||
// create board object
|
||||
Ptr<aruco::GridBoard> gridboard =
|
||||
aruco::GridBoard::create(markersX, markersY, markerLength, markerSeparation, dictionary);
|
||||
Ptr<aruco::GridBoard> gridboard = new aruco::GridBoard(Size(markersX, markersY), markerLength, markerSeparation, dictionary);
|
||||
Ptr<aruco::Board> board = gridboard.staticCast<aruco::Board>();
|
||||
|
||||
double totalTime = 0;
|
||||
@@ -172,7 +171,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// refind strategy to detect more markers
|
||||
if(refindStrategy)
|
||||
detector.refineDetectedMarkers(image, board, corners, ids, rejected, camMatrix,
|
||||
detector.refineDetectedMarkers(image, *board, corners, ids, rejected, camMatrix,
|
||||
distCoeffs);
|
||||
|
||||
// estimate board pose
|
||||
|
@@ -145,8 +145,7 @@ int main(int argc, char *argv[]) {
|
||||
float axisLength = 0.5f * ((float)min(squaresX, squaresY) * (squareLength));
|
||||
|
||||
// create charuco board object
|
||||
Ptr<aruco::CharucoBoard> charucoboard =
|
||||
aruco::CharucoBoard::create(squaresX, squaresY, squareLength, markerLength, dictionary);
|
||||
Ptr<aruco::CharucoBoard> charucoboard = new aruco::CharucoBoard(Size(squaresX, squaresY), squareLength, markerLength, dictionary);
|
||||
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>();
|
||||
|
||||
double totalTime = 0;
|
||||
|
@@ -15,9 +15,9 @@ static inline void createBoard()
|
||||
{
|
||||
cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
|
||||
//! [createBoard]
|
||||
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04f, 0.02f, dictionary);
|
||||
cv::aruco::CharucoBoard board(cv::Size(5, 7), 0.04f, 0.02f, dictionary);
|
||||
cv::Mat boardImage;
|
||||
board->generateImage(cv::Size(600, 500), boardImage, 10, 1);
|
||||
board.generateImage(cv::Size(600, 500), boardImage, 10, 1);
|
||||
//! [createBoard]
|
||||
cv::imwrite("BoardImage.jpg", boardImage);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ static inline void detectCharucoBoardWithCalibrationPose()
|
||||
} else {
|
||||
//! [dictboard]
|
||||
cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
|
||||
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04f, 0.02f, dictionary);
|
||||
cv::Ptr<cv::aruco::CharucoBoard> board = new cv::aruco::CharucoBoard(cv::Size(5, 7), 0.04f, 0.02f, dictionary);
|
||||
cv::Ptr<cv::aruco::DetectorParameters> params = cv::makePtr<cv::aruco::DetectorParameters>();
|
||||
//! [dictboard]
|
||||
while (inputVideo.grab()) {
|
||||
@@ -90,7 +90,7 @@ static inline void detectCharucoBoardWithoutCalibration()
|
||||
cv::VideoCapture inputVideo;
|
||||
inputVideo.open(0);
|
||||
cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
|
||||
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04f, 0.02f, dictionary);
|
||||
cv::Ptr<cv::aruco::CharucoBoard> board = new cv::aruco::CharucoBoard(cv::Size(5, 7), 0.04f, 0.02f, dictionary);
|
||||
|
||||
cv::Ptr<cv::aruco::DetectorParameters> params = cv::makePtr<cv::aruco::DetectorParameters>();
|
||||
params->cornerRefinementMethod = cv::aruco::CORNER_REFINE_NONE;
|
||||
|
@@ -26,7 +26,7 @@ void refineDetectedMarkers(InputArray _image, const Ptr<Board> &_board,
|
||||
const Ptr<DetectorParameters> &_params) {
|
||||
RefineParameters refineParams(minRepDistance, errorCorrectionRate, checkAllOrders);
|
||||
ArucoDetector detector(_board->getDictionary(), *_params, refineParams);
|
||||
detector.refineDetectedMarkers(_image, _board, _detectedCorners, _detectedIds, _rejectedCorners, _cameraMatrix,
|
||||
detector.refineDetectedMarkers(_image, *_board, _detectedCorners, _detectedIds, _rejectedCorners, _cameraMatrix,
|
||||
_distCoeffs, _recoveredIdxs);
|
||||
}
|
||||
|
||||
|
@@ -383,14 +383,13 @@ void detectCharucoDiamond(InputArray _image, InputArrayOfArrays _markerCorners,
|
||||
// current id is assigned to [0], so it is the marker on the top
|
||||
tmpIds[0] = currentId;
|
||||
// create Charuco board layout for diamond (3x3 layout)
|
||||
Ptr<CharucoBoard> _charucoDiamondLayout = CharucoBoard::create(3, 3, squareMarkerLengthRate, 1., *dictionary,
|
||||
tmpIds);
|
||||
Ptr<CharucoBoard> _charucoDiamondLayout = new CharucoBoard(Size(3, 3), squareMarkerLengthRate, 1., *dictionary, tmpIds);
|
||||
|
||||
// try to find the rest of markers in the diamond
|
||||
vector< int > acceptedIdxs;
|
||||
RefineParameters refineParameters(minRepDistance, -1.f, false);
|
||||
ArucoDetector detector(*dictionary, DetectorParameters(), refineParameters);
|
||||
detector.refineDetectedMarkers(grey, _charucoDiamondLayout, currentMarker, currentMarkerId, candidates,
|
||||
detector.refineDetectedMarkers(grey, *_charucoDiamondLayout, currentMarker, currentMarkerId, candidates,
|
||||
noArray(), noArray(), acceptedIdxs);
|
||||
|
||||
// if found, we have a diamond
|
||||
@@ -456,9 +455,9 @@ void drawCharucoDiamond(const Ptr<Dictionary> &dictionary, Vec4i ids, int square
|
||||
for(int i = 0; i < 4; i++)
|
||||
tmpIds[i] = ids[i];
|
||||
// create a charuco board similar to a charuco marker and print it
|
||||
Ptr<CharucoBoard> board = CharucoBoard::create(3, 3, (float)squareLength, (float)markerLength, *dictionary, tmpIds);
|
||||
CharucoBoard board(Size(3, 3), (float)squareLength, (float)markerLength, *dictionary, tmpIds);
|
||||
Size outSize(3 * squareLength + 2 * marginSize, 3 * squareLength + 2 * marginSize);
|
||||
board->generateImage(outSize, _img, marginSize, borderBits);
|
||||
board.generateImage(outSize, _img, marginSize, borderBits);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user