我是pcl库的新手,我在链接示例项目时遇到了问题。
我已将所有功能于一身的安装程序下载到vsmc2010 x64 (OpenNI库不能成功安装并在没有这个的情况下重复安装)
在Visual Studio 2010项目中:
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
int main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 5;
cloud->height = 1;
cloud->points.resize (cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size (); ++i)
{
cloud->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
cloud->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
cloud->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
}
std::cerr << "Cloud before filtering: " << std::endl;
for (size_t i = 0; i < cloud->points.size (); ++i)
std::cerr << " " << cloud->points[i].x << " "
<< cloud->points[i].y << " "
<< cloud->points[i].z << std::endl;
// Create the filtering object
pcl::PassThrough<pcl::PointXYZ> pass;
/*pass.setInputCloud (cloud);
pass.setFilterFieldName ("z");
pass.setFilterLimits (0.0, 1.0);
//pass.setFilterLimitsNegative (true);
pass.filter (*cloud_filtered);
std::cerr << "Cloud after filtering: " << std::endl;
for (size_t i = 0; i < cloud_filtered->points.size (); ++i)
std::cerr << " " << cloud_filtered->points[i].x << " "
<< cloud_filtered->points[i].y << " "
<< cloud_filtered->points[i].z << std::endl;*/
return (0);
}
但我有链接器错误:
Error 8 error LNK2019: símbolo externo "protected: void __cdecl pcl::PassThrough<struct pcl::PointXYZ>::applyFilterIndices(class std::vector<int,class std::allocator<int> > &)" (?applyFilterIndices@?$PassThrough@UPointXYZ@pcl@@@pcl@@IEAAXAEAV?$vector@HV?$allocator@H@std@@@std@@@Z) sin resolver al que se hace referencia en la función "protected: virtual void __cdecl pcl::PassThrough<struct pcl::PointXYZ>::applyFilter(class std::vector<int,class std::allocator<int> > &)" (?applyFilter@?$PassThrough@UPointXYZ@pcl@@@pcl@@MEAAXAEAV?$vector@HV?$allocator@H@std@@@std@@@Z)
任何人都可以帮助我吗?
答案 0 :(得分:0)
我建议您使用CMake创建您的PCL项目。 在下面我将使用一体式安装程序链接最新PCL 1.8.0版本的指南,请注意它适用于Visual Studio 2013或2015.请务必使用此处提供的CMakeLists.txt网站如果您选择遵循本指南,我最初使用另一个给我一些链接器问题。
CMake:https://cmake.org/ PCL 1.8.0:http://unanancyowen.com/en/pcl18/
希望这有帮助!