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
Loading
Pipeline #13761 passed
......@@ -14,6 +14,7 @@
#include <ftl/rgbd/streamer.hpp>
#include <ftl/slave.hpp>
#include <ftl/rgbd/group.hpp>
#include <ftl/threads.hpp>
#include "ilw.hpp"
#include <ftl/render/splat_render.hpp>
......@@ -138,6 +139,8 @@ static void run(ftl::Configurable *root) {
// TODO: Release frameset here...
//cudaSafeCall(cudaStreamSynchronize(scene->getIntegrationStream()));
UNIQUE_LOCK(scene_A.mtx, lk);
// Send all frames to GPU, block until done?
scene_A.upload(Channel::Colour + Channel::Depth); // TODO: (Nick) Add scene stream.
align->process(scene_A);
......
......@@ -20,9 +20,10 @@ Splatter::~Splatter() {
}
bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cudaStream_t stream) {
SHARED_LOCK(scene_->mtx, lk);
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();
......@@ -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::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
for (size_t i=0; i<scene_->frames.size(); ++i) {
auto &f = scene_->frames[i];
auto *s = scene_->sources[i];
if (!f.hasChannel(Channel::Depth) || f.isCPU(Channel::Depth)) {
LOG(ERROR) << "Missing required Depth channel";
return false;
if (f.empty(Channel::Depth + Channel::Colour)) {
LOG(ERROR) << "Missing required channel";
continue;
} else {
LOG(INFO) << "Channels found";
}
// Needs to create points channel first?
......@@ -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);
if (src->getChannel() == Channel::Depth) {
LOG(INFO) << "Rendering depth";
//ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream);
if (value("splatting", false)) {
//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
// src->writeFrames(colour1_, depth2_, stream);
//}
} else if (src->getChannel() == Channel::Right) {
LOG(INFO) << "Rendering right";
// Adjust pose to right eye position
Eigen::Affine3f transform(Eigen::Translation3f(camera.baseline,0.0f,0.0f));
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
//src->writeFrames(ts, colour1_, colour2_, stream);
//src->write(scene_.timestamp, output_, stream);
} else {
LOG(INFO) << "No second rendering";
if (value("splatting", false)) {
//ftl::cuda::splat_points(depth1_, colour1_, normal1_, depth2_, colour2_, params, stream);
//src->writeFrames(ts, colour1_, depth2_, stream);
//src->write(scene_.timestamp, out, stream);
} else {
//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->write(scene_.timestamp, output_, stream);
}
......
......@@ -88,6 +88,13 @@ public:
*/
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).
*/
......@@ -95,6 +102,8 @@ public:
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
* the channel does not exist.
......
......@@ -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) {
f.reset();
// For all channels in this frame object
for (auto c : channels_) {
// Should we swap this channel?
if (channels.has(c)) {
// Does 'f' have this channel?
if (!f.hasChannel(c)) {
//if (!f.hasChannel(c)) {
// No, so create it first
// FIXME: Allocate the memory as well?
if (isCPU(c)) f.create<cv::Mat>(c);
else f.create<cv::cuda::GpuMat>(c);
}
//}
auto &m1 = _get(c);
auto &m2 = f._get(c);
cv::swap(m1.host, m2.host);
cv::cuda::swap(m1.gpu, m2.gpu);
LOG(INFO) << "Swapping channel: " << static_cast<int>(c);
}
}
}
......
......@@ -6,8 +6,8 @@ using ftl::rgbd::Channel;
class VirtualImpl : public ftl::rgbd::detail::Source {
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() {
......@@ -52,7 +52,8 @@ class VirtualImpl : public ftl::rgbd::detail::Source {
};
VirtualSource::VirtualSource(ftl::config::json_t &cfg) : Source(cfg) {
impl_ = new VirtualImpl(this);
auto params = params_;
impl_ = new VirtualImpl(this, params);
}
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