http://pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber
データが取得できれば、これまでやった、ファイルへの保存、ビューワでの表示、がとりあえずできるようになるわけです。
公式のサンプルコードは動かないので↓のように修正しました。
- #include <pcl/io/openni_grabber.h>
- #include <pcl/visualization/cloud_viewer.h>
- class SimpleOpenNIViewer
- {
- public:
- SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}
- void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud)
- {
- if (!viewer.wasStopped())
- viewer.showCloud (cloud);
- }
- void run ()
- {
- pcl::Grabber* interface = new pcl::OpenNIGrabber();
- boost::function<void (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&)> f =
- boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);
- interface->registerCallback (f);
- interface->start ();
- while (!viewer.wasStopped())
- {
- sleep (1);
- }
- interface->stop ();
- }
- pcl::visualization::CloudViewer viewer;
- };
- int main ()
- {
- SimpleOpenNIViewer v;
- v.run ();
- return 0;
- }
ビューワで表示されます。
さらに
#include<pcl/io/pcd_io.h>
して、cloud_cb_の中に
pcl::io::savePCDFileBinary("kinect.pcd", *cloud);
を追加すればファイルに保存もできますね。
マイフレーム保存してもけっこう軽いです。
次回は平面抽出をやります。
0 件のコメント:
コメントを投稿