1.新規プロジェクトの作成
Visual Studio 2013を起動し、メニューバーの[ファイル] >[新規] >[プロジェクト]から新規プロジェクトを作成します。プロジェクトの種類は「Win32コンソールアプリケーション」とし、プロジェクト名は「PclTest」とします。
2.プロパティの設定(OpenNI抜き)
「Solution Explorer」のプロジェクト名で右クリックし、一番下の「Properties」を開きます。
2.1 x64へ変更
右上の「configuration Manager」をクリックし、[Active Solution platform]に新規で「x64」を設定します。
2.2 インクルードを追加
左の中から、「Configuration Properties -> C/C++」を選択し、「Additional Include Directories」に以下のものを追加します。
C:\Program Files\PCL 1.7.2\include\pcl-1.7;C:\Program Files\PCL 1.7.2\3rdParty\Boost\include\boost-1_57;C:\Program Files\PCL 1.7.2\3rdParty\Eigen\eigen3;C:\Program Files\PCL 1.7.2\3rdParty\FLANN\include;C:\Program Files\PCL 1.7.2\3rdParty\Qhull\include;C:\Program Files\PCL 1.7.2\3rdParty\VTK\include\vtk-6.2\
この設定では、以降のソース内のインクルードの設定は。
PCL:#include <PCL\*.h>
Boost:#include <boost\*.h>
Eigen:#include <Eigen\*.h>
FLANN:#include <flann\*.h>
Qhull:#include <libqhullcpp\*.h>
VTK:#include <*.h>
2.3 リンカーを追加
左の中から、「Configuration Properties -> Linker->General」を選択し、「Additional Library Directories」に以下のものを追加します。(Eigenはヘッダのみのライブラリなので追加の必要なし)
C:\Program Files\PCL 1.7.2\lib;C:\Program Files\PCL 1.7.2\3rdParty\Boost\lib;C:\Program Files\PCL 1.7.2\3rdParty\FLANN\lib;C:\Program Files\PCL 1.7.2\3rdParty\Qhull\lib;C:\Program Files\PCL 1.7.2\3rdParty\VTK\lib2.4 追加の依存ファイルを追加
左の中から、「Configuration Properties -> Linker->Input」を選択し、「Additional Dependencies」に以下のものを追加します。(Eigenはヘッダのみのライブラリなので追加の必要なし)
pcl_common_debug.lib
pcl_features_debug.lib
pcl_filters_debug.lib
pcl_io_debug.lib
pcl_io_ply_debug.lib
pcl_kdtree_debug.lib
pcl_keypoints_debug.lib
pcl_octree_debug.lib
pcl_outofcore_debug.lib
pcl_people_debug.lib
pcl_recognition_debug.lib
pcl_registration_debug.lib
pcl_sample_consensus_debug.lib
pcl_search_debug.lib
pcl_segmentation_debug.lib
pcl_surface_debug.lib
pcl_tracking_debug.lib
pcl_visualization_debug.lib
flann.lib
flann-gd.lib
flann_s-gd.lib
flann_cpp_s-gd.lib
qhull_d.lib
qhullcpp_d.lib
qhullstatic_d.lib
qhullstatic_p_d.lib
vtkalglib-6.2-gd.lib
vtkChartsCore-6.2-gd.lib
vtkCommonColor-6.2-gd.lib
vtkCommonComputationalGeometry-6.2-gd.lib
vtkCommonCore-6.2-gd.lib
vtkCommonDataModel-6.2-gd.lib
vtkCommonExecutionModel-6.2-gd.lib
vtkCommonMath-6.2-gd.lib
vtkCommonMisc-6.2-gd.lib
vtkCommonSystem-6.2-gd.lib
vtkCommonTransforms-6.2-gd.lib
vtkDICOMParser-6.2-gd.lib
vtkDomainsChemistry-6.2-gd.lib
vtkexoIIc-6.2-gd.lib
vtkexpat-6.2-gd.lib
vtkFiltersAMR-6.2-gd.lib
vtkFiltersCore-6.2-gd.lib
vtkFiltersExtraction-6.2-gd.lib
vtkFiltersFlowPaths-6.2-gd.lib
vtkFiltersGeneral-6.2-gd.lib
vtkFiltersGeneric-6.2-gd.lib
vtkFiltersGeometry-6.2-gd.lib
vtkFiltersHybrid-6.2-gd.lib
vtkFiltersHyperTree-6.2-gd.lib
vtkFiltersImaging-6.2-gd.lib
vtkFiltersModeling-6.2-gd.lib
vtkFiltersParallel-6.2-gd.lib
vtkFiltersParallelImaging-6.2-gd.lib
vtkFiltersProgrammable-6.2-gd.lib
vtkFiltersSelection-6.2-gd.lib
vtkFiltersSMP-6.2-gd.lib
vtkFiltersSources-6.2-gd.lib
vtkFiltersStatistics-6.2-gd.lib
vtkFiltersTexture-6.2-gd.lib
vtkFiltersVerdict-6.2-gd.lib
vtkfreetype-6.2-gd.lib
vtkftgl-6.2-gd.lib
vtkGeovisCore-6.2-gd.lib
vtkgl2ps-6.2-gd.lib
vtkhdf5_hl-6.2-gd.lib
vtkhdf5-6.2-gd.lib
vtkImagingColor-6.2-gd.lib
vtkImagingCore-6.2-gd.lib
vtkImagingFourier-6.2-gd.lib
vtkImagingGeneral-6.2-gd.lib
vtkImagingHybrid-6.2-gd.lib
vtkImagingMath-6.2-gd.lib
vtkImagingMorphological-6.2-gd.lib
vtkImagingSources-6.2-gd.lib
vtkImagingStatistics-6.2-gd.lib
vtkImagingStencil-6.2-gd.lib
vtkInfovisCore-6.2-gd.lib
vtkInfovisLayout-6.2-gd.lib
vtkInteractionImage-6.2-gd.lib
vtkInteractionStyle-6.2-gd.lib
vtkInteractionWidgets-6.2-gd.lib
vtkIOAMR-6.2-gd.lib
vtkIOCore-6.2-gd.lib
vtkIOEnSight-6.2-gd.lib
vtkIOExodus-6.2-gd.lib
vtkIOExport-6.2-gd.lib
vtkIOGeometry-6.2-gd.lib
vtkIOImage-6.2-gd.lib
vtkIOImport-6.2-gd.lib
vtkIOInfovis-6.2-gd.lib
vtkIOLegacy-6.2-gd.lib
vtkIOLSDyna-6.2-gd.lib
vtkIOMINC-6.2-gd.lib
vtkIOMovie-6.2-gd.lib
vtkIONetCDF-6.2-gd.lib
vtkIOParallel-6.2-gd.lib
vtkIOParallelXML-6.2-gd.lib
vtkIOPLY-6.2-gd.lib
vtkIOSQL-6.2-gd.lib
vtkIOVideo-6.2-gd.lib
vtkIOXML-6.2-gd.lib
vtkIOXMLParser-6.2-gd.lib
vtkjpeg-6.2-gd.lib
vtkjsoncpp-6.2-gd.lib
vtklibxml2-6.2-gd.lib
vtkmetaio-6.2-gd.lib
vtkNetCDF_cxx-6.2-gd.lib
vtkNetCDF-6.2-gd.lib
vtkoggtheora-6.2-gd.lib
vtkParallelCore-6.2-gd.lib
vtkpng-6.2-gd.lib
vtkproj4-6.2-gd.lib
vtkRenderingAnnotation-6.2-gd.lib
vtkRenderingContext2D-6.2-gd.lib
vtkRenderingContextOpenGL-6.2-gd.lib
vtkRenderingCore-6.2-gd.lib
vtkRenderingFreeType-6.2-gd.lib
vtkRenderingFreeTypeOpenGL-6.2-gd.lib
vtkRenderingGL2PS-6.2-gd.lib
vtkRenderingImage-6.2-gd.lib
vtkRenderingLabel-6.2-gd.lib
vtkRenderingLIC-6.2-gd.lib
vtkRenderingLOD-6.2-gd.lib
vtkRenderingOpenGL-6.2-gd.lib
vtkRenderingVolume-6.2-gd.lib
vtkRenderingVolumeOpenGL-6.2-gd.lib
vtksqlite-6.2-gd.lib
vtksys-6.2-gd.lib
vtktiff-6.2-gd.lib
vtkverdict-6.2-gd.lib
vtkViewsContext2D-6.2-gd.lib
vtkViewsCore-6.2-gd.lib
vtkViewsInfovis-6.2-gd.lib
vtkzlib-6.2-gd.lib
-----------------------
vtkalglib-gd.lib;
vtkCharts-gd.lib;
vtkCommon-gd.lib;
vtkDICOMParser-gd.lib;
vtkexoIIc-gd.lib;
vtkexpat-gd.lib;
vtkFiltering-gd.lib;
vtkfreetype-gd.lib;
vtkftgl-gd.lib;
vtkGenericFiltering-gd.lib;
vtkGeovis-gd.lib;
vtkGraphics-gd.lib;
vtkhdf5-gd.lib;
vtkHybrid-gd.lib;
vtkImaging-gd.lib;
vtkInfovis-gd.lib;
vtkIO-gd.lib;
vtkjpeg-gd.lib;
vtklibxml2-gd.lib;
vtkmetaio-gd.lib;
vtkNetCDF-gd.lib;
vtkNetCDF_cxx-gd.lib;
vtkpng-gd.lib;
vtkproj4-gd.lib;
vtkRendering-gd.lib;
vtksqlite-gd.lib;
vtksys-gd.lib;
vtktiff-gd.lib;
vtkverdict-gd.lib;
vtkViews-gd.lib;
vtkVolumeRendering-gd.lib;
vtkWidgets-gd.lib;
vtkzlib-gd.lib;opengl32.lib;
3.サンプルプログラムの実行
ライブラリの中にあるサンプルプログラム(cloud_viewer.cpp)をちょっと改造(ほとんど変えてない)して実行。
---------------------------------------------Source---------------------------------------------
// PclTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
int user_data;
void
viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
{
viewer.setBackgroundColor(1.0, 0.5, 1.0);
pcl::PointXYZ o;
o.x = 1.0;
o.y = 0;
o.z = 0;
viewer.addSphere(o, 0.25, "sphere", 0);
std::cout << "i only run once" << std::endl;
}
void
viewerPsycho(pcl::visualization::PCLVisualizer& viewer)
{
static unsigned count = 0;
std::stringstream ss;
ss << "Once per viewer loop: " << count++;
viewer.removeShape("text", 0);
viewer.addText(ss.str(), 200, 300, "text", 0);
//FIXME: possible race condition here:
user_data++;
}
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "test" << std::endl;
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::io::loadPCDFile("my_point_cloud.pcd", *cloud);
pcl::visualization::CloudViewer viewer("Cloud Viewer");
//blocks until the cloud is actually rendered
viewer.showCloud(cloud);
//use the following functions to get access to the underlying more advanced/powerful
//PCLVisualizer
//This will only get called once
viewer.runOnVisualizationThreadOnce(viewerOneOff);
//This will get called once per visualization iteration
viewer.runOnVisualizationThread(viewerPsycho);
while (!viewer.wasStopped())
{
//you can also do cool processing here
//FIXME: Note that this is running in a separate thread from viewerPsycho
//and you should guard against race conditions yourself...
user_data++;
}
return 0;
}
------------------------------------------------------------------------------------------
この画面が出力されたら成功!!
reference
http://unanancyowen.com/?p=712
http://tips.hecomi.com/entry/2014/05/11/214401
http://www.pointcloud.jp/blog_n03/
http://derivecv.tumblr.com/serialization
http://derivecv.tumblr.com/post/12359379355
0 件のコメント:
コメントを投稿