-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
189 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <pdal/Log.hpp> | ||
#include <pdal/PointBuffer.hpp> | ||
|
||
namespace pdal | ||
{ | ||
namespace pclsupport | ||
{ | ||
|
||
class Pipeline | ||
{ | ||
public: | ||
Pipeline(pdal::PointBuffer& input, std::string const json, bool isFilename, pdal::LogPtr log); | ||
~Pipeline(); | ||
void filter(pdal::PointBuffer& output); | ||
|
||
private: | ||
class PipelineImpl; | ||
std::unique_ptr<PipelineImpl> m_pipeline_pimpl; | ||
}; | ||
|
||
} //namespace pclsupport | ||
} //namespace pdal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#include <pdal/pclsupport/pipeline_impl.h> | ||
|
||
#include <pdal/Bounds.hpp> | ||
#include <pdal/Log.hpp> | ||
#include <pdal/PointBuffer.hpp> | ||
|
||
#ifdef PDAL_HAVE_PCL | ||
#ifdef PDAL_COMPILER_CLANG | ||
# pragma clang diagnostic push | ||
# pragma clang diagnostic ignored "-Wfloat-equal" | ||
#endif | ||
#include <pdal/pclsupport/PCLConversions.hpp> | ||
#include <pdal/pclsupport/impl/PCLPipeline.hpp> | ||
#include <pcl/console/print.h> | ||
#include <pcl/point_types.h> | ||
#include <pcl/io/pcd_io.h> | ||
#ifdef PDAL_COMPILER_CLANG | ||
# pragma clang diagnostic pop | ||
#endif | ||
#endif | ||
|
||
namespace pdal | ||
{ | ||
namespace pclsupport | ||
{ | ||
|
||
class Pipeline::PipelineImpl | ||
{ | ||
public: | ||
PipelineImpl(pdal::PointBuffer& input, std::string const json, bool isFilename, pdal::LogPtr log) : m_input(input), m_json(json), m_isFilename(isFilename), m_log(log) {} | ||
|
||
void filter(pdal::PointBuffer& output) | ||
{ | ||
#ifdef PDAL_HAVE_PCL | ||
bool logOutput = m_log->getLevel() > LogLevel::Debug1; | ||
if (logOutput) | ||
m_log->floatPrecision(8); | ||
|
||
//m_log->get(LogLevel::Debug2) << m_input.getFieldAs<double>(Dimension::Id::X, 0) << ", " << | ||
// m_input.getFieldAs<double>(Dimension::Id::Y, 0) << ", " << | ||
// m_input.getFieldAs<double>(Dimension::Id::Z, 0) << std::endl; | ||
m_log->get(LogLevel::Debug2) << "Process PCLBlock..." << std::endl; | ||
|
||
BOX3D const& buffer_bounds = m_input.calculateBounds(); | ||
|
||
// convert PointBuffer to PointNormal | ||
typedef pcl::PointCloud<pcl::PointNormal> Cloud; | ||
Cloud::Ptr cloud(new Cloud); | ||
pclsupport::PDALtoPCD(m_input, *cloud, buffer_bounds); | ||
|
||
//m_log->get(LogLevel::Debug2) << cloud->points[0].x << ", " << | ||
// cloud->points[0].y << ", " << cloud->points[0].z << std::endl; | ||
|
||
int level = m_log->getLevel(); | ||
switch (level) | ||
{ | ||
case 0: | ||
pcl::console::setVerbosityLevel(pcl::console::L_ALWAYS); | ||
break; | ||
case 1: | ||
pcl::console::setVerbosityLevel(pcl::console::L_ERROR); | ||
break; | ||
case 2: | ||
pcl::console::setVerbosityLevel(pcl::console::L_WARN); | ||
break; | ||
case 3: | ||
pcl::console::setVerbosityLevel(pcl::console::L_INFO); | ||
break; | ||
case 4: | ||
pcl::console::setVerbosityLevel(pcl::console::L_DEBUG); | ||
break; | ||
default: | ||
pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE); | ||
break; | ||
} | ||
|
||
pcl::Pipeline<pcl::PointNormal> pipeline; | ||
pipeline.setInputCloud(cloud); | ||
if (m_isFilename) | ||
pipeline.setFilename(m_json); | ||
else | ||
pipeline.setJSON(m_json); | ||
// PDALtoPCD subtracts min values in each XYZ dimension to prevent rounding | ||
// errors in conversion to float. These offsets need to be conveyed to the | ||
// pipeline to offset any bounds entered as part of a PassThrough filter. | ||
pipeline.setOffsets(buffer_bounds.minx, buffer_bounds.miny, buffer_bounds.minz); | ||
|
||
// create PointCloud for results | ||
Cloud::Ptr cloud_f(new Cloud); | ||
pipeline.filter(*cloud_f); | ||
|
||
if (cloud_f->points.empty()) | ||
{ | ||
m_log->get(LogLevel::Debug2) << "Filtered cloud has no points!" << std::endl; | ||
return; | ||
} | ||
|
||
pclsupport::PCDtoPDAL(*cloud_f, output, buffer_bounds); | ||
|
||
m_log->get(LogLevel::Debug2) << cloud->points.size() << " before, " << | ||
cloud_f->points.size() << " after" << std::endl; | ||
//m_log->get(LogLevel::Debug2) << output.size() << std::endl; | ||
//m_log->get(LogLevel::Debug2) << output.getFieldAs<double>(Dimension::Id::X, 0) << ", " << | ||
// output.getFieldAs<double>(Dimension::Id::Y, 0) << ", " << | ||
// output.getFieldAs<double>(Dimension::Id::Z, 0) << std::endl; | ||
#endif | ||
|
||
/* | ||
#ifdef PDAL_HAVE_PCL | ||
pdal::BOX3D const& buffer_bounds = m_input.calculateBounds(); | ||
// create PCL cloud objects | ||
typedef pcl::PointCloud<pcl::PointNormal> Cloud; | ||
Cloud::Ptr cloud(new Cloud); | ||
Cloud::Ptr cloud_f(new Cloud); | ||
// convert PointBuffer to PointCloud | ||
pdal::pclsupport::PDALtoPCD(m_input, *cloud, buffer_bounds); | ||
// apply the voxel grid | ||
pcl::Pipeline<pcl::PointNormal> vg; | ||
vg.setInputCloud(cloud); | ||
vg.setLeafSize(m_leaf_size,m_leaf_size,m_leaf_size); | ||
vg.filter(*cloud_f); | ||
// and convert PointCloud back to PointBuffer | ||
pdal::pclsupport::PCDtoPDAL(*cloud_f, output, buffer_bounds); | ||
#else | ||
throw pdal_error("Pipeline requested without PCL support"); | ||
#endif | ||
*/ | ||
} | ||
|
||
private: | ||
pdal::PointBuffer& m_input; | ||
std::string m_json; | ||
bool m_isFilename; | ||
pdal::LogPtr m_log; | ||
}; | ||
|
||
Pipeline::Pipeline(pdal::PointBuffer& input, std::string const json, bool isFilename, pdal::LogPtr log) : m_pipeline_pimpl(new PipelineImpl(input, json, isFilename, log)) {} | ||
|
||
Pipeline::~Pipeline() {} | ||
|
||
void Pipeline::filter(pdal::PointBuffer& output) | ||
{ | ||
m_pipeline_pimpl->filter(output); | ||
} | ||
|
||
} //namespace pclsupport | ||
} //namespace pdal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters