Skip to content

Commit b511cfa

Browse files
author
AleksandrPanov
committed
add gridImpl
1 parent 4326ae5 commit b511cfa

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

modules/aruco/include/opencv2/aruco/aruco_calib_pose.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ double calibrateCameraAruco(InputArrayOfArrays corners, InputArray ids, InputArr
193193
OutputArray stdDeviationsExtrinsics, OutputArray perViewErrors, int flags = 0,
194194
const TermCriteria& criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
195195

196-
/**
196+
/** @overload
197197
* @brief It's the same function as #calibrateCameraAruco but without calibration error estimation.
198-
* @overload
199198
*/
200199
CV_EXPORTS_W double calibrateCameraAruco(InputArrayOfArrays corners, InputArray ids, InputArray counter,
201200
const Ptr<Board> &board, Size imageSize, InputOutputArray cameraMatrix,

modules/aruco/include/opencv2/aruco/board.hpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ CV_EXPORTS_W void drawPlanarBoard(const Ptr<Board> &board, Size outSize, OutputA
9090
*/
9191

9292
class CV_EXPORTS_W GridBoard : public Board {
93-
public:
93+
public:
94+
CV_EXPORTS_W GridBoard();
9495
/**
9596
* @brief Draw a GridBoard
9697
*
@@ -121,21 +122,13 @@ class CV_EXPORTS_W GridBoard : public Board {
121122
CV_WRAP static Ptr<GridBoard> create(int markersX, int markersY, float markerLength, float markerSeparation,
122123
const Ptr<Dictionary> &dictionary, int firstMarker = 0);
123124

124-
CV_WRAP Size getGridSize() const { return Size(_markersX, _markersY); }
125-
126-
CV_WRAP float getMarkerLength() const { return _markerLength; }
127-
128-
CV_WRAP float getMarkerSeparation() const { return _markerSeparation; }
129-
130-
private:
131-
// number of markers in X and Y directions
132-
int _markersX, _markersY;
125+
CV_WRAP Size getGridSize() const;
126+
CV_WRAP float getMarkerLength();
127+
CV_WRAP float getMarkerSeparation();
133128

134-
// marker side length (normally in meters)
135-
float _markerLength;
136-
137-
// separation between markers in the grid
138-
float _markerSeparation;
129+
protected:
130+
struct GridImpl;
131+
Ptr<GridImpl> gridImpl;
139132
};
140133

141134
/**
@@ -147,7 +140,7 @@ class CV_EXPORTS_W GridBoard : public Board {
147140
* This class also allows the easy creation and drawing of ChArUco boards.
148141
*/
149142
class CV_EXPORTS_W CharucoBoard : public Board {
150-
public:
143+
public:
151144
// vector of chessboard 3D corners precalculated
152145
CV_PROP std::vector<Point3f> chessboardCorners;
153146

@@ -185,9 +178,7 @@ class CV_EXPORTS_W CharucoBoard : public Board {
185178
float markerLength, const Ptr<Dictionary> &dictionary);
186179

187180
CV_WRAP Size getChessboardSize() const { return Size(_squaresX, _squaresY); }
188-
189181
CV_WRAP float getSquareLength() const { return _squareLength; }
190-
191182
CV_WRAP float getMarkerLength() const { return _markerLength; }
192183

193184
private:

modules/aruco/src/board.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ namespace cv {
1010
namespace aruco {
1111
using namespace std;
1212

13-
/**
14-
* @brief Implementation of drawPlanarBoard that accepts a raw Board pointer.
13+
/** @brief Implementation of drawPlanarBoard that accepts a raw Board pointer.
1514
*/
1615
static void _drawPlanarBoardImpl(Board *_board, Size outSize, OutputArray _img, int marginSize, int borderBits) {
1716
CV_Assert(!outSize.empty());
@@ -99,6 +98,20 @@ void drawPlanarBoard(const Ptr<Board> &_board, Size outSize, OutputArray _img, i
9998
_drawPlanarBoardImpl(_board, outSize, _img, marginSize, borderBits);
10099
}
101100

101+
struct GridBoard::GridImpl {
102+
GridImpl(){};
103+
// number of markers in X and Y directions
104+
int sizeX = 3, sizeY = 3;
105+
106+
// marker side length (normally in meters)
107+
float markerLength = 1.f;
108+
109+
// separation between markers in the grid
110+
float markerSeparation = .5f;
111+
};
112+
113+
GridBoard::GridBoard(): gridImpl(makePtr<GridImpl>()) {}
114+
102115
Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids) {
103116
CV_Assert(objPoints.total() == ids.total());
104117
CV_Assert(objPoints.type() == CV_32FC3 || objPoints.type() == CV_32FC1);
@@ -139,10 +152,10 @@ Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength,
139152
const Ptr<Dictionary> &dictionary, int firstMarker) {
140153
CV_Assert(markersX > 0 && markersY > 0 && markerLength > 0 && markerSeparation > 0);
141154
Ptr<GridBoard> res = makePtr<GridBoard>();
142-
res->_markersX = markersX;
143-
res->_markersY = markersY;
144-
res->_markerLength = markerLength;
145-
res->_markerSeparation = markerSeparation;
155+
res->gridImpl->sizeX = markersX;
156+
res->gridImpl->sizeY = markersY;
157+
res->gridImpl->markerLength = markerLength;
158+
res->gridImpl->markerSeparation = markerSeparation;
146159
res->dictionary = dictionary;
147160

148161
size_t totalMarkers = (size_t) markersX * markersY;
@@ -175,6 +188,19 @@ void GridBoard::draw(Size outSize, OutputArray _img, int marginSize, int borderB
175188
_drawPlanarBoardImpl((Board*)this, outSize, _img, marginSize, borderBits);
176189
}
177190

191+
Size GridBoard::getGridSize() const {
192+
return Size(gridImpl->sizeX, gridImpl->sizeY);
193+
}
194+
195+
float GridBoard::getMarkerLength() {
196+
return gridImpl->markerLength;
197+
}
198+
199+
float GridBoard::getMarkerSeparation() {
200+
return gridImpl->markerSeparation;
201+
}
202+
203+
178204
void CharucoBoard::draw(Size outSize, OutputArray _img, int marginSize, int borderBits) {
179205
CV_Assert(!outSize.empty());
180206
CV_Assert(marginSize >= 0);

0 commit comments

Comments
 (0)