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

Fix for missing vsource params

parent 31260c79
No related branches found
No related tags found
1 merge request!109Resolves #173 remove voxel code
Pipeline #13761 passed
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <ftl/rgbd/streamer.hpp> #include <ftl/rgbd/streamer.hpp>
#include <ftl/slave.hpp> #include <ftl/slave.hpp>
#include <ftl/rgbd/group.hpp> #include <ftl/rgbd/group.hpp>
#include <ftl/threads.hpp>
#include "ilw.hpp" #include "ilw.hpp"
#include <ftl/render/splat_render.hpp> #include <ftl/render/splat_render.hpp>
...@@ -138,6 +139,8 @@ static void run(ftl::Configurable *root) { ...@@ -138,6 +139,8 @@ static void run(ftl::Configurable *root) {
// TODO: Release frameset here... // TODO: Release frameset here...
//cudaSafeCall(cudaStreamSynchronize(scene->getIntegrationStream())); //cudaSafeCall(cudaStreamSynchronize(scene->getIntegrationStream()));
UNIQUE_LOCK(scene_A.mtx, lk);
// Send all frames to GPU, block until done? // Send all frames to GPU, block until done?
scene_A.upload(Channel::Colour + Channel::Depth); // TODO: (Nick) Add scene stream. scene_A.upload(Channel::Colour + Channel::Depth); // TODO: (Nick) Add scene stream.
align->process(scene_A); align->process(scene_A);
......
...@@ -20,9 +20,10 @@ Splatter::~Splatter() { ...@@ -20,9 +20,10 @@ Splatter::~Splatter() {
} }
bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cudaStream_t stream) { bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cudaStream_t stream) {
SHARED_LOCK(scene_->mtx, lk);
if (!src->isReady()) return false; if (!src->isReady()) return false;
LOG(INFO) << "Render ready2"; if (scene_->frames.size() > 0) LOG(INFO) << "Render ready2 " << (unsigned int)scene_->frames[0].getChannels();
const auto &camera = src->parameters(); const auto &camera = src->parameters();
...@@ -82,16 +83,18 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda ...@@ -82,16 +83,18 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda
out.get<GpuMat>(Channel::Depth).setTo(cv::Scalar(1000.0f), cvstream); out.get<GpuMat>(Channel::Depth).setTo(cv::Scalar(1000.0f), cvstream);
out.get<GpuMat>(Channel::Colour).setTo(cv::Scalar(0,0,0), cvstream); out.get<GpuMat>(Channel::Colour).setTo(cv::Scalar(0,0,0), cvstream);
LOG(INFO) << "Render ready"; LOG(INFO) << "Render ready: " << camera.width << "," << camera.height;
// Render each camera into virtual view // Render each camera into virtual view
for (size_t i=0; i<scene_->frames.size(); ++i) { for (size_t i=0; i<scene_->frames.size(); ++i) {
auto &f = scene_->frames[i]; auto &f = scene_->frames[i];
auto *s = scene_->sources[i]; auto *s = scene_->sources[i];
if (!f.hasChannel(Channel::Depth) || f.isCPU(Channel::Depth)) { if (f.empty(Channel::Depth + Channel::Colour)) {
LOG(ERROR) << "Missing required Depth channel"; LOG(ERROR) << "Missing required channel";
return false; continue;
} else {
LOG(INFO) << "Channels found";
} }
// Needs to create points channel first? // Needs to create points channel first?
...@@ -123,6 +126,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda ...@@ -123,6 +126,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda
//ftl::cuda::mls_render_depth(depth1_, depth3_, params, scene_->cameraCount(), stream); //ftl::cuda::mls_render_depth(depth1_, depth3_, params, scene_->cameraCount(), stream);
if (src->getChannel() == Channel::Depth) { if (src->getChannel() == Channel::Depth) {
LOG(INFO) << "Rendering depth";
//ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream); //ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream);
if (value("splatting", false)) { if (value("splatting", false)) {
//ftl::cuda::splat_points(depth1_, colour1_, normal1_, depth2_, colour2_, params, stream); //ftl::cuda::splat_points(depth1_, colour1_, normal1_, depth2_, colour2_, params, stream);
...@@ -149,6 +153,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda ...@@ -149,6 +153,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda
// src->writeFrames(colour1_, depth2_, stream); // src->writeFrames(colour1_, depth2_, stream);
//} //}
} else if (src->getChannel() == Channel::Right) { } else if (src->getChannel() == Channel::Right) {
LOG(INFO) << "Rendering right";
// Adjust pose to right eye position // Adjust pose to right eye position
Eigen::Affine3f transform(Eigen::Translation3f(camera.baseline,0.0f,0.0f)); Eigen::Affine3f transform(Eigen::Translation3f(camera.baseline,0.0f,0.0f));
Eigen::Matrix4f matrix = src->getPose().cast<float>() * transform.matrix(); Eigen::Matrix4f matrix = src->getPose().cast<float>() * transform.matrix();
...@@ -160,13 +165,14 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda ...@@ -160,13 +165,14 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda
//src->writeFrames(ts, colour1_, colour2_, stream); //src->writeFrames(ts, colour1_, colour2_, stream);
//src->write(scene_.timestamp, output_, stream); //src->write(scene_.timestamp, output_, stream);
} else { } else {
LOG(INFO) << "No second rendering";
if (value("splatting", false)) { if (value("splatting", false)) {
//ftl::cuda::splat_points(depth1_, colour1_, normal1_, depth2_, colour2_, params, stream); //ftl::cuda::splat_points(depth1_, colour1_, normal1_, depth2_, colour2_, params, stream);
//src->writeFrames(ts, colour1_, depth2_, stream); //src->writeFrames(ts, colour1_, depth2_, stream);
//src->write(scene_.timestamp, out, stream); //src->write(scene_.timestamp, out, stream);
} else { } else {
//ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream); //ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream);
temp_.get<GpuMat>(Channel::Depth).convertTo(out.get<GpuMat>(Channel::Depth), CV_32F, 1.0f / 1000.0f, cvstream); //temp_.get<GpuMat>(Channel::Depth).convertTo(out.get<GpuMat>(Channel::Depth), CV_32F, 1.0f / 1000.0f, cvstream);
//src->writeFrames(ts, colour1_, depth2_, stream); //src->writeFrames(ts, colour1_, depth2_, stream);
//src->write(scene_.timestamp, output_, stream); //src->write(scene_.timestamp, output_, stream);
} }
......
...@@ -88,6 +88,13 @@ public: ...@@ -88,6 +88,13 @@ public:
*/ */
void reset(); void reset();
bool empty(ftl::rgbd::Channels c);
inline bool empty(ftl::rgbd::Channel c) {
auto &m = _get(c);
return !hasChannel(c) || (m.host.empty() && m.gpu.empty());
}
/** /**
* Is there valid data in channel (either host or gpu). * Is there valid data in channel (either host or gpu).
*/ */
...@@ -95,6 +102,8 @@ public: ...@@ -95,6 +102,8 @@ public:
return channels_.has(channel); return channels_.has(channel);
} }
inline ftl::rgbd::Channels getChannels() const { return channels_; }
/** /**
* Is the channel data currently located on GPU. This also returns false if * Is the channel data currently located on GPU. This also returns false if
* the channel does not exist. * the channel does not exist.
......
...@@ -39,24 +39,36 @@ void Frame::upload(Channels c, cv::cuda::Stream stream) { ...@@ -39,24 +39,36 @@ void Frame::upload(Channels c, cv::cuda::Stream stream) {
} }
} }
bool Frame::empty(ftl::rgbd::Channels channels) {
for (auto c : channels) {
LOG(INFO) << "Check empty for " << (int)c;
if (empty(c)) return true;
}
return false;
}
void Frame::swapTo(ftl::rgbd::Channels channels, Frame &f) { void Frame::swapTo(ftl::rgbd::Channels channels, Frame &f) {
f.reset();
// For all channels in this frame object // For all channels in this frame object
for (auto c : channels_) { for (auto c : channels_) {
// Should we swap this channel? // Should we swap this channel?
if (channels.has(c)) { if (channels.has(c)) {
// Does 'f' have this channel? // Does 'f' have this channel?
if (!f.hasChannel(c)) { //if (!f.hasChannel(c)) {
// No, so create it first // No, so create it first
// FIXME: Allocate the memory as well? // FIXME: Allocate the memory as well?
if (isCPU(c)) f.create<cv::Mat>(c); if (isCPU(c)) f.create<cv::Mat>(c);
else f.create<cv::cuda::GpuMat>(c); else f.create<cv::cuda::GpuMat>(c);
} //}
auto &m1 = _get(c); auto &m1 = _get(c);
auto &m2 = f._get(c); auto &m2 = f._get(c);
cv::swap(m1.host, m2.host); cv::swap(m1.host, m2.host);
cv::cuda::swap(m1.gpu, m2.gpu); cv::cuda::swap(m1.gpu, m2.gpu);
LOG(INFO) << "Swapping channel: " << static_cast<int>(c);
} }
} }
} }
......
...@@ -6,8 +6,8 @@ using ftl::rgbd::Channel; ...@@ -6,8 +6,8 @@ using ftl::rgbd::Channel;
class VirtualImpl : public ftl::rgbd::detail::Source { class VirtualImpl : public ftl::rgbd::detail::Source {
public: public:
explicit VirtualImpl(ftl::rgbd::Source *host) : ftl::rgbd::detail::Source(host) { explicit VirtualImpl(ftl::rgbd::Source *host, const ftl::rgbd::Camera &params) : ftl::rgbd::detail::Source(host) {
params_ = params;
} }
~VirtualImpl() { ~VirtualImpl() {
...@@ -52,7 +52,8 @@ class VirtualImpl : public ftl::rgbd::detail::Source { ...@@ -52,7 +52,8 @@ class VirtualImpl : public ftl::rgbd::detail::Source {
}; };
VirtualSource::VirtualSource(ftl::config::json_t &cfg) : Source(cfg) { VirtualSource::VirtualSource(ftl::config::json_t &cfg) : Source(cfg) {
impl_ = new VirtualImpl(this); auto params = params_;
impl_ = new VirtualImpl(this, params);
} }
VirtualSource::~VirtualSource() { VirtualSource::~VirtualSource() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment