Skip to content

Commit 7a35d3d

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 1490611 + ef5a7e8 commit 7a35d3d

30 files changed

+379
-380
lines changed

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -230,21 +230,19 @@ struct CV_EXPORTS_W DetectorParameters {
230230
* @param parameters marker detection parameters
231231
* @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
232232
* correct codification. Useful for debugging purposes.
233-
* @param cameraMatrix optional input 3x3 floating-point camera matrix
234-
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
235-
* @param distCoeff optional vector of distortion coefficients
236-
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
237233
*
238234
* Performs marker detection in the input image. Only markers included in the specific dictionary
239235
* are searched. For each detected marker, it returns the 2D position of its corner in the image
240236
* and its corresponding identifier.
241237
* Note that this function does not perform pose estimation.
242-
* @sa estimatePoseSingleMarkers, estimatePoseBoard
238+
* @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
239+
* input image with corresponging camera model, if camera parameters are known
240+
* @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
243241
*
244242
*/
245243
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
246244
OutputArray ids, const Ptr<DetectorParameters> &parameters = DetectorParameters::create(),
247-
OutputArrayOfArrays rejectedImgPoints = noArray(), InputArray cameraMatrix= noArray(), InputArray distCoeff= noArray());
245+
OutputArrayOfArrays rejectedImgPoints = noArray());
248246

249247

250248

@@ -274,8 +272,9 @@ CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &diction
274272
* The marker corrdinate system is centered on the middle of the marker, with the Z axis
275273
* perpendicular to the marker plane.
276274
* The coordinates of the four corners of the marker in its own coordinate system are:
277-
* (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
278-
* (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)
275+
* (0, 0, 0), (markerLength, 0, 0),
276+
* (markerLength, markerLength, 0), (0, markerLength, 0)
277+
* @sa use cv::drawFrameAxes to get world coordinate system axis for object points
279278
*/
280279
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
281280
InputArray cameraMatrix, InputArray distCoeffs,
@@ -318,7 +317,14 @@ class CV_EXPORTS_W Board {
318317
CV_WRAP void setIds(InputArray ids);
319318

320319
/// array of object points of all the marker corners in the board
321-
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
320+
/// each marker include its 4 corners in this order:
321+
///- objPoints[i][0] - left-top point of i-th marker
322+
///- objPoints[i][1] - right-top point of i-th marker
323+
///- objPoints[i][2] - right-bottom point of i-th marker
324+
///- objPoints[i][3] - left-bottom point of i-th marker
325+
///
326+
/// Markers are placed in a certain order - row by row, left to right in every row.
327+
/// For M markers, the size is Mx4.
322328
CV_PROP std::vector< std::vector< Point3f > > objPoints;
323329

324330
/// the dictionary of markers employed for this board
@@ -327,6 +333,9 @@ class CV_EXPORTS_W Board {
327333
/// vector of the identifiers of the markers in the board (same size than objPoints)
328334
/// The identifiers refers to the board dictionary
329335
CV_PROP_RW std::vector< int > ids;
336+
337+
/// coordinate of the bottom right corner of the board, is set when calling the function create()
338+
CV_PROP Point3f rightBottomBorder;
330339
};
331340

332341

@@ -426,6 +435,7 @@ class CV_EXPORTS_W GridBoard : public Board {
426435
* Input markers that are not included in the board layout are ignored.
427436
* The function returns the number of markers from the input employed for the board pose estimation.
428437
* Note that returning a 0 means the pose has not been estimated.
438+
* @sa use cv::drawFrameAxes to get world coordinate system axis for object points
429439
*/
430440
CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr<Board> &board,
431441
InputArray cameraMatrix, InputArray distCoeffs, InputOutputArray rvec,
@@ -490,36 +500,14 @@ CV_EXPORTS_W void refineDetectedMarkers(
490500
* Given an array of detected marker corners and its corresponding ids, this functions draws
491501
* the markers in the image. The marker borders are painted and the markers identifiers if provided.
492502
* Useful for debugging purposes.
503+
*
493504
*/
494505
CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays corners,
495506
InputArray ids = noArray(),
496507
Scalar borderColor = Scalar(0, 255, 0));
497508

498509

499510

500-
/**
501-
* @brief Draw coordinate system axis from pose estimation
502-
*
503-
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
504-
* altered.
505-
* @param cameraMatrix input 3x3 floating-point camera matrix
506-
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
507-
* @param distCoeffs vector of distortion coefficients
508-
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
509-
* @param rvec rotation vector of the coordinate system that will be drawn. (@sa Rodrigues).
510-
* @param tvec translation vector of the coordinate system that will be drawn.
511-
* @param length length of the painted axis in the same unit than tvec (usually in meters)
512-
*
513-
* Given the pose estimation of a marker or board, this function draws the axis of the world
514-
* coordinate system, i.e. the system centered on the marker/board. Useful for debugging purposes.
515-
*
516-
* @deprecated use cv::drawFrameAxes
517-
*/
518-
CV_EXPORTS_W void drawAxis(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs,
519-
InputArray rvec, InputArray tvec, float length);
520-
521-
522-
523511
/**
524512
* @brief Draw a canonical marker image
525513
*

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Inp
181181
* This function estimates a Charuco board pose from some detected corners.
182182
* The function checks if the input corners are enough and valid to perform pose estimation.
183183
* If pose estimation is valid, returns true, else returns false.
184+
* @sa use cv::drawFrameAxes to get world coordinate system axis for object points
184185
*/
185186
CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds,
186187
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
@@ -275,6 +276,7 @@ CV_EXPORTS_W double calibrateCameraCharuco(
275276
* diamond.
276277
* @param cameraMatrix Optional camera calibration matrix.
277278
* @param distCoeffs Optional camera distortion coefficients.
279+
* @param dictionary dictionary of markers indicating the type of markers.
278280
*
279281
* This function detects Diamond markers from the previous detected ArUco markers. The diamonds
280282
* are returned in the diamondCorners and diamondIds parameters. If camera calibration parameters
@@ -285,7 +287,8 @@ CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays mark
285287
InputArray markerIds, float squareMarkerLengthRate,
286288
OutputArrayOfArrays diamondCorners, OutputArray diamondIds,
287289
InputArray cameraMatrix = noArray(),
288-
InputArray distCoeffs = noArray());
290+
InputArray distCoeffs = noArray(),
291+
Ptr<Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME::DICT_4X4_50));
289292

290293

291294

modules/aruco/samples/calibrate_camera.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int main(int argc, char *argv[]) {
101101
if(parser.get<bool>("zt")) calibrationFlags |= CALIB_ZERO_TANGENT_DIST;
102102
if(parser.get<bool>("pc")) calibrationFlags |= CALIB_FIX_PRINCIPAL_POINT;
103103

104-
Ptr<aruco::DetectorParameters> detectorParams;
104+
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
105105
if(parser.has("dp")) {
106106
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
107107
bool readOk = aruco::DetectorParameters::readDetectorParameters(fs.root(), detectorParams);

modules/aruco/samples/calibrate_camera_charuco.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int main(int argc, char *argv[]) {
102102
if(parser.get<bool>("zt")) calibrationFlags |= CALIB_ZERO_TANGENT_DIST;
103103
if(parser.get<bool>("pc")) calibrationFlags |= CALIB_FIX_PRINCIPAL_POINT;
104104

105-
Ptr<aruco::DetectorParameters> detectorParams;
105+
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
106106
if(parser.has("dp")) {
107107
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
108108
bool readOk = aruco::DetectorParameters::readDetectorParameters(fs.root(), detectorParams);

modules/aruco/samples/detect_board.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
9797
}
9898
}
9999

100-
Ptr<aruco::DetectorParameters> detectorParams;
100+
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
101101
if(parser.has("dp")) {
102102
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
103103
bool readOk = aruco::DetectorParameters::readDetectorParameters(fs.root(), detectorParams);
@@ -199,7 +199,7 @@ int main(int argc, char *argv[]) {
199199
aruco::drawDetectedMarkers(imageCopy, rejected, noArray(), Scalar(100, 0, 255));
200200

201201
if(markersOfBoardDetected > 0)
202-
aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvec, tvec, axisLength);
202+
cv::drawFrameAxes(imageCopy, camMatrix, distCoeffs, rvec, tvec, axisLength);
203203

204204
imshow("out", imageCopy);
205205
char key = (char)waitKey(waitTime);

modules/aruco/samples/detect_board_charuco.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int main(int argc, char *argv[]) {
9999
}
100100
}
101101

102-
Ptr<aruco::DetectorParameters> detectorParams;
102+
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
103103
if(parser.has("dp")) {
104104
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
105105
bool readOk = aruco::DetectorParameters::readDetectorParameters(fs.root(), detectorParams);
@@ -213,7 +213,7 @@ int main(int argc, char *argv[]) {
213213
}
214214

215215
if(validPose)
216-
aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvec, tvec, axisLength);
216+
cv::drawFrameAxes(imageCopy, camMatrix, distCoeffs, rvec, tvec, axisLength);
217217

218218
imshow("out", imageCopy);
219219
char key = (char)waitKey(waitTime);

modules/aruco/samples/detect_diamonds.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int main(int argc, char *argv[]) {
8787
bool autoScale = parser.has("as");
8888
float autoScaleFactor = autoScale ? parser.get<float>("as") : 1.f;
8989

90-
Ptr<aruco::DetectorParameters> detectorParams;
90+
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
9191
if(parser.has("dp")) {
9292
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
9393
bool readOk = aruco::DetectorParameters::readDetectorParameters(fs.root(), detectorParams);
@@ -219,8 +219,8 @@ int main(int argc, char *argv[]) {
219219

220220
if(estimatePose) {
221221
for(unsigned int i = 0; i < diamondIds.size(); i++)
222-
aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i],
223-
squareLength * 0.5f);
222+
cv::drawFrameAxes(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i],
223+
squareLength * 1.1f);
224224
}
225225
}
226226

modules/aruco/samples/detect_markers.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int main(int argc, char *argv[]) {
8080
bool estimatePose = parser.has("c");
8181
float markerLength = parser.get<float>("l");
8282

83-
Ptr<aruco::DetectorParameters> detectorParams;
83+
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
8484
if(parser.has("dp")) {
8585
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
8686
bool readOk = aruco::DetectorParameters::readDetectorParameters(fs.root(), detectorParams);
@@ -179,8 +179,7 @@ int main(int argc, char *argv[]) {
179179

180180
if(estimatePose) {
181181
for(unsigned int i = 0; i < ids.size(); i++)
182-
aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i],
183-
markerLength * 0.5f);
182+
cv::drawFrameAxes(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i], markerLength * 1.5f, 2);
184183
}
185184
}
186185

modules/aruco/samples/tutorial_charuco_create_detect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static inline void detectCharucoBoardWithCalibrationPose()
7272
//! [pose]
7373
// if charuco pose is valid
7474
if (valid)
75-
cv::aruco::drawAxis(imageCopy, cameraMatrix, distCoeffs, rvec, tvec, 0.1f);
75+
cv::drawFrameAxes(imageCopy, cameraMatrix, distCoeffs, rvec, tvec, 0.1f);
7676
}
7777
}
7878
cv::imshow("out", imageCopy);

0 commit comments

Comments
 (0)