lundi 23 décembre 2019

How to create the function fromPCL in PCL library with CUDA

I'm trying to use the cuda capabilities in PCL. My goal is to be able to transfer a point cloud into the GPU and perform some cuda operations. The PCL repo has a function called fromPCL(link to the .cu file) that it isn't implemented, but in the source file it has an implementation that it is not 100% correct. I'm trying to compile uncommenting these lines, but I get an error when using the thrust::copy function in line 60:

 thrust::copy (output.points.begin(), output.points.end(), input.points.begin());

The error is below:

/opt/cuda/include/thrust/system/detail/sequential/general_copy.h(91): error: no operator "=" matches these operands
            operand types are: const pcl::PointXYZRGB = value_type
          detected during:
            instantiation of "thrust::detail::disable_if<thrust::system::detail::sequential::general_copy_detail::reference_is_assignable<InputIterator, OutputIterator>::value, void>::type thrust::system::detail::sequential::general_copy_detail::iter_assign(OutputIterator, InputIterator) [with OutputIterator=__gnu_cxx::__normal_iterator<std::__allocator_traits_base::__c_pointer<Eigen::aligned_allocator<pcl::PointXYZRGB>>, std::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB>>>, InputIterator=thrust::detail::normal_iterator<pcl::cuda::PointXYZRGB *>]" 
(112): here
            instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator<pcl::cuda::PointXYZRGB *>, OutputIterator=__gnu_cxx::__normal_iterator<std::__allocator_traits_base::__c_pointer<Eigen::aligned_allocator<pcl::PointXYZRGB>>, std::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB>>>]" 
/opt/cuda/include/thrust/system/detail/sequential/copy.inl(74): here
            instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator<pcl::cuda::PointXYZRGB *>, OutputIterator=__gnu_cxx::__normal_iterator<std::__allocator_traits_base::__c_pointer<Eigen::aligned_allocator<pcl::PointXYZRGB>>, std::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB>>>]" 
/opt/cuda/include/thrust/system/detail/sequential/copy.inl(121): here
            instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy<DerivedPolicy> &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::system::cpp::detail::tag, InputIterator=thrust::detail::normal_iterator<pcl::cuda::PointXYZRGB *>, OutputIterator=__gnu_cxx::__normal_iterator<std::__allocator_traits_base::__c_pointer<Eigen::aligned_allocator<pcl::PointXYZRGB>>, std::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB>>>]" 
/opt/cuda/include/thrust/detail/copy.inl(37): here
            instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base<System> &, InputIterator, InputIterator, OutputIterator) [with System=thrust::system::cpp::detail::tag, InputIterator=thrust::detail::normal_iterator<pcl::cuda::PointXYZRGB *>, OutputIterator=__gnu_cxx::__normal_iterator<std::__allocator_traits_base::__c_pointer<Eigen::aligned_allocator<pcl::PointXYZRGB>>, std::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB>>>]" 
/opt/cuda/include/thrust/detail/copy.inl(72): here
            instantiation of "OutputIterator thrust::detail::two_system_copy(const thrust::execution_policy<FromSystem> &, const thrust::execution_policy<ToSystem> &, InputIterator, InputIterator, OutputIterator) [with FromSystem=thrust::system::cpp::detail::tag, ToSystem=thrust::system::cpp::detail::tag, InputIterator=thrust::detail::normal_iterator<pcl::cuda::PointXYZRGB *>, OutputIterator=__gnu_cxx::__normal_iterator<std::__allocator_traits_base::__c_pointer<Eigen::aligned_allocator<pcl::PointXYZRGB>>, std::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB>>>]" 
/opt/cuda/include/thrust/detail/copy.inl(110): here
            instantiation of "OutputIterator thrust::copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator<pcl::cuda::PointXYZRGB *>, OutputIterator=__gnu_cxx::__normal_iterator<std::__allocator_traits_base::__c_pointer<Eigen::aligned_allocator<pcl::PointXYZRGB>>, std::vector<pcl::PointXYZRGB, Eigen::aligned_allocator<pcl::PointXYZRGB>>>]" 
/home/Lavy.David/Libraries/pcl-pcl-1.9.0/cuda/io/src/cloud_from_pcl.cu(61): here

1 error detected in the compilation of "/tmp/tmpxft_000049e6_00000000-15_cloud_from_pcl.compute_75.cpp1.ii".
CMake Error at pcl_cuda_io_generated_cloud_from_pcl.cu.o.RelWithDebInfo.cmake:279 (message):
  Error generating file
  /home/Lavy.David/Libraries/pcl-pcl-1.9.0/build_ni/cuda/io/CMakeFiles/pcl_cuda_io.dir/src/./pcl_cuda_io_generated_cloud_from_pcl.cu.o


cuda/io/CMakeFiles/pcl_cuda_io.dir/build.make:3186: recipe for target 'cuda/io/CMakeFiles/pcl_cuda_io.dir/src/pcl_cuda_io_generated_cloud_from_pcl.cu.o' failed
make[2]: *** [cuda/io/CMakeFiles/pcl_cuda_io.dir/src/pcl_cuda_io_generated_cloud_from_pcl.cu.o] Error 1
CMakeFiles/Makefile2:5523: recipe for target 'cuda/io/CMakeFiles/pcl_cuda_io.dir/all' failed
make[1]: *** [cuda/io/CMakeFiles/pcl_cuda_io.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

Trying to debug it, it seems that the output and input types are not matching, as I am comparing a const pcl::PointXYZRGB (seems this is coming from the input variable) with a value_type (seems this is coming from the output variable). This goes a bit more than my C++ and PCL knowledge, but how would I go and cast the output variable to not be value_type?

Thank you in advance

Aucun commentaire:

Enregistrer un commentaire