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

add check

parent 721c6752
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28311 passed
......@@ -19,9 +19,10 @@ public:
void set(unsigned int flag) { flags_ |= flag; }
void unset(unsigned int flag) { flags_ &= ~flag; }
void reset() { flags_ = 0; }
std::string name(int) const;
int defaultFlags() const;
std::vector<int> list() const;
std::string name(int) const;
std::string explain(int) const;
operator int() { return flags_; }
......@@ -36,8 +37,6 @@ public:
std::string explain(int) const;
};
/**
* Calibration. Loads Intrinsic and Extrinsic calibration modules and
* adds buttons to main screen.
......@@ -313,6 +312,8 @@ private:
std::future<void> future_;
std::mutex mtx_;
ftl::data::FrameSetPtr fs_current_;
ftl::data::FrameSetPtr fs_update_;
struct State {
cv::Mat gray_left;
......@@ -328,10 +329,9 @@ private:
float last = 0.0f;
float frequency = 0.5f;
int count = 0;
float reprojection_error = NAN;
OpenCVCalibrateFlagsStereo flags;
ftl::data::FrameSetPtr fs_current;
ftl::data::FrameSetPtr fs_updated;
ftl::data::FrameSetPtr fs_previous_points;
std::vector<std::vector<cv::Point2f>> points_l;
std::vector<std::vector<cv::Point2f>> points_r;
......
......@@ -135,6 +135,7 @@ bool StereoCalibration::onFrame_(const ftl::data::FrameSetPtr& fs) {
auto& frame = fs->frames[state_->id.source()];
if (!checkFrame(frame)) { return true; }
if (!frame.hasAll({channelLeft_(), channelRight_()})) { return true; }
if (!state_->capture) { return true; }
if ((float(glfwGetTime()) - state_->last) < state_->frequency) { return true; }
if (state_->running.exchange(true)) { return true; }
......@@ -143,8 +144,10 @@ bool StereoCalibration::onFrame_(const ftl::data::FrameSetPtr& fs) {
try {
auto& frame = (*fs)[state_->id.source()].cast<ftl::rgbd::Frame>();
cv::cvtColor(getMat(frame, channelLeft_()), state_->gray_left, cv::COLOR_BGRA2GRAY);
cv::cvtColor(getMat(frame, channelRight_()), state_->gray_right, cv::COLOR_BGRA2GRAY);
auto l = getMat(frame, channelLeft_());
auto r = getMat(frame, channelRight_());
cv::cvtColor(l, state_->gray_left, cv::COLOR_BGRA2GRAY);
cv::cvtColor(r, state_->gray_right, cv::COLOR_BGRA2GRAY);
std::vector<cv::Point2d> pointsl;
std::vector<cv::Point2d> pointsr;
......@@ -203,8 +206,10 @@ bool StereoCalibration::isBusy() {
}
void StereoCalibration::run() {
if (state_->running) { return; }
state_->running = true;
future_ = ftl::pool.push([this](int id) {
future_ = ftl::pool.push([this](int) {
try {
auto& calib_l = state_->calib.get(Channel::Left);
auto& calib_r = state_->calib.get(Channel::Right);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment