Merge branch 'demmeln/fix-hardcoded-aprilgrid-size' into 'master'

fix hardcoded aprilgrid size

See merge request VladyslavUsenko/basalt!6
This commit is contained in:
Vladyslav Usenko 2022-03-16 19:18:59 +00:00
commit 362df0c4e9
8 changed files with 21 additions and 9 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

@ -26,6 +26,8 @@ struct SmoothFunction {
BASALT_HOST_DEVICE inline bool InBounds( BASALT_HOST_DEVICE inline bool InBounds(
const Eigen::MatrixBase<Derived>& p, const Eigen::MatrixBase<Derived>& p,
const typename Derived::Scalar border) const { const typename Derived::Scalar border) const {
UNUSED(p);
UNUSED(border);
return true; return true;
} }
}; };

View File

@ -17,7 +17,7 @@ include_directories(../../include)
include_directories(../basalt-headers/include) include_directories(../basalt-headers/include)
include_directories(../basalt-headers/thirdparty/Sophus) include_directories(../basalt-headers/thirdparty/Sophus)
add_library(apriltag STATIC ${APRILTAG_SRCS} src/apriltag.cpp) add_library(apriltag STATIC ${APRILTAG_SRCS} include/basalt/utils/apriltag.h src/apriltag.cpp)
target_include_directories(apriltag PUBLIC include) target_include_directories(apriltag PUBLIC include)
target_link_libraries(apriltag PUBLIC basalt::opencv Sophus::Sophus) target_link_libraries(apriltag PUBLIC basalt::opencv Sophus::Sophus)

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; }