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

move fs

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