MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / TEST

Function TEST

test/gpu/octree/test_approx_nearest.cpp:23–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21#include <array> // for std::array
22
23TEST(PCL_OctreeGPU, approxNearesSearch)
24{
25
26 /*
27 the test points create an octree with bounds (-1, -1, -1) and (1, 1, 1).
28 point q, represents a query point
29 ------------------------------------
30 | | |
31 | | |
32 | | |
33 | | |
34 | | |
35 |----------------------------------|
36 | x | q | |
37 | | | |
38 |-------|--------| |
39 | | y | |
40 | | | |
41 ------------------------------------
42 the final two point are positioned such that point 'x' is farther from query point 'q'
43 than 'y', but the voxel containing 'x' is closer to 'q' than the voxel containing 'y'
44 */
45
46 const std::array<pcl::PointXYZ, 10> coords{
47 pcl::PointXYZ{-1.f, -1.f, -1.f},
48 pcl::PointXYZ{-1.f, -1.f, 1.f},
49 pcl::PointXYZ{-1.f, 1.f, -1.f},
50 pcl::PointXYZ{-1.f, 1.f, 1.f},
51 pcl::PointXYZ{1.f, -1.f, -1.f},
52 pcl::PointXYZ{1.f, -1.f, 1.f},
53 pcl::PointXYZ{1.f, 1.f, -1.f},
54 pcl::PointXYZ{1.f, 1.f, 1.f},
55 pcl::PointXYZ{-0.9f, -0.2f, -0.75f},
56 pcl::PointXYZ{-0.4f, -0.6f, -0.75f},
57 };
58
59 // While the GPU implementation has a fixed depth of 10 levels, octree depth in the
60 // CPU implementation can vary based on the leaf size set by the user, which can
61 // affect the results. Therefore results would only tally if depths match.
62 //generate custom pointcloud
63 constexpr pcl::index_t point_size = 1000 * coords.size();
64 auto cloud = pcl::make_shared<pcl::PointCloud<pcl::PointXYZ>>(point_size, 1);
65
66 // copy chunks of 10 points at the same time
67 for (auto it = cloud->begin(); it != cloud->cend(); it += coords.size())
68 std::copy(coords.cbegin(), coords.cend(), it);
69
70 const std::vector<pcl::PointXYZ> queries = {
71 {-0.4, -0.2, -0.75}, // should be different across CPU and GPU if different
72 // traversal methods are used
73 {-0.6, -0.2, -0.75}, // should be same across CPU and GPU
74 {1.1, 1.1, 1.1}, // out of range query
75 };
76
77 // prepare device cloud
78 pcl::gpu::Octree::PointCloud cloud_device;
79 cloud_device.upload(cloud->points);
80

Callers

nothing calls this directly

Calls 12

squaredEuclideanDistanceFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
cendMethod · 0.45
cbeginMethod · 0.45
uploadMethod · 0.45
setCloudMethod · 0.45
buildMethod · 0.45
setInputCloudMethod · 0.45
approxNearestSearchMethod · 0.45
downloadMethod · 0.45

Tested by

no test coverage detected