PointCloudConsortium > PCCブログ
![]()
PCL、3D関連の情報をブログ形式で発信します。
<2>Visual C++ Express起動
前記事のWindows8.1でPCLを動かすまで(初心者編①~③)で紹介いたしました設定を完了できた状態で作業を行います。
プロジェクトにコードを記述していきます。
記述するコードはPCLの公式ページよりコピーして持ってきます。
http://mobile.docs.pointclouds.org/documentation/tutorials/
http://mobile.docs.pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber
<3>PCL公式ページからのサンプルコード
#include "stdafx.h"
#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::PointXYZ>::ConstPtr &cloud)
{
if (!viewer.wasStopped())
viewer.showCloud (cloud);
}
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;
}
そのままコピーしてデバック開始をするとビルドエラーが出ますので上記のように
ただしそのままですと色情報がなく白い点群が表示されます。マグネットインダストリー
西内伸太郎
2014年7月18日
PCL関連ブログ
・MeshLabで点群メッシュ化の際に色情報をテクスチャ画像にする
・Point Cloud Libraryについて②「PCLの概要」
・Point Cloud Library について ①「PCLの登場の経緯」