Skip to content
Snippets Groups Projects
Commit f596a379 authored by Mederic Fourmy's avatar Mederic Fourmy
Browse files

Optimize parameters for speed -> barely under 1/30 s for detection of quads on macbook 8 threads

parent 2f091fd5
No related branches found
No related tags found
1 merge request!233WIP: Apriltag
processor type: "TRACKER LANDMARK APRILTAG"
processor name: "tracker landmark apriltag example"
detector parameters:
quad_decimate: 0.0
quad_sigma: 2.0
nthreads: 4
debug: false
refine_edges: true
refine_decode: true
refine_pose: true
ippe_min_ratio: 3.0 # quite arbitrary, always > 1 (to deactive, set at 0 for example)
quad_decimate: 1.5 # doing quad detection at lower resolution to speed things up (see end of file)
quad_sigma: 0.8 # gaussian blur good for noisy images, may be recommended with quad_decimate. Kernel size adapted (see end of this file)
nthreads: 8 # how many thread during tag detection (does not change much?)
debug: false # write some debugging images
refine_edges: true # better edge detection if quad_decimate > 1 (quite inexpensive, almost no diff)
refine_decode: false # improve detection probability for small tags (quite expensive (~*3)
refine_pose: false # improves detection by maximizing local contrast so that future pose extraction works better (VERY expensive ~*10-20)
ippe_min_ratio: 3.0 # quite arbitrary, always > 1 (to deactive, set at 0 for example)
ippe_max_rep_error: 2.0 # to deactivate, set at something big (100)
tag parameters:
......@@ -33,3 +32,21 @@ vote:
voting active: true
min_time_vote: 0.2 # s
min_features_for_keyframe: 1
# Annexes:
### Quad decimate: the higher, the lower the resolution
# Does nothing if <= 1.0
# Only values taken into account:
# 1.5, 2, 3, 4
# 1.5 -> ~*2 speed up
# Higher values use a "bad" code according to commentaries in the library, smaller do nothing
### Gaussian blur table:
# max sigma kernel size
# 0.499 1 (disabled)
# 0.999 3
# 1.499 5
# 1.999 7
......@@ -69,6 +69,26 @@ ProcessorTrackerLandmarkApriltag::ProcessorTrackerLandmarkApriltag( ProcessorPar
detector_ = *apriltag_detector_create();
apriltag_detector_add_family(&detector_, &tag_family_);
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
WOLF_TRACE("\n\n\n\n", _params_tracker_landmark_apriltag->nthreads_, "\n\n\n\n");
detector_.quad_decimate = _params_tracker_landmark_apriltag->quad_decimate_;
detector_.quad_sigma = _params_tracker_landmark_apriltag->quad_sigma_;
detector_.nthreads = _params_tracker_landmark_apriltag->nthreads_;
......@@ -126,7 +146,9 @@ void ProcessorTrackerLandmarkApriltag::preProcess()
};
// run Apriltag detector
// const clock_t begin_time_detection = clock();
zarray_t *detections = apriltag_detector_detect(&detector_, &im);
// WOLF_DEBUG("tag detection: ", (double)(clock() - begin_time_detection) / CLOCKS_PER_SEC);
// loop all detections
for (int i = 0; i < zarray_size(detections); i++) {
......@@ -148,7 +170,6 @@ void ProcessorTrackerLandmarkApriltag::preProcess()
Scalar rep_error1;
Scalar rep_error2;
ippePoseEstimation(det, cv_K_, tag_width, M_ippe1, rep_error1, M_ippe2, rep_error2);
// If not so sure about whether we have the right solution or not, do not create a feature
is_ambiguous = !((rep_error2 / rep_error1 > ippe_min_ratio_) && rep_error1 < ippe_max_rep_error_);
//////////////////
......@@ -169,8 +190,8 @@ void ProcessorTrackerLandmarkApriltag::preProcess()
// M_april = umichPoseEstimation(det, cv_K_, tag_width);
//////////////////
WOLF_DEBUG("ippe1\n", M_ippe1 .matrix());
WOLF_DEBUG("ippe2\n", M_ippe2 .matrix());
// WOLF_DEBUG("ippe1\n", M_ippe1 .matrix());
// WOLF_DEBUG("ippe2\n", M_ippe2 .matrix());
// WOLF_DEBUG("M_PnP\n", M_PnP .matrix());
// WOLF_DEBUG("M_april\n", M_april .matrix());
......@@ -191,7 +212,7 @@ void ProcessorTrackerLandmarkApriltag::preProcess()
Eigen::Matrix6s info = computeInformation(translation, c_M_t.linear(), K_, tag_width, std_pix_); // Lie jacobians covariance
if (is_ambiguous){
WOLF_INFO("Ambiguity on estimated rotation is likely");
// WOLF_INFO("Ambiguity on estimated rotation is likely");
// Put a very high covariance on angles measurements (low info matrix ?)
// cov.bottomRightCorner(3, 3) = 1000000*Eigen::Matrix3s::Identity();
Eigen::Matrix6s new_info = 0.00001*Eigen::Matrix6s::Identity();
......@@ -207,7 +228,7 @@ void ProcessorTrackerLandmarkApriltag::preProcess()
// WOLF_TRACE("tag ", tag_id, " cov diagonal: [", cov.diagonal().transpose(), "]");
// add to detected features list
detections_incoming_.push_back(std::make_shared<FeatureApriltag>(pose, info, tag_id, *det, FeatureBase::UncertaintyType::UNCERTAINTY_IS_INFO));
WOLF_TRACE("Meas Covariance tag ", tag_id, "\n", info.inverse());
// WOLF_TRACE("Meas Covariance tag ", tag_id, "\n", info.inverse());
WOLF_TRACE("---------------------\n");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment