Skip to content

Commit 4db2299

Browse files
author
AleksandrPanov
committed
remove static create, remove setters, move EstimateParameters, fix Python
1 parent 4d96b1f commit 4db2299

18 files changed

+125
-84
lines changed

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
namespace cv {
1111
namespace aruco {
1212

13-
1413
/**
1514
@deprecated Use class ArucoDetector::detectMarkers
1615
*/
1716
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
18-
OutputArray ids, const Ptr<DetectorParameters> &parameters = DetectorParameters::create(),
17+
OutputArray ids, const Ptr<DetectorParameters> &parameters = makePtr<DetectorParameters>(),
1918
OutputArrayOfArrays rejectedImgPoints = noArray());
2019

2120
/**
@@ -27,7 +26,7 @@ CV_EXPORTS_W void refineDetectedMarkers(InputArray image,const Ptr<Board> &boar
2726
InputArray cameraMatrix = noArray(), InputArray distCoeffs = noArray(),
2827
float minRepDistance = 10.f, float errorCorrectionRate = 3.f,
2928
bool checkAllOrders = true, OutputArray recoveredIdxs = noArray(),
30-
const Ptr<DetectorParameters> &parameters = DetectorParameters::create());
29+
const Ptr<DetectorParameters> &parameters = makePtr<DetectorParameters>());
3130

3231
/**
3332
@deprecated Use Board::draw
@@ -138,15 +137,13 @@ CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray
138137
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
139138
InputArray cameraMatrix, InputArray distCoeffs,
140139
OutputArray rvecs, OutputArray tvecs, OutputArray objPoints = noArray(),
141-
const Ptr<EstimateParameters>& estimateParameters = EstimateParameters::create());
140+
const Ptr<EstimateParameters>& estimateParameters = makePtr<EstimateParameters>());
142141

143142

144-
/**
145-
@deprecated Use CharucoBoard::testCharucoCornersCollinear
143+
/** @deprecated Use CharucoBoard::testCharucoCornersCollinear
146144
*/
147145
CV_EXPORTS_W bool testCharucoCornersCollinear(const Ptr<CharucoBoard> &board, InputArray charucoIds);
148146

149-
150147
}
151148
}
152149

modules/aruco/include/opencv2/aruco/aruco_calib.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,55 @@ namespace aruco {
1111
//! @addtogroup aruco
1212
//! @{
1313

14+
/** @brief rvec/tvec define the right handed coordinate system of the marker.
15+
*
16+
* PatternPositionType defines center this system and axes direction.
17+
* Axis X (red color) - first coordinate, axis Y (green color) - second coordinate,
18+
* axis Z (blue color) - third coordinate.
19+
* @sa estimatePoseSingleMarkers(), check tutorial_aruco_detection in aruco contrib
20+
*/
21+
enum PatternPositionType {
22+
/** @brief The marker coordinate system is centered on the middle of the marker.
23+
*
24+
* The coordinates of the four corners (CCW order) of the marker in its own coordinate system are:
25+
* (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
26+
* (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0).
27+
*
28+
* These pattern points define this coordinate system:
29+
* ![Image with axes drawn](tutorials/images/singlemarkersaxes.jpg)
30+
*/
31+
ARUCO_CCW_CENTER,
32+
/** @brief The marker coordinate system is centered on the top-left corner of the marker.
33+
*
34+
* The coordinates of the four corners (CW order) of the marker in its own coordinate system are:
35+
* (0, 0, 0), (markerLength, 0, 0),
36+
* (markerLength, markerLength, 0), (0, markerLength, 0).
37+
*
38+
* These pattern points define this coordinate system:
39+
* ![Image with axes drawn](tutorials/images/singlemarkersaxes2.jpg)
40+
*
41+
* These pattern dots are convenient to use with a chessboard/ChArUco board.
42+
*/
43+
ARUCO_CW_TOP_LEFT_CORNER
44+
};
45+
46+
/** @brief Pose estimation parameters
47+
*
48+
* @param pattern Defines center this system and axes direction (default PatternPositionType::ARUCO_CCW_CENTER).
49+
* @param useExtrinsicGuess Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses the provided
50+
* rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further
51+
* optimizes them (default false).
52+
* @param solvePnPMethod Method for solving a PnP problem: see @ref calib3d_solvePnP_flags (default SOLVEPNP_ITERATIVE).
53+
* @sa PatternPositionType, solvePnP(), check tutorial_aruco_detection in aruco contrib
54+
*/
55+
struct CV_EXPORTS_W EstimateParameters {
56+
CV_PROP_RW PatternPositionType pattern;
57+
CV_PROP_RW bool useExtrinsicGuess;
58+
CV_PROP_RW int solvePnPMethod;
59+
60+
CV_WRAP EstimateParameters();
61+
};
62+
1463
/**
1564
* @brief Calibrate a camera using aruco markers
1665
*

modules/aruco/misc/java/test/ArucoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public void testArucoIssue3133() {
3333

3434
public void testArucoDetector() {
3535
Dictionary dictionary = Dictionary.get(0);
36-
DetectorParameters detectorParameters = DetectorParameters.create();
37-
ArucoDetector detector = ArucoDetector.create(dictionary, detectorParameters);
36+
DetectorParameters detectorParameters = new DetectorParameters();
37+
ArucoDetector detector = new ArucoDetector(dictionary, detectorParameters);
3838

3939
Mat markerImage = new Mat();
4040
int id = 1, offset = 5, size = 40;

modules/aruco/misc/python/test/test_aruco.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ def test_idsAccessibility(self):
2121

2222
np.testing.assert_array_equal(board.getIds().squeeze(), ids)
2323

24-
board.setIds(rev_ids)
24+
board = cv.aruco.CharucoBoard_create(7, 5, 1, 0.5, aruco_dict, rev_ids)
2525
np.testing.assert_array_equal(board.getIds().squeeze(), rev_ids)
2626

27-
board.setIds(ids)
27+
board = cv.aruco.CharucoBoard_create(7, 5, 1, 0.5, aruco_dict, ids)
2828
np.testing.assert_array_equal(board.getIds().squeeze(), ids)
2929

30-
with self.assertRaises(cv.error):
31-
board.setIds(np.array([0]))
32-
3330
def test_drawCharucoDiamond(self):
3431
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
3532
img = cv.aruco.drawCharucoDiamond(aruco_dict, np.array([0, 1, 2, 3]), 100, 80)
@@ -86,9 +83,9 @@ def test_getDistanceToId(self):
8683
self.assertEqual(dist, 0)
8784

8885
def test_aruco_detector(self):
89-
aruco_params = cv.aruco.DetectorParameters_create()
86+
aruco_params = cv.aruco.DetectorParameters()
9087
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_250)
91-
aruco_detector = cv.aruco.ArucoDetector_create(aruco_dict, aruco_params)
88+
aruco_detector = cv.aruco.ArucoDetector(aruco_dict, aruco_params)
9289
id = 2
9390
marker_size = 100
9491
offset = 10
@@ -109,9 +106,9 @@ def test_aruco_detector(self):
109106
np.testing.assert_array_equal(gold_corners, corners[i].reshape(4, 2))
110107

111108
def test_aruco_detector_refine(self):
112-
aruco_params = cv.aruco.DetectorParameters_create()
109+
aruco_params = cv.aruco.DetectorParameters()
113110
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_250)
114-
aruco_detector = cv.aruco.ArucoDetector_create(aruco_dict, aruco_params)
111+
aruco_detector = cv.aruco.ArucoDetector(aruco_dict, aruco_params)
115112
board_size = (3, 4)
116113
board = cv.aruco.GridBoard_create(board_size[0], board_size[1], 5.0, 1.0, aruco_dict)
117114
board_image = board.draw((board_size[0]*50, board_size[1]*50), marginSize=10)

modules/aruco/perf/perf_aruco.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ PERF_TEST_P(EstimateAruco, ArucoFirst, ESTIMATE_PARAMS)
178178
{
179179
UseArucoParams testParams = GetParam();
180180
Ptr<aruco::Dictionary> dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250);
181-
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
181+
Ptr<aruco::DetectorParameters> detectorParams = makePtr<aruco::DetectorParameters>();
182182
detectorParams->minDistanceToBorder = 1;
183183
detectorParams->markerBorderBits = 1;
184184
detectorParams->cornerRefinementMethod = cv::aruco::CORNER_REFINE_SUBPIX;
@@ -212,7 +212,7 @@ PERF_TEST_P(EstimateAruco, ArucoSecond, ESTIMATE_PARAMS)
212212
{
213213
UseArucoParams testParams = GetParam();
214214
Ptr<aruco::Dictionary> dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250);
215-
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
215+
Ptr<aruco::DetectorParameters> detectorParams = makePtr<aruco::DetectorParameters>();
216216
detectorParams->minDistanceToBorder = 1;
217217
detectorParams->markerBorderBits = 1;
218218
detectorParams->cornerRefinementMethod = cv::aruco::CORNER_REFINE_SUBPIX;
@@ -268,7 +268,7 @@ PERF_TEST_P(EstimateLargeAruco, ArucoFHD, ESTIMATE_FHD_PARAMS)
268268
{
269269
ArucoTestParams testParams = GetParam();
270270
Ptr<aruco::Dictionary> dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250);
271-
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
271+
Ptr<aruco::DetectorParameters> detectorParams = makePtr<aruco::DetectorParameters>();
272272
detectorParams->minDistanceToBorder = 1;
273273
detectorParams->markerBorderBits = 1;
274274
detectorParams->cornerRefinementMethod = cv::aruco::CORNER_REFINE_SUBPIX;

modules/aruco/samples/calibrate_camera.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 = aruco::DetectorParameters::create();
105+
Ptr<aruco::DetectorParameters> detectorParams = makePtr<aruco::DetectorParameters>();
106106
if(parser.has("dp")) {
107107
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
108108
bool readOk = detectorParams->readDetectorParameters(fs.root());

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

modules/aruco/samples/detect_board.cpp

Lines changed: 1 addition & 1 deletion
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 = aruco::DetectorParameters::create();
100+
Ptr<aruco::DetectorParameters> detectorParams = makePtr<aruco::DetectorParameters>();
101101
if(parser.has("dp")) {
102102
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
103103
bool readOk = detectorParams->readDetectorParameters(fs.root());

modules/aruco/samples/detect_board_charuco.cpp

Lines changed: 1 addition & 1 deletion
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 = aruco::DetectorParameters::create();
102+
Ptr<aruco::DetectorParameters> detectorParams = makePtr<aruco::DetectorParameters>();
103103
if(parser.has("dp")) {
104104
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
105105
bool readOk = detectorParams->readDetectorParameters(fs.root());

modules/aruco/samples/detect_diamonds.cpp

Lines changed: 1 addition & 1 deletion
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 = aruco::DetectorParameters::create();
90+
Ptr<aruco::DetectorParameters> detectorParams = makePtr<aruco::DetectorParameters>();
9191
if(parser.has("dp")) {
9292
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
9393
bool readOk = detectorParams->readDetectorParameters(fs.root());

0 commit comments

Comments
 (0)