2014-11-09 2 views
0

실시간으로 필터링 된 포인트 클라우드를 표시하고 싶습니다. PCD 파일이 아니라 PCL 문서의 예제 코드를 조작하려고했습니다. 이 물건과 C + + 초급. 내 코드는 오류가 있지만 이해할 수는 없습니다. :(포인트 클라우드를 실시간으로 필터링 ... PCL

#include <pcl/io/openni_grabber.h> 
#include <pcl/visualization/cloud_viewer.h> 
#include <iostream> 
#include <pcl/point_types.h> 
#include <pcl/filters/voxel_grid.h> 
Class SimpleOpenNIViewer 
{ 
public: 
SimpleOpenNIViewer() : viewer ("PCL OpenNI Viewer") {} 
pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_filtered; 
void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud) 
{ 
    if (!viewer.wasStopped()){ 
    pcl::VoxelGrid<pcl::PointCloud<pcl::PointXYZ> sor; 
    sor.setInputCloud (cloud); 
    sor.setLeafSize (0.01f, 0.01f, 0.01f); 
    sor.filter (*cloud_filtered); 
    viewer.showCloud (cloud_filtered); 
    } 
} 

void run() 
{ 
    pcl::Grabber* interface = new pcl::OpenNIGrabber(); 

    boost::function<void (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr&)> f = 
    boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1); 

    interface->registerCallback (f); 

    interface->start(); 

    while (!viewer.wasStopped()) 
    { 
    boost::this_thread::sleep (boost::posix_time::seconds (1)); 
    } 

    interface->stop(); 
} 

pcl::visualization::CloudViewer viewer; 
}; 

int main() 
{ 
    SimpleOpenNIViewer v; 
    v.run(); 
    return 0; 
} 
+0

그것은 잠재적 인 헬퍼에게 많은 도움이됩니다. –

답변

0

오류 : 오류 메시지를 제공 할 수 있다면

sor.setInputCloud (cloud); 
sor.setLeafSize (0.01f, 0.01f, 0.01f); 
sor.filter (*cloud_filtered); 
viewer.showCloud (*cloud_filtered);// I guess with this the error is solved 
관련 문제