编译PCL点云库
window7
vs2013
Qt 5.10.1
cmake 3.11.2
可以下载已经编译好的库,就不用手动编译
1.第三方依赖库
第三方库 | 用途 | 是否必须 |
---|---|---|
Boost | 用于智能指针等操作 | 必选 |
Eigen | 用于矩阵运算等 | 必选 |
FLANN | 用于邻域搜索等 | 必选 |
VTK | 可视化库,用于显示点云等 | 必选 |
Qt | 用于图像交互界面等 | 可选 |
QHULL | 用于表面的凸凹分解 | 可选 |
OpenNI | 用于获取点云等 | 可选 |
2.编译boost 1.67.0
2.1 下载源码
https://www.boost.org/users/download/
2.2 配置
解压进入源码目录运行bootstrap.bat批处理,会生成b2.exe和bjam.exe两个文件
2.3 编译32位库
bjam -j4 stage --toolset=msvc-12.0 address-model=32 --without-graph --without-graph_parallel --stagedir="C:\Users\Administrator\Desktop\depend_pcl\boost1.67.0" link=shared runtime-link=shared threading=multi release
编译完成将源码中头文件boost
目录拷贝到C:\Users\Administrator\Desktop\depend_pcl
3.编译eigen 3.2.10
3.1 下载
http://eigen.tuxfamily.org/index.php?title=Main_Page
3.2 cmake配置
指定编译目录后点击configure
选择vs2013编译器,编译32位库
设置安装目录C:/Users/Administrator/Desktop/depend_pcl/Eigen3.2.10
,点击configure
点击generate,打开项目开始编译
编译没有生成dll
、lib
之类的文件,其实现在头文件中,这里就直接安装
4.编译flann 1.8.4
4.1 下载
http://www.cs.ubc.ca/research/flann/#download
4.2 cmake配置
指定编译目录后点击configure
编译32位库
设置安装目录后继续configure
配置成功后点击生成,然后打开项目编译
编译
安装
5.编译qhull-2015.2
5.1 下载
http://www.qhull.org/download/
5.2 cmake配置
设置好编译目录,点击configure
编译32位库
设置好安装目录继续configure
点击generate,打开项目编译
编译
安装
6.编译OpenNI2
官网:http://www.openni.ru/openni-sdk/index.html
6.1 下载
源码:https://github.com/OpenNI/OpenNI2
bin:http://www.openni.ru/wp-content/uploads/2013/11/OpenNI-Windows-x86-2.2.0.33.zip
6.2 安装(不编译)
这里就不编译OpenNI2,直接使用编译好的
下载安装包,将安装路径设置成
C:\Users\Administrator\Desktop\depend_pcl\OpenNI2
7.编译VTK7.1.1
7.1下载
7.2 cmake配置
设置源码目录
编译32位库
修改cmake选项后继续configure
configure后点击generate,没有出错打开项目进行编译
编译时出现无法链接Qt库,我的Qt版本是5.10.1,安装是选择了vs2013和mingw,通过项目属性查看发现链接的事mingw的库,将其修改为vs2013的就可以了,其他的也这么修改
由于Qt的msvc的版是64位的,而我们编译的事32位的链接不上,这里就不集成Qt
安装vtk
8.编译PCL 1.8.1
8.1 下载
https://github.com/PointCloudLibrary/pcl/releases
8.2 cmake配置
设置源码目录,点击configure
编译32位库
设置安装目录,点击configure
设置Eigen头文件目录,点击configure
设置flann库路径,点击configure
设置boost库路径,点击configure
设置OpenNI2
设置QHull
生成项目进行编译
安装
9.测试
1.新建一个win32控制台程序
2.项目属性==>VC++目录==>包含目录
3.项目属性==>VC++目录==>库目录
4.项目属性==>链接器==>输入==>附加依赖库
将用到的lib
添加进去
5.测试代码
从源码example中拷贝过来,能编译通过,但运行是会报错
#include "stdafx.h"
#include <iostream>
#include <pcl/geometry/polygon_mesh.h>
////////////////////////////////////////////////////////////////////////////////
// User data for the vertices. Here I just store an Id. In a 3D application this would be, for example
// - x, y, z
// - nx, ny, nz
// - r, g, b
// ...
class MyVertexData
{
public:
MyVertexData(const int id = -1) : id_(id) {}
int id() const { return (id_); }
int& id() { return (id_); }
private:
int id_;
};
std::ostream&
operator << (std::ostream& os, const MyVertexData& vd)
{
return (os << vd.id());
}
////////////////////////////////////////////////////////////////////////////////
// Declare the mesh.
typedef pcl::geometry::PolygonMesh <pcl::geometry::DefaultMeshTraits <MyVertexData> > Mesh;
typedef Mesh::VertexIndex VertexIndex;
typedef Mesh::HalfEdgeIndex HalfEdgeIndex;
typedef Mesh::FaceIndex FaceIndex;
typedef Mesh::VertexIndices VertexIndices;
typedef Mesh::HalfEdgeIndices HalfEdgeIndices;
typedef Mesh::FaceIndices FaceIndices;
typedef Mesh::VertexAroundVertexCirculator VAVC;
typedef Mesh::OutgoingHalfEdgeAroundVertexCirculator OHEAVC;
typedef Mesh::IncomingHalfEdgeAroundVertexCirculator IHEAVC;
typedef Mesh::FaceAroundVertexCirculator FAVC;
typedef Mesh::VertexAroundFaceCirculator VAFC;
typedef Mesh::InnerHalfEdgeAroundFaceCirculator IHEAFC;
typedef Mesh::OuterHalfEdgeAroundFaceCirculator OHEAFC;
////////////////////////////////////////////////////////////////////////////////
// Some output functions
void
printVertices(const Mesh& mesh)
{
std::cout << "Vertices:\n ";
for (unsigned int i = 0; i<mesh.sizeVertices(); ++i)
{
std::cout << mesh.getVertexDataCloud()[i] << " ";
}
std::cout << std::endl;
}
void
printEdge(const Mesh& mesh, const HalfEdgeIndex& idx_he)
{
std::cout << " "
<< mesh.getVertexDataCloud()[mesh.getOriginatingVertexIndex(idx_he).get()]
<< " "
<< mesh.getVertexDataCloud()[mesh.getTerminatingVertexIndex(idx_he).get()]
<< std::endl;
}
void
printFace(const Mesh& mesh, const FaceIndex& idx_face)
{
// Circulate around all vertices in the face
VAFC circ = mesh.getVertexAroundFaceCirculator(idx_face);
const VAFC circ_end = circ;
std::cout << " ";
do
{
std::cout << mesh.getVertexDataCloud()[circ.getTargetIndex().get()] << " ";
} while (++circ != circ_end);
std::cout << std::endl;
}
void
printFaces(const Mesh& mesh)
{
std::cout << "Faces:\n";
for (unsigned int i = 0; i<mesh.sizeFaces(); ++i)
{
printFace(mesh, FaceIndex(i));
}
}
////////////////////////////////////////////////////////////////////////////////
int main()
{
Mesh mesh;
VertexIndices vi;
// Create a closed circle around vertex 0 //
// 2 - 1 //
// / \ / \ 7 <- Isolated vertex //
// 3 - 0 6 //
// \ / \ / //
// 4 - 5 //
for (unsigned int i = 0; i<8; ++i)
{
vi.push_back(mesh.addVertex(MyVertexData(i)));
}
// General method to add faces.
VertexIndices tmp;
tmp.push_back(vi[0]);
tmp.push_back(vi[1]);
tmp.push_back(vi[2]);
mesh.addFace(tmp);
tmp.clear();
// Convenience method: Works only for triangles
mesh.addFace(vi[0], vi[2], vi[3]);
mesh.addFace(vi[0], vi[3], vi[4]);
mesh.addFace(vi[0], vi[4], vi[5]);
// Convenience method: Works only for quads
mesh.addFace(vi[0], vi[5], vi[6], vi[1]);
printVertices(mesh);
printFaces(mesh);
//////////////////////////////////////////////////////////////////////////////
std::cout << "Outgoing half-edges of vertex 0:" << std::endl;
OHEAVC circ_oheav = mesh.getOutgoingHalfEdgeAroundVertexCirculator(vi[0]);
const OHEAVC circ_oheav_end = circ_oheav;
do
{
printEdge(mesh, circ_oheav.getTargetIndex());
} while (++circ_oheav != circ_oheav_end);
//////////////////////////////////////////////////////////////////////////////
std::cout << "Circulate around the boundary half-edges:" << std::endl;
const HalfEdgeIndex& idx_he_boundary = mesh.getOutgoingHalfEdgeIndex(vi[6]);
IHEAFC circ_iheaf = mesh.getInnerHalfEdgeAroundFaceCirculator(idx_he_boundary);
const IHEAFC circ_iheaf_end = circ_iheaf;
do
{
printEdge(mesh, circ_iheaf.getTargetIndex());
} while (++circ_iheaf != circ_iheaf_end);
//////////////////////////////////////////////////////////////////////////////
std::cout << std::endl << "Deleting face 1 (0 2 3) and 3 (0 4 5) ...\n";
std::cout << "(If the mesh is set to manifold further faces are removed automatically)\n\n";
mesh.deleteFace(FaceIndex(1));
mesh.deleteFace(FaceIndex(3));
mesh.cleanUp(); // Removes the isolated vertex (7) as well!
vi.clear(); // The vertex indices are no longer synchronized with the mesh!
printVertices(mesh);
printFaces(mesh);
//////////////////////////////////////////////////////////////////////////
std::cout << "Circulate around all faces of vertex 0:\n";
FAVC circ_fav = mesh.getFaceAroundVertexCirculator(vi[0]);
const FAVC circ_fav_end = circ_fav;
do
{
// Very important: Some half_edges are on the boundary
// -> have an invalid face index
if (!mesh.isBoundary(circ_fav.getCurrentHalfEdgeIndex()))
{
printFace(mesh, circ_fav.getTargetIndex());
}
else
{
std::cout << " invalid face -> boundary half-edge\n";
}
} while (++circ_fav != circ_fav_end);
return (0);
}
10.官方编译说明文档:
http://www.pointclouds.org/documentation/tutorials/compiling_pcl_windows.php