{"action":"created","issue":{"url":"https://api.github.com/repos/giacomodabisias/libfreenect2pclgrabber/issues/11","labels_url":"https://api.github.com/repos/giacomodabisias/libfreenect2pclgrabber/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/giacomodabisias/libfreenect2pclgrabber/issues/11/comments","events_url":"https://api.github.com/repos/giacomodabisias/libfreenect2pclgrabber/issues/11/events","html_url":"https://github.com/giacomodabisias/libfreenect2pclgrabber/issues/11","id":115790896,"number":11,"title":"Writing cloud to PLY","user":{"login":"ahundt","id":55744,"avatar_url":"https://avatars.githubusercontent.com/u/55744?v=3","gravatar_id":"","url":"https://api.github.com/users/ahundt","html_url":"https://github.com/ahundt","followers_url":"https://api.github.com/users/ahundt/followers","following_url":"https://api.github.com/users/ahundt/following{/other_user}","gists_url":"https://api.github.com/users/ahundt/gists{/gist_id}","starred_url":"https://api.github.com/users/ahundt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahundt/subscriptions","organizations_url":"https://api.github.com/users/ahundt/orgs","repos_url":"https://api.github.com/users/ahundt/repos","events_url":"https://api.github.com/users/ahundt/events{/privacy}","received_events_url":"https://api.github.com/users/ahundt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-09T04:44:28Z","updated_at":"2015-11-09T05:36:15Z","closed_at":null,"body":"I'm trying to modify the test to write out a PLY file:\r\n\r\n```\r\n/*\r\nCopyright 2015, Giacomo Dabisias\"\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n@Author \r\nGiacomo. Dabisias, PhD Student\r\nPERCRO, (Laboratory of Perceptual Robotics)\r\nScuola Superiore Sant'Anna\r\nvia Luigi Alamanni 13D, San Giuliano Terme 56010 (PI), Italy\r\n*/\r\n#include \"k2g.h\"\r\n#include <pcl/visualization/cloud_viewer.h>\r\n#include <chrono>\r\n\r\n// extra headers for writing out ply file\r\n#include <pcl/console/print.h>\r\n#include <pcl/console/parse.h>\r\n#include <pcl/console/time.h>\r\n#include <pcl/io/ply_io.h>\r\n#include <pcl/PCLPointCloud2.h>\r\n\r\nusing namespace pcl;\r\nusing namespace pcl::io;\r\nusing namespace pcl::console;\r\n\r\ntemplate<typename Cloud>\r\nvoid\r\nsaveCloud (const std::string &filename, const Cloud &cloud, bool binary, bool use_camera)\r\n{\r\n  TicToc tt;\r\n  tt.tic ();\r\n\r\n  print_highlight (\"Saving \"); print_value (\"%s \", filename.c_str ());\r\n  \r\n  pcl::PLYWriter writer;\r\n  writer.write (filename, cloud, Eigen::Vector4f::Zero (), Eigen::Quaternionf::Identity (), binary, use_camera);\r\n  \r\n  print_info (\"[done, \"); print_value (\"%g\", tt.toc ()); print_info (\" ms : \"); print_value (\"%d\", cloud.width * cloud.height); print_info (\" points]\\n\");\r\n}\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n  std::cout << \"Syntax is: \" << argv[0] << \" [-processor 0|1|2] [output.ply]\\n -processor options 0,1,2 correspond to CPU, OPENCL, and OPENGL respectively\\n\";\r\n  processor freenectprocessor = OPENGL;\r\n  std::vector<int> ply_file_indices;\r\n  if(argc>1){\r\n      int fnpInt;\r\n      ply_file_indices = parse_file_extension_argument (argc, argv, \".ply\");\r\n      parse_argument (argc, argv, \"-processor\", fnpInt);\r\n      freenectprocessor = static_cast<processor>(fnpInt);\r\n      \r\n  }\r\n    \r\n  boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB>> cloud;\r\n  K2G k2g(freenectprocessor);\r\n  std::cout << \"getting cloud\" << std::endl;\r\n  cloud = k2g.getCloud();\r\n\r\n  cloud->sensor_orientation_.w() = 0.0;\r\n  cloud->sensor_orientation_.x() = 1.0;\r\n  cloud->sensor_orientation_.y() = 0.0;\r\n  cloud->sensor_orientation_.z() = 0.0;\r\n  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer (\"3D Viewer\"));\r\n  viewer->setBackgroundColor (0, 0, 0);\r\n  pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);\r\n  viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgb, \"sample cloud\");\r\n  viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, \"sample cloud\");\r\n  \r\n  bool done = false;\r\n  while ((!viewer->wasStopped()) && (!done)) {\r\n    viewer->spinOnce ();\r\n    using namespace std::chrono;\r\n    static high_resolution_clock::time_point last;\r\n\r\n    auto tnow = high_resolution_clock::now();   \r\n    cloud = k2g.getCloud();\r\n    auto tpost = high_resolution_clock::now();\r\n    std::cout << \"delta \" << duration_cast<duration<double>>(tpost-tnow).count()*1000 << std::endl;\r\n    pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(cloud);\r\n    viewer->updatePointCloud<pcl::PointXYZRGB> (cloud, rgb, \"sample cloud\"); \r\n    \r\n    if(ply_file_indices.size() > 0 ){\r\n        saveCloud(std::string(argv[ply_file_indices[0]]),*cloud,false,false);\r\n        done = true;\r\n    }\r\n  }\r\n\r\n  k2g.shutDown();\r\n  return 0;\r\n}\r\n```\r\n\r\nI'm getting an error as follows:\r\n```\r\n± make\r\nScanning dependencies of target Kinect2Grabber\r\n[ 50%] Building CXX object CMakeFiles/Kinect2Grabber.dir/test.cpp.o\r\nIn file included from /Users/athundt/source/git/libfreenect2pclgrabber/test.cpp:19:\r\n/Users/athundt/source/git/libfreenect2pclgrabber/k2g.h:132:33: warning: using integer\r\n      absolute value function 'abs' when argument is of floating point type\r\n      [-Wabsolute-value]\r\n                                if(!isnan(depth_value) && !(abs(depth_value) < 0.0001)){\r\n                                                            ^\r\n/Users/athundt/source/git/libfreenect2pclgrabber/k2g.h:132:33: note: use function\r\n      'std::abs' instead\r\n                                if(!isnan(depth_value) && !(abs(depth_value) < 0.0001)){\r\n                                                            ^~~\r\n                                                            std::abs\r\n/Users/athundt/source/git/libfreenect2pclgrabber/test.cpp:44:10: error: no matching member\r\n      function for call to 'write'\r\n  writer.write (filename, cloud, Eigen::Vector4f::Zero (), Eigen::Quaternionf::Ide...\r\n  ~~~~~~~^~~~~\r\n/Users/athundt/source/git/libfreenect2pclgrabber/test.cpp:91:9: note: in instantiation of\r\n      function template specialization 'saveCloud<pcl::PointCloud<pcl::PointXYZRGB> >'\r\n      requested here\r\n        saveCloud(std::string(argv[ply_file_indices[0]]),*cloud,false,false);\r\n        ^\r\n/usr/local/include/pcl-1.8/pcl/io/ply_io.h:646:7: note: candidate function not viable: no\r\n      known conversion from 'const pcl::PointCloud<pcl::PointXYZRGB>' to\r\n      'const pcl::PCLPointCloud2' for 2nd argument\r\n      write (const std::string &file_name, const pcl::PCLPointCloud2 &cloud,\r\n      ^\r\n/usr/local/include/pcl-1.8/pcl/io/ply_io.h:669:7: note: candidate function not viable: no\r\n      known conversion from 'const pcl::PointCloud<pcl::PointXYZRGB>' to 'const\r\n      pcl::PCLPointCloud2::ConstPtr' (aka 'const shared_ptr<const ::pcl::PCLPointCloud2>')\r\n      for 2nd argument\r\n      write (const std::string &file_name, const pcl::PCLPointCloud2::ConstPtr &cloud,\r\n      ^\r\n/usr/local/include/pcl-1.8/pcl/io/ply_io.h:687:7: note: candidate function template not\r\n      viable: requires at most 4 arguments, but 6 were provided\r\n      write (const std::string &file_name,\r\n      ^\r\n/usr/local/include/pcl-1.8/pcl/io/ply_io.h:624:7: note: candidate function not viable:\r\n      requires at most 5 arguments, but 6 were provided\r\n      write (const std::string &file_name, const pcl::PCLPointCloud2 &cloud,\r\n      ^\r\n1 warning and 1 error generated.\r\nmake[2]: *** [CMakeFiles/Kinect2Grabber.dir/test.cpp.o] Error 1\r\nmake[1]: *** [CMakeFiles/Kinect2Grabber.dir/all] Error 2\r\nmake: *** [all] Error 2\r\n```\r\n\r\nIn particular I'm not sure how to get the cloud into a format the ply writer will accept. If you perhaps know a little more of PCL I'd appreciate some advice! Once I have it working I'll also send you a pull request for the improved test."},"comment":{"url":"https://api.github.com/repos/giacomodabisias/libfreenect2pclgrabber/issues/comments/154937903","html_url":"https://github.com/giacomodabisias/libfreenect2pclgrabber/issues/11#issuecomment-154937903","issue_url":"https://api.github.com/repos/giacomodabisias/libfreenect2pclgrabber/issues/11","id":154937903,"user":{"login":"ahundt","id":55744,"avatar_url":"https://avatars.githubusercontent.com/u/55744?v=3","gravatar_id":"","url":"https://api.github.com/users/ahundt","html_url":"https://github.com/ahundt","followers_url":"https://api.github.com/users/ahundt/followers","following_url":"https://api.github.com/users/ahundt/following{/other_user}","gists_url":"https://api.github.com/users/ahundt/gists{/gist_id}","starred_url":"https://api.github.com/users/ahundt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahundt/subscriptions","organizations_url":"https://api.github.com/users/ahundt/orgs","repos_url":"https://api.github.com/users/ahundt/repos","events_url":"https://api.github.com/users/ahundt/events{/privacy}","received_events_url":"https://api.github.com/users/ahundt/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T05:36:15Z","updated_at":"2015-11-09T05:36:15Z","body":"It seems to write a file successfully but has some weird properties when I open it with meshlab. In particular many verticies exist at 0,0,0, with faces going to actually detected points. Perhaps this is what is written out for xyz coordinates where nothing is detected (NaN?) Perhaps that is a bug in another part of the function from the original tool (without my modifications) that needs to be fixed?"}}