Skip to content

Commit 3b3e47c

Browse files
author
AleksandrPanov
committed
remove gloabal params (threshold)
1 parent 42018ae commit 3b3e47c

File tree

6 files changed

+108
-254
lines changed

6 files changed

+108
-254
lines changed

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,7 @@ enum CornerRefineMethod{
163163
* Latter is the binarized image in which contours are searched.
164164
* So all contours with a size smaller than minSideLengthCanonicalImg*minSideLengthCanonicalImg will omitted from the search.
165165
* - minMarkerLengthRatioOriginalImg: range [0,1], eq (2) from paper
166-
* - cameraMotionSpeed: is in the range [0,1]. This parameter (tau_s in the paper) implements the feature proposed
167-
* in Section 3.7. and is particularly useful for video sequences.
168-
* The parameter tau_i has a direct influence on the processing speed. Instead of setting a fixed value for it,
169-
* it can be adjusted at the end of each frame using
170-
* tau_i = (1-tau_s)*P(v_s)/4 (eq. 6 in paper).
171-
* Where P(v_s) is the perimeter of the smallest marker that was detected in the last frame.
172-
* - useGlobalThreshold: if we process a video, the assumption is, that the illumination conditions remains
173-
* constant and global instead of adaptive thresholding can be applied, speeding up the binarization step.
174-
* - foundGlobalThreshold: internal variable. It is used to cache the variable to the next detector call.
175-
* - otsuGlobalThreshold: internal variable. It is used to cache the global otsu threshold to the next detector call.
176-
* - foundMarkerInLastFrames: internal variable. It is used to cache if markers were found in the last frame.
166+
* The parameter tau_i has a direct influence on the processing speed.
177167
*/
178168
struct CV_EXPORTS_W DetectorParameters {
179169

@@ -222,13 +212,6 @@ struct CV_EXPORTS_W DetectorParameters {
222212
CV_PROP_RW bool useAruco3Detection;
223213
CV_PROP_RW int minSideLengthCanonicalImg;
224214
CV_PROP_RW float minMarkerLengthRatioOriginalImg;
225-
226-
// New Aruco functionality especially for video
227-
CV_PROP_RW float cameraMotionSpeed;
228-
CV_PROP_RW bool useGlobalThreshold;
229-
CV_PROP_RW bool foundGlobalThreshold;
230-
CV_PROP_RW float otsuGlobalThreshold;
231-
CV_PROP_RW int foundMarkerInLastFrames;
232215
};
233216

234217

@@ -256,13 +239,12 @@ struct CV_EXPORTS_W DetectorParameters {
256239
* are searched. For each detected marker, it returns the 2D position of its corner in the image
257240
* and its corresponding identifier.
258241
* Note that this function does not perform pose estimation.
259-
* The function returns an estimate of the parameter minMarkerLengthRatioOriginalImg if useAruco3Detection=1. If not it returns 0.0.
260242
* @sa estimatePoseSingleMarkers, estimatePoseBoard
261243
*
262244
*/
263-
CV_EXPORTS_W float detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
264-
OutputArray ids, const Ptr<DetectorParameters> &parameters = DetectorParameters::create(),
265-
OutputArrayOfArrays rejectedImgPoints = noArray(), InputArray cameraMatrix= noArray(), InputArray distCoeff= noArray());
245+
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
246+
OutputArray ids, const Ptr<DetectorParameters> &parameters = DetectorParameters::create(),
247+
OutputArrayOfArrays rejectedImgPoints = noArray(), InputArray cameraMatrix= noArray(), InputArray distCoeff= noArray());
266248

267249

268250

modules/aruco/perf/perf_aruco.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,4 @@ PERF_TEST_P(EstimateLargeAruco, ArucoFHD, ESTIMATE_FHD_PARAMS)
288288
SANITY_CHECK_NOTHING();
289289
}
290290

291-
}
291+
}

modules/aruco/samples/detect_markers.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ const char* keys =
6363
"{dp | | File of marker detector parameters }"
6464
"{r | | show rejected candidates too }"
6565
"{refine | | Corner refinement: CORNER_REFINE_NONE=0, CORNER_REFINE_SUBPIX=1,"
66-
"CORNER_REFINE_CONTOUR=2, CORNER_REFINE_APRILTAG=3}"
67-
"{ar3vid | | Adapt the paramater tau_i if aruco3 functionality is used. }";
66+
"CORNER_REFINE_CONTOUR=2, CORNER_REFINE_APRILTAG=3}";
6867
}
6968
//! [aruco_detect_markers_keys]
7069

@@ -80,7 +79,6 @@ int main(int argc, char *argv[]) {
8079
bool showRejected = parser.has("r");
8180
bool estimatePose = parser.has("c");
8281
float markerLength = parser.get<float>("l");
83-
bool useAruco3DynamicUpdates = parser.has("ar3vid");
8482

8583
Ptr<aruco::DetectorParameters> detectorParams;
8684
if(parser.has("dp")) {
@@ -141,7 +139,7 @@ int main(int argc, char *argv[]) {
141139
int waitTime;
142140
if(!video.empty()) {
143141
inputVideo.open(video);
144-
waitTime = 1;
142+
waitTime = 0;
145143
} else {
146144
inputVideo.open(camId);
147145
waitTime = 10;
@@ -150,8 +148,6 @@ int main(int argc, char *argv[]) {
150148
double totalTime = 0;
151149
int totalIterations = 0;
152150

153-
float new_marker_length_ratio = 0.0;
154-
size_t total_nr_detected_corners = 0;
155151
while(inputVideo.grab()) {
156152
Mat image, imageCopy;
157153
inputVideo.retrieve(image);
@@ -163,16 +159,7 @@ int main(int argc, char *argv[]) {
163159
vector< Vec3d > rvecs, tvecs;
164160

165161
// detect markers and estimate pose
166-
if (useAruco3DynamicUpdates) {
167-
// if new aruco3 features are used, we can also set the new min
168-
// marker length ratio dymamically from the last frame
169-
detectorParams->minMarkerLengthRatioOriginalImg = new_marker_length_ratio;
170-
if(totalIterations % 30 == 0) {
171-
cout<<"Current tau_i= "<<new_marker_length_ratio<<"\n";
172-
}
173-
}
174-
new_marker_length_ratio = aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected);
175-
total_nr_detected_corners += ids.size();
162+
aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected);
176163
if(estimatePose && ids.size() > 0)
177164
aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs,
178165
tvecs);

0 commit comments

Comments
 (0)