diff --git a/applications/aruco/src/main.cpp b/applications/aruco/src/main.cpp index 3c1daf03147dc7660239bff46eb5c2f26062e570..f53c454abefe0bc607575b18af19d46030d11611 100644 --- a/applications/aruco/src/main.cpp +++ b/applications/aruco/src/main.cpp @@ -12,9 +12,9 @@ int main(int argc, char** argv) { unsigned int ntags = 10; cv::Ptr<cv::aruco::Dictionary> dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); - unsigned int size = 1024; - unsigned int margin = 1; - unsigned int delay = 100; + unsigned int size = 512; + unsigned int margin = 64; + unsigned int delay = 50; argc--; argv++; @@ -28,18 +28,27 @@ int main(int argc, char** argv) { ntags = std::stoi(opts["ntags"]); if (opts.count("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++) { - 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; + bool show_blank = false; ftl::timer::setInterval(delay); ftl::timer::setHighPrecision(true); auto h = ftl::timer::add(ftl::timer::kTimerMain, [&](uint64_t){ - - cv::imshow("ArUco", tags[id]); + cv::imshow("ArUco", show_blank ? blank : tags[id]); if (cv::waitKey(1) == 27) { ftl::timer::stop(false); } + show_blank = !show_blank; id = (id + 1) % ntags; return true; }); diff --git a/applications/gui2/src/views/calibration/extrinsicview.cpp b/applications/gui2/src/views/calibration/extrinsicview.cpp index 00a3713a78ae541538146a9ac90b38a33af27025..0c703474eac7ec293a526c013459522cba33fba1 100644 --- a/applications/gui2/src/views/calibration/extrinsicview.cpp +++ b/applications/gui2/src/views/calibration/extrinsicview.cpp @@ -166,6 +166,7 @@ private: nanogui::Button* bsave_; nanogui::Button* bupload_; nanogui::Button* bapply_; + nanogui::Button* bfreeze_; nanogui::Button* bcalibrate_; nanogui::Button* bpause_; nanogui::Button* bresults_; @@ -208,13 +209,20 @@ ExtrinsicCalibrationView::ControlWindow::ControlWindow(nanogui::Widget* parent, bapply_ = new nanogui::Button(buttons, ""); bapply_->setFixedWidth(40); bapply_->setTooltip("Rectify stereo images"); - bapply_->setFlags(nanogui::Button::Flags::ToggleButton); bapply_->setPushed(view_->rectify()); bapply_->setChangeCallback([button = bapply_, view = view_](bool 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_->setEnabled(ctrl_->calib().calibrated()); bresults_->setCallback([view = view_, button = bresults_]{ @@ -244,6 +252,7 @@ void ExtrinsicCalibrationView::ControlWindow::draw(NVGcontext* ctx) { } bapply_->setIcon(view_->rectify() ? ENTYPO_ICON_EYE : ENTYPO_ICON_EYE_WITH_LINE); bapply_->setPushed(view_->rectify()); + bfreeze_->setIcon(view_->paused() ? ENTYPO_ICON_CONTROLLER_PLAY : ENTYPO_ICON_CONTROLLER_PAUS); //bcalibrate_->setEnabled(ctrl_->calib().nFrames() > 0); //bresults_->setEnabled(ctrl_->calib().calibrated()); FixedWindow::draw(ctx); @@ -454,7 +463,7 @@ ExtrinsicCalibrationView::ExtrinsicCalibrationView(Screen* widget, ExtrinsicCali for (int i = 0; i < ctrl_->cameraCount(); i += 2) { new StereoImageView(frames_, nanogui::Orientation::Vertical); } - + paused_ = false; wcontrol_ = new ControlWindow(screen(), this); wcalibration_ = new CalibrationWindow(screen(), this); wresults_ = new ResultsWindow(screen(), this); @@ -484,7 +493,7 @@ void ExtrinsicCalibrationView::performLayout(NVGcontext* ctx) { void ExtrinsicCalibrationView::draw(NVGcontext* ctx) { - if (ctrl_->next()) { + if (ctrl_->next() && !paused_) { for (int i = 0; i < ctrl_->cameraCount(); i += 2) { auto* imview = dynamic_cast<StereoImageView*>(frames_->childAt(i/2)); diff --git a/applications/gui2/src/views/calibration/extrinsicview.hpp b/applications/gui2/src/views/calibration/extrinsicview.hpp index 10066d9c7738755dd2fa6cb1a303277efe158daa..7e2b7b490c946a4945b199fb6532b0b4dfd650ab 100644 --- a/applications/gui2/src/views/calibration/extrinsicview.hpp +++ b/applications/gui2/src/views/calibration/extrinsicview.hpp @@ -69,6 +69,9 @@ public: void setRectify(bool v) { rectify_ = v; }; void setMode(Mode m); + bool paused() { return paused_; } + void pause(bool v) { paused_ = v; } + protected: int rows(); // calculate optimum number of rows; void setRows(int rows); @@ -84,7 +87,7 @@ private: int rows_; bool draw_number_; bool rectify_; - + bool paused_; public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW };