点云技术相关产学研社区

 找回密码
 立即注册加入PCL中国点云技术相关产学研社区

扫一扫,访问微社区

查看: 11273|回复: 9

NDT配准 生成的时候出现错误

[复制链接]
发表于 2013-7-9 09:48:12 | 显示全部楼层 |阅读模式
NDT配准 生成的时候出现错误
2>normal_distributions_transform.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall pcl::VoxelGridCovariance<struct pcl::PointXYZ>::applyFilter(class pcl::PointCloud<struct pcl::PointXYZ> &)" (?applyFilter@?$VoxelGridCovariance@UPointXYZ@pcl@@@pcl@@MAEXAAV?$PointCloud@UPointXYZ@pcl@@@2@@Z)
2>D:\test\normal_distributions_transform\bin\Debug\normal_distributions_transform.exe : fatal error LNK1120: 1 个无法解析的外部命令


代码是教材上的
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/registration/ndt.h>
#include <pcl/filters/approximate_voxel_grid.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <boost/thread/thread.hpp>
int
main (int argc, char** argv)
{
  //加载房间的第一次扫描
  pcl::PointCloud<pcl::PointXYZ>::Ptr target_cloud (new pcl::PointCloud<pcl::PointXYZ>);
  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("room_scan1.pcd", *target_cloud) == -1)
  {
    PCL_ERROR ("Couldn't read file room_scan1.pcd \n");
    return (-1);
  }
  std::cout << "Loaded " << target_cloud->size () << " data points from room_scan1.pcd" << std::endl;
  //加载从新视角得到的房间的第二次扫描
  pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud (new pcl::PointCloud<pcl::PointXYZ>);
  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("room_scan2.pcd", *input_cloud) == -1)
  {
    PCL_ERROR ("Couldn't read file room_scan2.pcd \n");
    return (-1);
  }
  std::cout << "Loaded " << input_cloud->size () << " data points from room_scan2.pcd" << std::endl;
  //将输入的扫描过滤到原始尺寸的大概10%以提高匹配的速度。
  pcl::PointCloud<pcl::PointXYZ>::Ptr filtered_cloud (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::ApproximateVoxelGrid<pcl::PointXYZ> approximate_voxel_filter;
  approximate_voxel_filter.setLeafSize (0.2, 0.2, 0.2);
  approximate_voxel_filter.setInputCloud (input_cloud);
  approximate_voxel_filter.filter (*filtered_cloud);
  std::cout << "Filtered cloud contains " << filtered_cloud->size ()
            << " data points from room_scan2.pcd" << std::endl;
  //初始化正态分布变换(NDT)
  pcl::NormalDistributionsTransform<pcl::PointXYZ, pcl::PointXYZ> ndt;
  //设置依赖尺度NDT参数
  //为终止条件设置最小转换差异
  ndt.setTransformationEpsilon (0.01);
  //为More-Thuente线搜索设置最大步长
  ndt.setStepSize (0.1);
  //设置NDT网格结构的分辨率(VoxelGridCovariance)
  ndt.setResolution (1.0);
  //设置匹配迭代的最大次数
  ndt.setMaximumIterations (35);
  // 设置要配准的点云
  ndt.setInputCloud (filtered_cloud);
  //设置点云配准目标
  ndt.setInputTarget (target_cloud);
  //设置使用机器人测距法得到的初始对准估计结果
  Eigen::AngleAxisf init_rotation (0.6931, Eigen::Vector3f::UnitZ ());
  Eigen::Translation3f init_translation (1.79387, 0.720047, 0);
  Eigen::Matrix4f init_guess = (init_translation * init_rotation).matrix ();
  //计算需要的刚体变换以便将输入的点云匹配到目标点云
  pcl::PointCloud<pcl::PointXYZ>::Ptr output_cloud (new pcl::PointCloud<pcl::PointXYZ>);
  ndt.align (*output_cloud, init_guess);
  std::cout << "Normal Distributions Transform has converged:" << ndt.hasConverged ()
            << " score: " << ndt.getFitnessScore () << std::endl;
  //使用创建的变换对未过滤的输入点云进行变换
  pcl::transformPointCloud (*input_cloud, *output_cloud, ndt.getFinalTransformation ());
  //保存转换的输入点云
  pcl::io::savePCDFileASCII ("room_scan2_transformed.pcd", *output_cloud);
  // 初始化点云可视化界面
  boost::shared_ptr<pcl::visualization::PCLVisualizer>
  viewer_final (new pcl::visualization::PCLVisualizer ("3D Viewer"));
  viewer_final->setBackgroundColor (0, 0, 0);
  //对目标点云着色(红色)并可视化
  pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ>
  target_color (target_cloud, 255, 0, 0);
  viewer_final->addPointCloud<pcl::PointXYZ> (target_cloud, target_color, "target cloud");
  viewer_final->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
                                                  1, "target cloud");
  //对转换后的目标点云着色(绿色)并可视化
  pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ>
  output_color (output_cloud, 0, 255, 0);
  viewer_final->addPointCloud<pcl::PointXYZ> (output_cloud, output_color, "output cloud");
  viewer_final->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
                                                  1, "output cloud");
  // 启动可视化
  viewer_final->addCoordinateSystem (1.0);
  viewer_final->initCameraParameters ();
  //等待直到可视化窗口关闭。
  while (!viewer_final->wasStopped ())
  {
    viewer_final->spinOnce (100);
    boost::this_thread::sleep (boost::posix_time::microseconds (100000));
  }
  return (0);
}


回复

使用道具 举报

发表于 2013-7-9 10:09:22 | 显示全部楼层

回帖奖励 +1 金钱

需要添加这个pcl_filters_release.lib在你的链接项中。
你是只把ndt.h放在合适的位置,就直接编译的吗,我估计你添加了,还会有问题。你编译好的registration模块中没有包含ndt的实现吧。  anyway,你试一试。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-7-9 10:28:11 | 显示全部楼层
mypcl 发表于 2013-7-9 10:09
需要添加这个pcl_filters_release.lib在你的链接项中。
你是只把ndt.h放在合适的位置,就直接编译的吗,我 ...

谢谢,不过还是没用
回复 支持 反对

使用道具 举报

发表于 2013-7-10 15:35:25 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2014-11-4 12:13:50 | 显示全部楼层
为何1。5版本没有ndt头文件呢
回复 支持 反对

使用道具 举报

发表于 2014-11-9 10:59:27 | 显示全部楼层
chrisfxz 发表于 2014-11-4 12:13
为何1。5版本没有ndt头文件呢

使用1.7.2版本的里面有,另外,升级Flann到1.8以上,然后再编译pcl库
回复 支持 反对

使用道具 举报

发表于 2015-4-9 16:03:58 | 显示全部楼层
我和你情况一样,不知前辈当初是如何让解决的
回复 支持 反对

使用道具 举报

发表于 2015-4-11 12:27:35 | 显示全部楼层
我用的是PCL1.7.2+VS2012+CMAKE3.1.2,在CMAKE配置时出现两个警告“** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled”没有处理,在VS2012中生成时,出现很多错误,主要问题就是“vtkCommon-gd.lib(vtkSmartPointerBase.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1700”(normal_distributions_transform.obj 中)”,请高手指导。是不是版本的问题?
回复 支持 反对

使用道具 举报

发表于 2015-4-12 23:24:33 | 显示全部楼层
我只更新PCL1.7.2的库和FLANN1.8.4,VS2010总算生成成功,运行exe文件,能够生成配准PCD文件,但显示时出现问题。调试时,程序运行到CPP的72行,即viewer_final->addPointCloud<pcl::PointXYZ> (target_cloud, target_color, "target cloud");,在调用pcl_visulizer.hpp时的292行,即 vtkSmartPointer<vtkPoints> points;时,提示“读取位置0xbaadfood时发生访问冲突”,请高手指导,谢谢!
回复 支持 反对

使用道具 举报

发表于 2015-4-12 23:47:29 | 显示全部楼层
更新VTK库后,在VS2010生成的过程中出错,error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall vtkDataArrayTemplate<unsigned char>::SetArray(unsigned char *,int,int)" (__imp_?SetArray@?$vtkDataArrayTemplate@E@@QAEXPAEHH@Z),该符号在函数 "public: virtual bool __thiscall pcl::visualization::PointCloudColorHandlerCustom<struct pcl::PointXYZ>::getColor(class vtkSmartPointer<class vtkDataArray>&)const " (?getColor@?$PointCloudColorHandlerCustom@UPointXYZ@pcl@@@visualization@pcl@@UBE_NAAV?$vtkSmartPointer@VvtkDataArray@@@@@Z) 中被引用,请高手指导,谢谢!
回复 支持 反对

使用道具 举报

本版积分规则

QQ|小黑屋|点云技术相关产学研社区 ( 陕ICP备13001629号 )

GMT+8, 2024-5-5 08:26 , Processed in 4.400929 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表