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

Function run

tools/obj_rec_ransac_accepted_hypotheses.cpp:404–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402//===============================================================================================================================
403
404void
405run (float pair_width, float voxel_size, float max_coplanarity_angle, int num_hypotheses_to_show)
406{
407 PointCloud<PointXYZ>::Ptr scene_points (new PointCloud<PointXYZ> ()), model_points (new PointCloud<PointXYZ> ());
408 PointCloud<Normal>::Ptr scene_normals (new PointCloud<Normal> ()), model_normals (new PointCloud<Normal> ());
409
410 // Get the points and normals from the scene
411 if ( !vtk_to_pointcloud ("../../test/tum_table_scene.vtk", *scene_points, *scene_normals) )
412 return;
413
414 vtkPolyData *vtk_model = vtkPolyData::New ();
415 // Get the points and normals from the scene
416 if ( !vtk_to_pointcloud ("../../test/tum_amicelli_box.vtk", *model_points, *model_normals, vtk_model) )
417 return;
418
419 // The recognition object
420 ObjRecRANSAC objrec (pair_width, voxel_size);
421 objrec.setMaxCoplanarityAngleDegrees (max_coplanarity_angle);
422 objrec.addModel (*model_points, *model_normals, "amicelli", vtk_model);
423 // Switch to the test mode in which only oriented point pairs from the scene are sampled
424 objrec.enterTestModeTestHypotheses ();
425
426 // The visualizer
427 PCLVisualizer viz;
428
429 CallbackParameters params(objrec, viz, *scene_points, *scene_normals, num_hypotheses_to_show);
430 viz.registerKeyboardCallback (keyboardCB, static_cast<void*> (&params));
431
432 // Run the recognition and update the viewer
433 update (&params);
434
435#ifdef _SHOW_SCENE_POINTS_
436 viz.addPointCloud (scene_points, "cloud in");
437 viz.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "cloud in");
438#endif
439
440#ifdef _SHOW_OCTREE_POINTS_
441 PointCloud<PointXYZ>::Ptr octree_points (new PointCloud<PointXYZ> ());
442 objrec.getSceneOctree ().getFullLeavesPoints (*octree_points);
443 viz.addPointCloud (octree_points, "octree points");
444 viz.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5, "octree points");
445 viz.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 1.0, 0.0, 0.0, "octree points");
446#endif
447
448#if defined _SHOW_OCTREE_NORMALS_ && defined _SHOW_OCTREE_POINTS_
449 PointCloud<Normal>::Ptr octree_normals (new PointCloud<Normal> ());
450 objrec.getSceneOctree ().getNormalsOfFullLeaves (*octree_normals);
451 viz.addPointCloudNormals<PointXYZ,Normal> (octree_points, octree_normals, 1, 6.0f, "normals out");
452#endif
453
454 // Enter the main loop
455 while (!viz.wasStopped ())
456 {
457 //main loop of the visualizer
458 viz.spinOnce (100);
459 std::this_thread::sleep_for(100ms);
460 }
461

Callers 1

mainFunction · 0.70

Calls 11

NewFunction · 0.85
getFullLeavesPointsMethod · 0.80
vtk_to_pointcloudFunction · 0.70
updateFunction · 0.70
addModelMethod · 0.45
addPointCloudMethod · 0.45
wasStoppedMethod · 0.45
spinOnceMethod · 0.45

Tested by

no test coverage detected