Skip to content

Commit 1ba4e68

Browse files
committed
add setIds and make ids field RW in python
1 parent 4613c51 commit 1ba4e68

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ class CV_EXPORTS_W Board {
281281
*
282282
*/
283283
CV_WRAP static Ptr<Board> create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids);
284+
284285
/// array of object points of all the marker corners in the board
285286
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
286287
CV_PROP std::vector< std::vector< Point3f > > objPoints;
@@ -290,7 +291,7 @@ class CV_EXPORTS_W Board {
290291

291292
/// vector of the identifiers of the markers in the board (same size than objPoints)
292293
/// The identifiers refers to the board dictionary
293-
CV_PROP std::vector< int > ids;
294+
CV_PROP_RW std::vector< int > ids;
294295
};
295296

296297

modules/aruco/include/opencv2/aruco/charuco.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ class CV_EXPORTS_W CharucoBoard : public Board {
100100
CV_WRAP static Ptr<CharucoBoard> create(int squaresX, int squaresY, float squareLength,
101101
float markerLength, const Ptr<Dictionary> &dictionary);
102102

103+
/**
104+
* @brief Set ids vector
105+
*
106+
* @param ids vector of the identifiers of the markers in the board (should be the same size
107+
* as objPoints)
108+
*
109+
* Safe way to set ids vector instead of backward-compatible legacy solution using direct assignment
110+
* to ids field.
111+
*/
112+
CV_WRAP void setIds(InputArray ids);
113+
103114
/**
104115
*
105116
*/

modules/aruco/src/charuco.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ Ptr<CharucoBoard> CharucoBoard::create(int squaresX, int squaresY, float squareL
170170
return res;
171171
}
172172

173-
173+
void CharucoBoard::setIds(InputArray ids_) {
174+
CV_Assert(objPoints.size() == ids_.total());
175+
ids_.copyTo(this->ids);
176+
}
174177

175178
/**
176179
* Fill nearestMarkerIdx and nearestMarkerCorners arrays

0 commit comments

Comments
 (0)