calibration: fix hardcoded number of tags -> use value from config

This commit is contained in:
Nikolaus Demmel 2022-03-16 19:09:03 +01:00
parent b8b47d12c4
commit 759de6dc91
6 changed files with 18 additions and 8 deletions

View File

@ -78,6 +78,7 @@ using CalibInitPoseMap =
class CalibHelper { class CalibHelper {
public: public:
static void detectCorners(const VioDatasetPtr& vio_data, static void detectCorners(const VioDatasetPtr& vio_data,
const AprilGrid& april_grid,
CalibCornerMap& calib_corners, CalibCornerMap& calib_corners,
CalibCornerMap& calib_corners_rejected); CalibCornerMap& calib_corners_rejected);

View File

@ -106,6 +106,7 @@ bool estimateTransformation(
} }
void CalibHelper::detectCorners(const VioDatasetPtr &vio_data, void CalibHelper::detectCorners(const VioDatasetPtr &vio_data,
const AprilGrid &april_grid,
CalibCornerMap &calib_corners, CalibCornerMap &calib_corners,
CalibCornerMap &calib_corners_rejected) { CalibCornerMap &calib_corners_rejected) {
calib_corners.clear(); calib_corners.clear();
@ -114,7 +115,8 @@ void CalibHelper::detectCorners(const VioDatasetPtr &vio_data,
tbb::parallel_for( tbb::parallel_for(
tbb::blocked_range<size_t>(0, vio_data->get_image_timestamps().size()), tbb::blocked_range<size_t>(0, vio_data->get_image_timestamps().size()),
[&](const tbb::blocked_range<size_t> &r) { [&](const tbb::blocked_range<size_t> &r) {
ApriltagDetector ad; const int numTags = april_grid.getTagCols() * april_grid.getTagRows();
ApriltagDetector ad(numTags);
for (size_t j = r.begin(); j != r.end(); ++j) { for (size_t j = r.begin(); j != r.end(); ++j) {
int64_t timestamp_ns = vio_data->get_image_timestamps()[j]; int64_t timestamp_ns = vio_data->get_image_timestamps()[j];

View File

@ -415,7 +415,8 @@ void CamCalib::detectCorners() {
processing_thread.reset(new std::thread([this]() { processing_thread.reset(new std::thread([this]() {
std::cout << "Started detecting corners" << std::endl; std::cout << "Started detecting corners" << std::endl;
CalibHelper::detectCorners(this->vio_dataset, this->calib_corners, CalibHelper::detectCorners(this->vio_dataset, this->april_grid,
this->calib_corners,
this->calib_corners_rejected); this->calib_corners_rejected);
std::string path = std::string path =

View File

@ -241,7 +241,8 @@ void CamImuCalib::detectCorners() {
processing_thread.reset(new std::thread([this]() { processing_thread.reset(new std::thread([this]() {
std::cout << "Started detecting corners" << std::endl; std::cout << "Started detecting corners" << std::endl;
CalibHelper::detectCorners(this->vio_dataset, this->calib_corners, CalibHelper::detectCorners(this->vio_dataset, this->april_grid,
this->calib_corners,
this->calib_corners_rejected); this->calib_corners_rejected);
std::string path = std::string path =

View File

@ -9,7 +9,7 @@ struct ApriltagDetectorData;
class ApriltagDetector { class ApriltagDetector {
public: public:
ApriltagDetector(); ApriltagDetector(int numTags);
~ApriltagDetector(); ~ApriltagDetector();

View File

@ -8,13 +8,14 @@
namespace basalt { namespace basalt {
struct ApriltagDetectorData { struct ApriltagDetectorData {
ApriltagDetectorData() ApriltagDetectorData(int numTags)
: doSubpixRefinement(true), : doSubpixRefinement(true),
maxSubpixDisplacement(0), maxSubpixDisplacement(0),
minTagsForValidObs(4), minTagsForValidObs(4),
minBorderDistance(4.0), minBorderDistance(4.0),
blackTagBorder(2), blackTagBorder(2),
_tagCodes(AprilTags::tagCodes36h11) { _tagCodes(AprilTags::tagCodes36h11),
_numTags(numTags) {
_tagDetector = _tagDetector =
std::make_shared<AprilTags::TagDetector>(_tagCodes, blackTagBorder); std::make_shared<AprilTags::TagDetector>(_tagCodes, blackTagBorder);
} }
@ -30,10 +31,14 @@ struct ApriltagDetectorData {
AprilTags::TagCodes _tagCodes; AprilTags::TagCodes _tagCodes;
std::shared_ptr<AprilTags::TagDetector> _tagDetector; std::shared_ptr<AprilTags::TagDetector> _tagDetector;
inline int size() { return 36 * 4; } int _numTags; //!< number of tags in the grid (determines the valid ids)
inline int size() { return _numTags * 4; }
}; };
ApriltagDetector::ApriltagDetector() { data = new ApriltagDetectorData; } ApriltagDetector::ApriltagDetector(int numTags) {
data = new ApriltagDetectorData(numTags);
}
ApriltagDetector::~ApriltagDetector() { delete data; } ApriltagDetector::~ApriltagDetector() { delete data; }