| 165 | } |
| 166 | |
| 167 | void |
| 168 | compute(const pcl::PCLPointCloud2::ConstPtr& input, |
| 169 | pcl::PCLPointCloud2& output, |
| 170 | float th_dd, |
| 171 | int max_search) |
| 172 | { |
| 173 | CloudPtr cloud(new Cloud); |
| 174 | fromPCLPointCloud2(*input, *cloud); |
| 175 | |
| 176 | pcl::PointCloud<pcl::Normal>::Ptr normal(new pcl::PointCloud<pcl::Normal>); |
| 177 | pcl::IntegralImageNormalEstimation<PointXYZRGBA, pcl::Normal> ne; |
| 178 | ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX); |
| 179 | ne.setNormalSmoothingSize(10.0f); |
| 180 | ne.setBorderPolicy(ne.BORDER_POLICY_MIRROR); |
| 181 | ne.setInputCloud(cloud); |
| 182 | ne.compute(*normal); |
| 183 | |
| 184 | TicToc tt; |
| 185 | tt.tic(); |
| 186 | |
| 187 | // OrganizedEdgeBase<PointXYZRGBA, Label> oed; |
| 188 | // OrganizedEdgeFromRGB<PointXYZRGBA, Label> oed; |
| 189 | // OrganizedEdgeFromNormals<PointXYZRGBA, Normal, Label> oed; |
| 190 | OrganizedEdgeFromRGBNormals<PointXYZRGBA, Normal, Label> oed; |
| 191 | oed.setInputNormals(normal); |
| 192 | oed.setInputCloud(cloud); |
| 193 | oed.setDepthDisconThreshold(th_dd); |
| 194 | oed.setMaxSearchNeighbors(max_search); |
| 195 | oed.setEdgeType(oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING | |
| 196 | oed.EDGELABEL_OCCLUDED | oed.EDGELABEL_HIGH_CURVATURE | |
| 197 | oed.EDGELABEL_RGB_CANNY); |
| 198 | PointCloud<Label> labels; |
| 199 | std::vector<PointIndices> label_indices; |
| 200 | oed.compute(labels, label_indices); |
| 201 | print_info("Detecting all edges... [done, "); |
| 202 | print_value("%g", tt.toc()); |
| 203 | print_info(" ms]\n"); |
| 204 | |
| 205 | // Make gray point clouds |
| 206 | for (auto& point : cloud->points) { |
| 207 | std::uint8_t gray = std::uint8_t((point.r + point.g + point.b) / 3); |
| 208 | point.r = point.g = point.b = gray; |
| 209 | } |
| 210 | |
| 211 | // Display edges in PCLVisualizer |
| 212 | viewer.setSize(640, 480); |
| 213 | viewer.addCoordinateSystem(0.2f, "global"); |
| 214 | viewer.addPointCloud(cloud, "original point cloud"); |
| 215 | viewer.registerKeyboardCallback(&keyboard_callback); |
| 216 | |
| 217 | pcl::PointCloud<pcl::PointXYZRGBA>::Ptr occluding_edges( |
| 218 | new pcl::PointCloud<pcl::PointXYZRGBA>), |
| 219 | occluded_edges(new pcl::PointCloud<pcl::PointXYZRGBA>), |
| 220 | nan_boundary_edges(new pcl::PointCloud<pcl::PointXYZRGBA>), |
| 221 | high_curvature_edges(new pcl::PointCloud<pcl::PointXYZRGBA>), |
| 222 | rgb_edges(new pcl::PointCloud<pcl::PointXYZRGBA>); |
| 223 | |
| 224 | pcl::copyPointCloud(*cloud, label_indices[0].indices, *nan_boundary_edges); |
no test coverage detected