View multiple Point Clouds in same window using PCL in C++ -
i have 2 point cloud, want visualise in same window.
#include <pcl/io/io.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/cloud_viewer.h> int main () { pcl::visualization::cloudviewer viewer("cloud viewer"); pcl::pointcloud<pcl::pointxyzrgba>::ptr body (new pcl::pointcloud<pcl::pointxyzrgba>); pcl::io::loadpcdfile ("body.pcd", *body); pcl::pointcloud<pcl::pointxyzrgba>::ptr head (new pcl::pointcloud<pcl::pointxyzrgba>); pcl::io::loadpcdfile ("head.pcd", *head); viewer.showcloud (body); viewer.showcloud (head); while (!viewer.wasstopped ()) { } return 0; }
i can see last pcd file.
please note don't want use pcd_viewer tool since need other processing on data.
regarding comment
"okay. check soon. can tell me set camera parameters , background color using cloud_viewer api?"
i not 100% sure if can using pcl::visualization::cloudviewer
. however, if move code pcl::visualization::pclvisualizer
can viewer.setbackgroundcolor(double red,double green,double blue)
(where values range 0..1. set camera). camera, can use pcl::visualization::pclvisualizer::setcameraposition
. moving code cloudviewer pclvisualizer preatty easy.
#include <pcl/io/io.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/pcl_visualizer.h> int main () { pcl::visualization::pclvisualizer viewer("cloud viewer"); pcl::pointcloud<pcl::pointxyzrgba>::ptr body (new pcl::pointcloud<pcl::pointxyzrgba>); pcl::io::loadpcdfile ("body.pcd", *body); pcl::pointcloud<pcl::pointxyzrgba>::ptr head (new pcl::pointcloud<pcl::pointxyzrgba>); pcl::io::loadpcdfile ("head.pcd", *head); viewer.addpointcloud (body,"body");// note before showcloud viewer.addpointcloud (head,"head");// note before showcloud viewer.spin(); return 0; }
edit ther acutally way this. looking here, can see can run of function of pcl::visualization::pclvisualizer
using pcl::visualization::cloudviewer::runonvisualizationthreadonce
or pcl::visualization::cloudviewer::runonvisualizationthread
functions. this, need create function part uses pcl::visualization::pclvisualizer
and pass cloudviewer::runonvisualizationthreadonce
or cloudviewer::runonvisualizationthread
.
for example
#include <pcl/io/io.h> #include <pcl/io/pcd_io.h> #include <pcl/visualization/cloud_viewer.h> void setbackground (pcl::visualization::pclvisualizer& viewer) { viewer.setbackgroundcolor (1.0, 0.5, 1.0); } int main () { pcl::visualization::pclvisualizer viewer("cloud viewer"); pcl::pointcloud<pcl::pointxyzrgba>::ptr body (new pcl::pointcloud<pcl::pointxyzrgba>); pcl::io::loadpcdfile ("body.pcd", *body); pcl::pointcloud<pcl::pointxyzrgba>::ptr head (new pcl::pointcloud<pcl::pointxyzrgba>); pcl::io::loadpcdfile ("head.pcd", *head); viewer.showcloud (body,"body"); viewer.showcloud (head,"head"); viewer.runonvisualizationthreadonce(setbackground); while (!viewer.wasstopped ()) { } return 0; }
the issue not see how potentially pass arguments pcl::visualization::pclvisualizer
function want use in function crated (in previous example pcl::visualization::pclvisualizer::setbackgroundcolor
in setbackground
. this, think using directly pcl::visualization::pclvisualizer
better.
Comments
Post a Comment