Skip to content
Snippets Groups Projects
Commit aadee2a4 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Don't render plane when missing depth

parent 43dd85b9
No related branches found
No related tags found
1 merge request!338Resolves #375 full colour resolution
Pipeline #29336 failed
...@@ -250,6 +250,9 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre ...@@ -250,6 +250,9 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre
int valid_count = 0; int valid_count = 0;
// FIXME: Is it possible to remember previously if there should be depth?
bool use_depth = scene_->anyHasChannel(Channel::Depth) || scene_->anyHasChannel(Channel::GroundTruth);
// For each source depth map // For each source depth map
for (size_t i=0; i < scene_->frames.size(); ++i) { for (size_t i=0; i < scene_->frames.size(); ++i) {
//if (!scene_->hasFrame(i)) continue; //if (!scene_->hasFrame(i)) continue;
...@@ -261,6 +264,11 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre ...@@ -261,6 +264,11 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre
continue; continue;
} }
// We have the needed depth data?
if (use_depth && !f.hasOwn(Channel::Depth) && !f.hasOwn(Channel::GroundTruth)) {
continue;
}
++valid_count; ++valid_count;
//auto pose = MatrixConversion::toCUDA(t.cast<float>() * f.getPose().cast<float>()); //auto pose = MatrixConversion::toCUDA(t.cast<float>() * f.getPose().cast<float>());
...@@ -273,6 +281,7 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre ...@@ -273,6 +281,7 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre
auto &screenbuffer = _getScreenBuffer(bufsize); auto &screenbuffer = _getScreenBuffer(bufsize);
// Calculate and save virtual view screen position of each source pixel // Calculate and save virtual view screen position of each source pixel
if (use_depth) {
if (f.hasChannel(Channel::Depth)) { if (f.hasChannel(Channel::Depth)) {
ftl::cuda::screen_coord( ftl::cuda::screen_coord(
f.createTexture<float>(Channel::Depth), f.createTexture<float>(Channel::Depth),
...@@ -287,6 +296,7 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre ...@@ -287,6 +296,7 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre
screenbuffer, screenbuffer,
params_, transform, f.getLeftCamera(), stream params_, transform, f.getLeftCamera(), stream
); );
}
} else { } else {
// Constant depth version // Constant depth version
ftl::cuda::screen_coord( ftl::cuda::screen_coord(
......
...@@ -134,6 +134,8 @@ class FrameSet : public ftl::data::Frame { ...@@ -134,6 +134,8 @@ class FrameSet : public ftl::data::Frame {
*/ */
bool hasAnyChanged(ftl::codecs::Channel) const; bool hasAnyChanged(ftl::codecs::Channel) const;
bool anyHasChannel(ftl::codecs::Channel) const;
private: private:
std::atomic<int> flags_; std::atomic<int> flags_;
}; };
......
...@@ -78,6 +78,13 @@ bool ftl::data::FrameSet::hasAnyChanged(ftl::codecs::Channel c) const { ...@@ -78,6 +78,13 @@ bool ftl::data::FrameSet::hasAnyChanged(ftl::codecs::Channel c) const {
return false; return false;
} }
bool ftl::data::FrameSet::anyHasChannel(ftl::codecs::Channel c) const {
for (size_t i=0; i<frames.size(); ++i) {
if (frames[i].hasOwn(c)) return true;
}
return false;
}
void FrameSet::store() { void FrameSet::store() {
if (status() != ftl::data::FrameStatus::CREATED) throw FTL_Error("Cannot store frameset multiple times"); if (status() != ftl::data::FrameStatus::CREATED) throw FTL_Error("Cannot store frameset multiple times");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment