Skip to content
Snippets Groups Projects
Commit dd452096 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

aruco app

parent 2b3b4893
Branches
Tags
No related merge requests found
...@@ -12,9 +12,9 @@ int main(int argc, char** argv) { ...@@ -12,9 +12,9 @@ int main(int argc, char** argv) {
unsigned int ntags = 10; unsigned int ntags = 10;
cv::Ptr<cv::aruco::Dictionary> dict = cv::Ptr<cv::aruco::Dictionary> dict =
cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
unsigned int size = 1024; unsigned int size = 512;
unsigned int margin = 1; unsigned int margin = 64;
unsigned int delay = 100; unsigned int delay = 50;
argc--; argc--;
argv++; argv++;
...@@ -28,18 +28,27 @@ int main(int argc, char** argv) { ...@@ -28,18 +28,27 @@ int main(int argc, char** argv) {
ntags = std::stoi(opts["ntags"]); ntags = std::stoi(opts["ntags"]);
if (opts.count("size")) if (opts.count("size"))
size = std::stoi(opts["size"]); size = std::stoi(opts["size"]);
if (opts.count("margin"))
margin = std::stoi(opts["margin"]);
cv::Mat blank = cv::Mat(size + margin*2, size + margin*2, CV_8UC1);
blank.setTo(255);
for (unsigned int i = 0; i < ntags; i++) { for (unsigned int i = 0; i < ntags; i++) {
cv::aruco::drawMarker(dict, i, size, tags.emplace_back(), margin); auto& tag = tags.emplace_back();
tag.create(size + margin*2, size + margin*2, CV_8UC1);
tag.setTo(255);
cv::aruco::drawMarker(dict, i, size, tag(cv::Rect(margin, margin, size, size)), 1);
} }
int id = 0; int id = 0;
bool show_blank = false;
ftl::timer::setInterval(delay); ftl::timer::setInterval(delay);
ftl::timer::setHighPrecision(true); ftl::timer::setHighPrecision(true);
auto h = ftl::timer::add(ftl::timer::kTimerMain, [&](uint64_t){ auto h = ftl::timer::add(ftl::timer::kTimerMain, [&](uint64_t){
cv::imshow("ArUco", show_blank ? blank : tags[id]);
cv::imshow("ArUco", tags[id]);
if (cv::waitKey(1) == 27) { ftl::timer::stop(false); } if (cv::waitKey(1) == 27) { ftl::timer::stop(false); }
show_blank = !show_blank;
id = (id + 1) % ntags; id = (id + 1) % ntags;
return true; return true;
}); });
......
...@@ -166,6 +166,7 @@ private: ...@@ -166,6 +166,7 @@ private:
nanogui::Button* bsave_; nanogui::Button* bsave_;
nanogui::Button* bupload_; nanogui::Button* bupload_;
nanogui::Button* bapply_; nanogui::Button* bapply_;
nanogui::Button* bfreeze_;
nanogui::Button* bcalibrate_; nanogui::Button* bcalibrate_;
nanogui::Button* bpause_; nanogui::Button* bpause_;
nanogui::Button* bresults_; nanogui::Button* bresults_;
...@@ -208,13 +209,20 @@ ExtrinsicCalibrationView::ControlWindow::ControlWindow(nanogui::Widget* parent, ...@@ -208,13 +209,20 @@ ExtrinsicCalibrationView::ControlWindow::ControlWindow(nanogui::Widget* parent,
bapply_ = new nanogui::Button(buttons, ""); bapply_ = new nanogui::Button(buttons, "");
bapply_->setFixedWidth(40); bapply_->setFixedWidth(40);
bapply_->setTooltip("Rectify stereo images"); bapply_->setTooltip("Rectify stereo images");
bapply_->setFlags(nanogui::Button::Flags::ToggleButton); bapply_->setFlags(nanogui::Button::Flags::ToggleButton);
bapply_->setPushed(view_->rectify()); bapply_->setPushed(view_->rectify());
bapply_->setChangeCallback([button = bapply_, view = view_](bool v){ bapply_->setChangeCallback([button = bapply_, view = view_](bool v){
view->setRectify(v); view->setRectify(v);
}); });
bfreeze_ = new nanogui::Button(buttons, "", ENTYPO_ICON_CONTROLLER_PLAY);
bfreeze_->setFixedWidth(40);
bfreeze_->setTooltip("Freeze view");
bfreeze_->setCallback([button=bapply_, view=view_, ctrl=ctrl_](){
ctrl->setCapture(view->paused());
view->pause(!view->paused());
});
bresults_ = new nanogui::Button(buttons, "Show Calibration"); bresults_ = new nanogui::Button(buttons, "Show Calibration");
//bresults_->setEnabled(ctrl_->calib().calibrated()); //bresults_->setEnabled(ctrl_->calib().calibrated());
bresults_->setCallback([view = view_, button = bresults_]{ bresults_->setCallback([view = view_, button = bresults_]{
...@@ -244,6 +252,7 @@ void ExtrinsicCalibrationView::ControlWindow::draw(NVGcontext* ctx) { ...@@ -244,6 +252,7 @@ void ExtrinsicCalibrationView::ControlWindow::draw(NVGcontext* ctx) {
} }
bapply_->setIcon(view_->rectify() ? ENTYPO_ICON_EYE : ENTYPO_ICON_EYE_WITH_LINE); bapply_->setIcon(view_->rectify() ? ENTYPO_ICON_EYE : ENTYPO_ICON_EYE_WITH_LINE);
bapply_->setPushed(view_->rectify()); bapply_->setPushed(view_->rectify());
bfreeze_->setIcon(view_->paused() ? ENTYPO_ICON_CONTROLLER_PLAY : ENTYPO_ICON_CONTROLLER_PAUS);
//bcalibrate_->setEnabled(ctrl_->calib().nFrames() > 0); //bcalibrate_->setEnabled(ctrl_->calib().nFrames() > 0);
//bresults_->setEnabled(ctrl_->calib().calibrated()); //bresults_->setEnabled(ctrl_->calib().calibrated());
FixedWindow::draw(ctx); FixedWindow::draw(ctx);
...@@ -454,7 +463,7 @@ ExtrinsicCalibrationView::ExtrinsicCalibrationView(Screen* widget, ExtrinsicCali ...@@ -454,7 +463,7 @@ ExtrinsicCalibrationView::ExtrinsicCalibrationView(Screen* widget, ExtrinsicCali
for (int i = 0; i < ctrl_->cameraCount(); i += 2) { for (int i = 0; i < ctrl_->cameraCount(); i += 2) {
new StereoImageView(frames_, nanogui::Orientation::Vertical); new StereoImageView(frames_, nanogui::Orientation::Vertical);
} }
paused_ = false;
wcontrol_ = new ControlWindow(screen(), this); wcontrol_ = new ControlWindow(screen(), this);
wcalibration_ = new CalibrationWindow(screen(), this); wcalibration_ = new CalibrationWindow(screen(), this);
wresults_ = new ResultsWindow(screen(), this); wresults_ = new ResultsWindow(screen(), this);
...@@ -484,7 +493,7 @@ void ExtrinsicCalibrationView::performLayout(NVGcontext* ctx) { ...@@ -484,7 +493,7 @@ void ExtrinsicCalibrationView::performLayout(NVGcontext* ctx) {
void ExtrinsicCalibrationView::draw(NVGcontext* ctx) { void ExtrinsicCalibrationView::draw(NVGcontext* ctx) {
if (ctrl_->next()) { if (ctrl_->next() && !paused_) {
for (int i = 0; i < ctrl_->cameraCount(); i += 2) { for (int i = 0; i < ctrl_->cameraCount(); i += 2) {
auto* imview = dynamic_cast<StereoImageView*>(frames_->childAt(i/2)); auto* imview = dynamic_cast<StereoImageView*>(frames_->childAt(i/2));
......
...@@ -69,6 +69,9 @@ public: ...@@ -69,6 +69,9 @@ public:
void setRectify(bool v) { rectify_ = v; }; void setRectify(bool v) { rectify_ = v; };
void setMode(Mode m); void setMode(Mode m);
bool paused() { return paused_; }
void pause(bool v) { paused_ = v; }
protected: protected:
int rows(); // calculate optimum number of rows; int rows(); // calculate optimum number of rows;
void setRows(int rows); void setRows(int rows);
...@@ -84,7 +87,7 @@ private: ...@@ -84,7 +87,7 @@ private:
int rows_; int rows_;
bool draw_number_; bool draw_number_;
bool rectify_; bool rectify_;
bool paused_;
public: public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment