void visualize(pcl::PointCloud<pcl::PointXYZ>::Ptr pCloud, pcl::visualization::PCLVisualizer::Ptr pVisualizer) { //init visualizer pVisualizer->setSize(640, 480); pVisualizer->setPosition(640, 0); pVisualizer->setBackgroundColor(0x00, 0x00, 0x00); pVisualizer->initCameraParameters(); pVisualizer->addPointCloud(pCloud, "cloud"); //reload visualizer content pVisualizer->spinOnce(1000000); }
void setCam( /* in: */ Eigen::Vector3d &pos, Eigen::Vector3d &up, Eigen::Vector3d &dir, ::pcl::visualization::PCLVisualizer::Ptr pViewerPtr ) { vtkSmartPointer<vtkRendererCollection> rens = pViewerPtr->getRendererCollection(); rens->InitTraversal (); vtkRenderer* renderer = NULL; int it = 0; while ((renderer = rens->GetNextItem ()) != NULL && (it < 1) ) { vtkCamera& camera = *renderer->GetActiveCamera(); camera.SetPosition ( pos[0], pos[1], pos[2] ); camera.SetViewUp ( up[0], up[1], up[2] ); camera.SetFocalPoint( dir[0], dir[1], dir[2] ); ++it; } pViewerPtr->spinOnce(); }
virtual void processBufferElement(CloudConstPtr cloud) override { cloud_viewer_->spinOnce(); if (!cloud_viewer_->updatePointCloud(cloud, "OpenNICloud")) { cloud_viewer_->setPosition(0, 0); cloud_viewer_->setSize(cloud->width, cloud->height); cloud_viewer_->addPointCloud(cloud, "OpenNICloud"); cloud_viewer_->resetCameraViewpoint("OpenNICloud"); cloud_viewer_->setCameraPosition( 0, 0, 0, // Position 0, 0, 1, // Viewpoint 0, -1, 0); // Up } // TODO; Figure out how to achieve this // if(cloud_viewer_->wasStopped()) { // this->cloud_buffer_.reset(new Buffer<CloudConstPtr>()); // this->stop(); // cloud_viewer_->close(); // } }