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

Code tidy again

parent 297f0c06
No related branches found
No related tags found
1 merge request!151Implements #216 triangle renderer
Pipeline #16017 passed
This commit is part of merge request !151. Comments created here will be created in the context of that merge request.
...@@ -10,12 +10,8 @@ namespace ftl { ...@@ -10,12 +10,8 @@ namespace ftl {
namespace render { namespace render {
/** /**
* Render the voxel hash structure by generating image points for surface * Generate triangles between connected points and render those. Colour is done
* voxels and expanding those into interpolated splats. This is a two pass * by weighted reprojection to the original source images.
* algorithm with the option of completing the second pass on a separate GPU.
* It also possible to only complete the first pass and perform the second step
* on a separate machine or at a later time, the advantage being to save local
* processing resources and that the first pass result may compress better.
*/ */
class Triangular : public ftl::render::Renderer { class Triangular : public ftl::render::Renderer {
public: public:
...@@ -30,15 +26,6 @@ class Triangular : public ftl::render::Renderer { ...@@ -30,15 +26,6 @@ class Triangular : public ftl::render::Renderer {
private: private:
int device_; int device_;
/*ftl::cuda::TextureObject<int> depth1_;
ftl::cuda::TextureObject<int> depth3_;
ftl::cuda::TextureObject<uchar4> colour1_;
ftl::cuda::TextureObject<float4> colour_tmp_;
ftl::cuda::TextureObject<float> depth2_;
ftl::cuda::TextureObject<uchar4> colour2_;
ftl::cuda::TextureObject<float4> normal1_;*/
//SplatParams params_;
ftl::rgbd::Frame temp_; ftl::rgbd::Frame temp_;
ftl::rgbd::Frame accum_; ftl::rgbd::Frame accum_;
ftl::rgbd::FrameSet *scene_; ftl::rgbd::FrameSet *scene_;
...@@ -47,7 +34,7 @@ class Triangular : public ftl::render::Renderer { ...@@ -47,7 +34,7 @@ class Triangular : public ftl::render::Renderer {
float norm_filter_; float norm_filter_;
bool backcull_; bool backcull_;
cv::Scalar background_; cv::Scalar background_;
bool splat_; bool mesh_;
float3 light_dir_; float3 light_dir_;
uchar4 light_diffuse_; uchar4 light_diffuse_;
uchar4 light_ambient_; uchar4 light_ambient_;
...@@ -55,10 +42,6 @@ class Triangular : public ftl::render::Renderer { ...@@ -55,10 +42,6 @@ class Triangular : public ftl::render::Renderer {
cudaStream_t stream_; cudaStream_t stream_;
float3 light_pos_; float3 light_pos_;
//template <typename T>
//void __blendChannel(ftl::rgbd::Frame &, ftl::codecs::Channel in, ftl::codecs::Channel out, cudaStream_t);
//void _blendChannel(ftl::rgbd::Frame &, ftl::codecs::Channel in, ftl::codecs::Channel out, cudaStream_t);
template <typename T> template <typename T>
void __reprojectChannel(ftl::rgbd::Frame &, ftl::codecs::Channel in, ftl::codecs::Channel out, cudaStream_t); void __reprojectChannel(ftl::rgbd::Frame &, ftl::codecs::Channel in, ftl::codecs::Channel out, cudaStream_t);
void _reprojectChannel(ftl::rgbd::Frame &, ftl::codecs::Channel in, ftl::codecs::Channel out, cudaStream_t); void _reprojectChannel(ftl::rgbd::Frame &, ftl::codecs::Channel in, ftl::codecs::Channel out, cudaStream_t);
......
...@@ -103,9 +103,9 @@ Triangular::Triangular(nlohmann::json &config, ftl::rgbd::FrameSet *fs) : ftl::r ...@@ -103,9 +103,9 @@ Triangular::Triangular(nlohmann::json &config, ftl::rgbd::FrameSet *fs) : ftl::r
backcull_ = value("back_cull", true); backcull_ = value("back_cull", true);
}); });
splat_ = value("splatting", true); mesh_ = value("meshing", true);
on("splatting", [this](const ftl::config::Event &e) { on("meshing", [this](const ftl::config::Event &e) {
splat_ = value("splatting", true); mesh_ = value("meshing", true);
}); });
background_ = parseCVColour(value("background", std::string("#4c4c4c"))); background_ = parseCVColour(value("background", std::string("#4c4c4c")));
...@@ -212,7 +212,7 @@ void Triangular::__reprojectChannel(ftl::rgbd::Frame &output, ftl::codecs::Chann ...@@ -212,7 +212,7 @@ void Triangular::__reprojectChannel(ftl::rgbd::Frame &output, ftl::codecs::Chann
auto poseInv = MatrixConversion::toCUDA(s->getPose().cast<float>().inverse()); auto poseInv = MatrixConversion::toCUDA(s->getPose().cast<float>().inverse());
if (splat_) { if (mesh_) {
ftl::cuda::reproject( ftl::cuda::reproject(
f.createTexture<T>(in), f.createTexture<T>(in),
f.createTexture<float>(Channel::Depth), // TODO: Use depth? f.createTexture<float>(Channel::Depth), // TODO: Use depth?
...@@ -472,43 +472,33 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) { ...@@ -472,43 +472,33 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) {
} }
// Create and render triangles for depth // Create and render triangles for depth
if (splat_) { if (mesh_) {
_mesh(stream_); _mesh(stream_);
} else { } else {
_dibr(stream_); _dibr(stream_);
} }
// Generate normals // Generate normals for final virtual image
ftl::cuda::normals(accum_.createTexture<float4>(Channel::Normals, Format<float4>(camera.width, camera.height)), ftl::cuda::normals(accum_.createTexture<float4>(Channel::Normals, Format<float4>(camera.width, camera.height)),
temp_.createTexture<float4>(Channel::Normals), temp_.createTexture<float4>(Channel::Normals),
temp_.getTexture<int>(Channel::Depth2), temp_.getTexture<int>(Channel::Depth2),
1, 0.02f, 1, 0.02f,
params_.camera, params_.m_viewMatrix.getFloat3x3(), params_.m_viewMatrixInverse.getFloat3x3(), stream_); params_.camera, params_.m_viewMatrix.getFloat3x3(), params_.m_viewMatrixInverse.getFloat3x3(), stream_);
// Reprojection of colours onto surface
_renderChannel(out, Channel::Colour, Channel::Colour, stream_); _renderChannel(out, Channel::Colour, Channel::Colour, stream_);
if (chan == Channel::Depth) if (chan == Channel::Depth)
{ {
//LOG(INFO) << "Copying depth"; // Just convert int depth to float depth
temp_.get<GpuMat>(Channel::Depth2).convertTo(out.get<GpuMat>(Channel::Depth), CV_32F, 1.0f / 1000.0f, cvstream); temp_.get<GpuMat>(Channel::Depth2).convertTo(out.get<GpuMat>(Channel::Depth), CV_32F, 1.0f / 1000.0f, cvstream);
//LOG(INFO) << "DEPTH COPIED";
} else if (chan == Channel::Normals) { } else if (chan == Channel::Normals) {
//out.create<GpuMat>(Channel::Normals, Format<uchar4>(camera.width, camera.height)); // Visualise normals to RGBA
// Render normal attribute
//_renderChannel(out, Channel::Normals, Channel::Normals, stream_);
// Convert normal to single float value
out.create<GpuMat>(Channel::Normals, Format<uchar4>(camera.width, camera.height)).setTo(cv::Scalar(0,0,0,0), cvstream); out.create<GpuMat>(Channel::Normals, Format<uchar4>(camera.width, camera.height)).setTo(cv::Scalar(0,0,0,0), cvstream);
ftl::cuda::normal_visualise(accum_.getTexture<float4>(Channel::Normals), out.createTexture<uchar4>(Channel::Normals), ftl::cuda::normal_visualise(accum_.getTexture<float4>(Channel::Normals), out.createTexture<uchar4>(Channel::Normals),
light_pos_, light_pos_,
light_diffuse_, light_diffuse_,
light_ambient_, stream_); light_ambient_, stream_);
// Put in output as single float
//cv::cuda::swap(temp_.get<GpuMat>(Channel::Colour), out.get<GpuMat>(Channel::Normals));
//out.resetTexture(Channel::Normals);
} }
//else if (chan == Channel::Contribution) //else if (chan == Channel::Contribution)
//{ //{
...@@ -556,7 +546,3 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) { ...@@ -556,7 +546,3 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) {
cudaSafeCall(cudaStreamSynchronize(stream_)); cudaSafeCall(cudaStreamSynchronize(stream_));
return true; return true;
} }
//void Triangular::setOutputDevice(int device) {
// device_ = device;
//}
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