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

move fs

parent 3ea3dcd5
Branches
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28309 failed
......@@ -52,6 +52,8 @@ StereoCalibration::~StereoCalibration() {
if(future_.valid()) {
future_.wait();
}
fs_current_.reset();
fs_update_.reset();
}
void StereoCalibration::reset() {
......@@ -89,12 +91,12 @@ void StereoCalibration::start(ftl::data::FrameID id) {
view->onClose([filter, this](){
// if state_->calib caches images, also reset() here!
filter->remove();
if (state_->fs_current) {
setCalibrationMode(state_->fs_current->frames[state_->id.source()], true);
if (fs_current_) {
setCalibrationMode(fs_current_->frames[state_->id.source()], true);
}
reset();
state_->fs_current.reset();
state_->fs_updated.reset();
fs_current_.reset();
fs_update_.reset();
});
screen->setView(view);
......@@ -127,7 +129,7 @@ void StereoCalibration::start(ftl::data::FrameID id) {
bool StereoCalibration::onFrame_(const ftl::data::FrameSetPtr& fs) {
std::atomic_store(&state_->fs_updated, fs);
std::atomic_store(&fs_update_, fs);
screen->redraw();
auto& frame = fs->frames[state_->id.source()];
......@@ -211,10 +213,10 @@ void StereoCalibration::run() {
auto K2 = calib_l.intrinsic.matrix();
auto distCoeffs2 = calib_r.intrinsic.distCoeffs.Mat();
cv::Mat R, T, E, F;
int flags = 0;
cv::stereoCalibrate(state_->points_object, state_->points_l,
state_->reprojection_error = cv::stereoCalibrate(
state_->points_object, state_->points_l,
state_->points_r, K1, distCoeffs1, K2, distCoeffs2,
state_->imsize, R, T, E, F, flags);
state_->imsize, R, T, E, F, state_->flags);
state_->calib.get(Channel::Left).intrinsic =
CalibrationData::Intrinsic(K1, distCoeffs1, state_->imsize);
......@@ -222,7 +224,7 @@ void StereoCalibration::run() {
CalibrationData::Intrinsic(K2, distCoeffs2, state_->imsize);
state_->calib.get(Channel::Right).extrinsic = CalibrationData::Extrinsic(R, T);
auto fs = std::atomic_load(&(state_->fs_current));
auto fs = std::atomic_load(&(fs_current_));
setCalibration((*fs)[state_->id.source()], state_->calib);
}
catch (std::exception &e) {
......@@ -238,8 +240,8 @@ void StereoCalibration::run() {
bool StereoCalibration::hasFrame() {
auto cleft = state_->highres ? Channel::LeftHighRes : Channel::Left;
auto cright = state_->highres ? Channel::RightHighRes : Channel::Right;
return (std::atomic_load(&state_->fs_updated).get() != nullptr)
&& state_->fs_updated->frames[state_->id.source()].hasAll({cleft, cright});
return (std::atomic_load(&fs_update_).get() != nullptr)
&& fs_update_->frames[state_->id.source()].hasAll({cleft, cright});
};
Channel StereoCalibration::channelLeft_() {
......@@ -251,20 +253,20 @@ Channel StereoCalibration::channelRight_() {
}
cv::cuda::GpuMat StereoCalibration::getLeft() {
if (std::atomic_load(&state_->fs_updated)) {
state_->fs_current = state_->fs_updated;
std::atomic_store(&state_->fs_updated, {});
if (std::atomic_load(&fs_update_)) {
fs_current_ = fs_update_;
std::atomic_store(&fs_update_, {});
}
auto& frame = (*state_->fs_current)[state_->id.source()].cast<ftl::rgbd::Frame>();
auto& frame = (*fs_current_)[state_->id.source()].cast<ftl::rgbd::Frame>();
return getGpuMat(frame ,channelLeft_());
}
cv::cuda::GpuMat StereoCalibration::getRight() {
if (std::atomic_load(&state_->fs_updated)) {
state_->fs_current = state_->fs_updated;
std::atomic_store(&state_->fs_updated, {});
if (std::atomic_load(&fs_update_)) {
fs_current_ = fs_update_;
std::atomic_store(&fs_update_, {});
}
auto& frame = (*state_->fs_current)[state_->id.source()].cast<ftl::rgbd::Frame>();
auto& frame = (*fs_current_)[state_->id.source()].cast<ftl::rgbd::Frame>();
return getGpuMat(frame ,channelRight_());
}
......@@ -276,8 +278,8 @@ cv::cuda::GpuMat StereoCalibration::getRightRectify() {
}
bool StereoCalibration::hasChannel(Channel c) {
if (state_->fs_current) {
return (*state_->fs_current)[state_->id.source()].hasChannel(c);
if (fs_current_) {
return (*fs_current_)[state_->id.source()].hasChannel(c);
}
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment