c++ - Print 3D coordinates of the selected point inside PCL visualizer -
i trying print 3d coordinates of selected point using pcl. below code:
#include <iostream> #include <pcl/io/io.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/pcl_visualizer.h> using namespace std; void pointpickingeventoccurred (const pcl::visualization::pointpickingevent& event, void* viewer_void) { std::cout << "[inof] point picking event occurred." << std::endl; float x, y, z; if (event.getpointindex () == -1) { return; } event.getpoint(x, y, z); std::cout << "[inof] point coordinate ( " << x << ", " << y << ", " << z << ")" << std::endl; } int main (int argc, char** argv) { pcl::visualization::pclvisualizer viewer("cloud viewer"); pcl::pointcloud<pcl::pointxyzrgba>::ptr body (new pcl::pointcloud<pcl::pointxyzrgba>); pcl::io::loadpcdfile ("body.pcd", *body); viewer.addpointcloud (body,"body"); viewer.registerpointpickingcallback (pointpickingeventoccurred, (void*)&viewer); viewer.spin(); return 0; }
the code compiles without error doesn't print information in termainal. what's wrong here?
try holding down shift while left-clicking pick point.
Comments
Post a Comment