效果展示
原始点云
上采样后点
cloud | point_size |
---|---|
1 | 5323 |
2 | 42584 |
有上图可知,点云上采样效果还可以。
代码
#include <CGAL/Simple_cartesian.h>
#include <CGAL/edge_aware_upsample_point_set.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_points.h>
#include <vector>
#include <fstream>
#include <CGAL/draw_point_set_3.h>
// types
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef std::pair<Point, Vector> PointVectorPair;
typedef CGAL::Parallel_if_available_tag Concurrency_tag;
int main(int argc, char* argv[])
{
std::vector<PointVectorPair> points;
if (!CGAL::IO::read_points(argv[1],
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())))
{
return EXIT_FAILURE;
}
//参数设置
const double sharpness_angle = 25; // control sharpness of the result.
const double edge_sensitivity = 0; // higher values will sample more points near the edges
const double neighbor_radius = 0.25; // initial size of neighborhood.
const std::size_t number_of_output_points = points.size() * 8;
CGAL::edge_aware_upsample_point_set<Concurrency_tag>(
points,
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()).
normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()).
sharpness_angle(sharpness_angle).
edge_sensitivity(edge_sensitivity).
neighbor_radius(neighbor_radius).
number_of_output_points(number_of_output_points));
//保存点云
if (!CGAL::IO::write_points(argv[2], points,
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())
.normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())
.stream_precision(17)))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END