点云技术相关产学研社区

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

扫一扫,访问微社区

查看: 3210|回复: 1

新人求教。(教材代码不能正常运行问题)

[复制链接]
发表于 2014-11-22 20:57:26 | 显示全部楼层 |阅读模式
本人初次接触PCL,求各位大神好好指导。
我看过教程后,把教程的代码放在自己电脑上运行遇到问题。
  1. #include <iostream>
  2. #include <pcl/io/pcd_io.h>
  3. #include <pcl/point_types.h>
  4. #include <pcl/registration/icp.h>

  5. int
  6. main (int argc, char** argv)
  7. {
  8.   pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZ>);
  9.   pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out (new pcl::PointCloud<pcl::PointXYZ>);

  10.   // Fill in the CloudIn data
  11.   cloud_in->width    = 5;
  12.   cloud_in->height   = 1;
  13.   cloud_in->is_dense = false;
  14.   cloud_in->points.resize (cloud_in->width * cloud_in->height);
  15.   for (size_t i = 0; i < cloud_in->points.size (); ++i)
  16.   {
  17.     cloud_in->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
  18.     cloud_in->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
  19.     cloud_in->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
  20.   }
  21.   std::cout << "Saved " << cloud_in->points.size () << " data points to input:"
  22.       << std::endl;
  23.   for (size_t i = 0; i < cloud_in->points.size (); ++i) std::cout << "    " <<
  24.       cloud_in->points[i].x << " " << cloud_in->points[i].y << " " <<
  25.       cloud_in->points[i].z << std::endl;
  26.   *cloud_out = *cloud_in;
  27.   std::cout << "size:" << cloud_out->points.size() << std::endl;
  28.   for (size_t i = 0; i < cloud_in->points.size (); ++i)
  29.     cloud_out->points[i].x = cloud_in->points[i].x + 0.7f;
  30.   std::cout << "Transformed " << cloud_in->points.size () << " data points:"
  31.       << std::endl;
  32.   for (size_t i = 0; i < cloud_out->points.size (); ++i)
  33.     std::cout << "    " << cloud_out->points[i].x << " " <<
  34.       cloud_out->points[i].y << " " << cloud_out->points[i].z << std::endl;
  35.   pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
  36.   icp.setInputCloud(cloud_in);
  37.   icp.setInputTarget(cloud_out);
  38.   pcl::PointCloud<pcl::PointXYZ> Final;
  39.   icp.align(Final);
  40.   std::cout << "has converged:" << icp.hasConverged() << " score: " <<
  41.   icp.getFitnessScore() << std::endl;
  42.   std::cout << icp.getFinalTransformation() << std::endl;

  43. return (0);
  44. }
复制代码
以上是从官网和教程找的代码,自己拷贝运行后出现几个问题,求指点迷津
1.编译的时候速度很慢,,提示这个
  1. <command-line>:0:15: warning: missing whitespace after the macro name [enabled by default]
复制代码
请问这个正常么?
2.编译过程提示我setInputCloud()改为setInputSource();我按照提示改了,再编译提示消失,请问里面参数是否不需要变,还是原来的点云。
3最后一个最关键的,我的代码和网站一模一样为什么只能输出
  1. Saved 5 data points to input:
  2.     0.352222 -0.151883 -0.106395
  3.     -0.397406 -0.473106 0.292602
  4.     -0.731898 0.667105 0.441304
  5.     -0.734766 0.854581 -0.0361733
  6.     -0.4607 -0.277468 -0.916762
  7. size:5
  8. Transformed 5 data points:
  9.     1.05222 -0.151883 -0.106395
  10.     0.302594 -0.473106 0.292602
  11.     -0.0318983 0.667105 0.441304
  12.     -0.0347655 0.854581 -0.0361733
  13.     0.2393 -0.277468 -0.916762
  14. Illegal instruction (core dumped)
复制代码
最后给我个非法指令是什么意思,难道官网代码有错?求大神指导,虚心求教。。
我的系统是
Fedora 20

回复

使用道具 举报

发表于 2014-11-27 15:31:17 | 显示全部楼层
目前這程式只有輸出比對後的旋轉與平移值
若要顯示比對結果需再key指令讓它顯示出
回复 支持 反对

使用道具 举报

本版积分规则

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

GMT+8, 2024-5-13 01:19 , Processed in 1.054972 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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