Problem running PCL algorithm on cloud with custom point type

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem running PCL algorithm on cloud with custom point type

Jun8
Hello,

I created a custom point type called XYZUV. I can read these clouds from a PCD file with no problems. However, when I want to run RANSAC plane segmentationon such a cloud I run into problems.

I read this discussion and the tutorial but still couldn't make it to work.

My user-defined point type is:

struct EIGEN_ALIGN16 PointXYZUV
{
        PCL_ADD_POINT4D;    /
        float u;
        float v;
        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

POINT_CLOUD_REGISTER_POINT_STRUCT (PointXYZUV,          
                                                                        (float, x, x)
                                                                        (float, y, y)
                                                                        (float, z, z)
                                                                        (float, u, u)
                                                                 (float, v, v))

First Approach:
When I add the line

  pcl::SACSegmentation<PointXYZUV> segmentor;

to my code, it compiles fine but I get linker errors. Based on the discussion above, I added the header in imp, so the relevant part of my include is:

#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/segmentation/impl/sac_segmentation.hpp>

This time, I get *a lot* of linker errors, a typical one is:

CMakeFiles/cloud_try.dir/cloud_try.cpp.o:(.rodata._ZTVN3pcl26ProgressiveSampleConsensusI10PointXYZUVEE[vtable for pcl::ProgressiveSampleConsensus<PointXYZUV>]+0x10): undefined reference to `pcl::ProgressiveSampleConsensus<PointXYZUV>::computeModel(int)'

Second Approach
Based on Radu's suggestion in the above thread, I commented the impl/sac_segmentation.hpp include and insttead added the include impl/instantiate.hpp and the line

PCL_INSTANTIATE(pcl::SACSegmentation,PointXYZUV);

This time I get the compilation error

cloud_try/cloud_try.cpp: In function ‘int main(int, char**)’:
cloud_try/cloud_try.cpp:59: error: ‘BOOST_PP_IIF_0’ was not declared in this scope
cloud_try.cpp:59: error: expected ‘;’ before ‘PointXYZUV’
make[2]: *** [CMakeFiles/cloud_try.dir/cloud_try.cpp.o] Error 1
make[1]: *** [CMakeFiles/cloud_try.dir/all] Error 2
make: *** [all] Error 2

How can I make this work? I have attached my code.cloud_try.cpp

Thanks a lot for the help!


 
Reply | Threaded
Open this post in threaded view
|

Re: Problem running PCL algorithm on cloud with custom point type

aichim
Administrator
Hi,


SACSegmentation uses a lot of other classes inside it, so when you
create a custom point type, you have to instantiate all the component
classes with it.

PCL_INSTANTIATE (SACSegmentation, (PointXYZUV));
PCL_INSTANTIATE(SampleConsensusModelPlane, (PointXYZUV));

You would have to do this for all the classes where you get linker
errors. It's not very elegant, but it's a way of doing it.

Hope this helps.

Cheers,
Alex


On 6/20/12 7:17 PM, Jun8 wrote:

> Hello,
>
> I created a custom point type called XYZUV. I can read these clouds from a
> PCD file with no problems. However, when I want to run RANSAC plane
> segmentationon such a cloud I run into problems.
>
> I read
> http://www.pcl-users.org/Creating-new-point-types-td2838631.html#a2841049
> this discussion  and
> http://www.pointclouds.org/documentation/tutorials/adding_custom_ptype.php#how-to-add-a-new-pointt-type
> the tutorial  but still couldn't make it to work.
>
> My user-defined point type is:
>
> struct EIGEN_ALIGN16 PointXYZUV
> {
>          PCL_ADD_POINT4D;    /
>          float u;
>          float v;
>          EIGEN_MAKE_ALIGNED_OPERATOR_NEW
> };
>
> POINT_CLOUD_REGISTER_POINT_STRUCT (PointXYZUV,
>                                                                        
> (float, x, x)
>                                                                        
> (float, y, y)
>                                                                        
> (float, z, z)
>                                                                        
> (float, u, u)
>                                                                  (float, v,
> v))
>
> *First Approach:*
> When I add the line
>
>    pcl::SACSegmentation<PointXYZUV> segmentor;
>
> to my code, it compiles fine but I get linker errors. Based on the
> discussion above, I added the header in imp, so the relevant part of my
> include is:
>
> #include <pcl/segmentation/sac_segmentation.h>
> #include <pcl/segmentation/impl/sac_segmentation.hpp>
>
> This time, I get *a lot* of linker errors, a typical one is:
>
> CMakeFiles/cloud_try.dir/cloud_try.cpp.o:(.rodata._ZTVN3pcl26ProgressiveSampleConsensusI10PointXYZUVEE[vtable
> for pcl::ProgressiveSampleConsensus<PointXYZUV>]+0x10): undefined reference
> to `pcl::ProgressiveSampleConsensus<PointXYZUV>::computeModel(int)'
>
> *Second Approach*
> Based on Radu's suggestion in the above thread, I commented the
> impl/sac_segmentation.hpp include and insttead added the include
> impl/instantiate.hpp and the line
>
> PCL_INSTANTIATE(pcl::SACSegmentation,PointXYZUV);
>
> This time I get the compilation error
>
> cloud_try/cloud_try.cpp: In function ‘int main(int, char**)’:
> cloud_try/cloud_try.cpp:59: error: ‘BOOST_PP_IIF_0’ was not declared in this
> scope
> cloud_try.cpp:59: error: expected ‘;’ before ‘PointXYZUV’
> make[2]: *** [CMakeFiles/cloud_try.dir/cloud_try.cpp.o] Error 1
> make[1]: *** [CMakeFiles/cloud_try.dir/all] Error 2
> make: *** [all] Error 2
>
> How can I make this work? I have attached my code.
> http://www.pcl-users.org/file/n4019488/cloud_try.cpp cloud_try.cpp
>
> Thanks a lot for the help!
>
>
>    
>
> --
> View this message in context: http://www.pcl-users.org/Problem-running-PCL-algorithm-on-cloud-with-custom-point-type-tp4019488.html
> Sent from the Point Cloud Library (PCL) Users mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem running PCL algorithm on cloud with custom point type

Jun8
Thanks for the answer. Howeber, when I use the PCL_INSTANTIATE macro I get the following compilation error:

error: ‘BOOST_PP_IIF_0’ was not declared in this scope

I have included the following headers

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/segmentation/impl/sac_segmentation.hpp>
#include <pcl/ModelCoefficients.h>
#include <pcl/common/common.h>
#include <pcl/impl/instantiate.hpp>

which one am I missing?

Thanks!

C
Reply | Threaded
Open this post in threaded view
|

Re: Problem running PCL algorithm on cloud with custom point type

Radu B Rusu
Administrator
In reply to this post by aichim
Alternatively, you can always include the HPP files in your code. See
http://www.pointclouds.org/documentation/tutorials/adding_custom_ptype.php#how-to-add-a-new-pointt-type for an explanation.

Cheers,
Radu.

On 06/20/2012 10:51 AM, Alexandru Eugen Ichim wrote:

> Hi,
>
>
> SACSegmentation uses a lot of other classes inside it, so when you create a custom point type, you have to instantiate
> all the component classes with it.
>
> PCL_INSTANTIATE (SACSegmentation, (PointXYZUV));
> PCL_INSTANTIATE(SampleConsensusModelPlane, (PointXYZUV));
>
> You would have to do this for all the classes where you get linker errors. It's not very elegant, but it's a way of
> doing it.
>
> Hope this helps.
>
> Cheers,
> Alex
>
>
> On 6/20/12 7:17 PM, Jun8 wrote:
>> Hello,
>>
>> I created a custom point type called XYZUV. I can read these clouds from a
>> PCD file with no problems. However, when I want to run RANSAC plane
>> segmentationon such a cloud I run into problems.
>>
>> I read
>> http://www.pcl-users.org/Creating-new-point-types-td2838631.html#a2841049
>> this discussion and
>> http://www.pointclouds.org/documentation/tutorials/adding_custom_ptype.php#how-to-add-a-new-pointt-type
>> the tutorial but still couldn't make it to work.
>>
>> My user-defined point type is:
>>
>> struct EIGEN_ALIGN16 PointXYZUV
>> {
>> PCL_ADD_POINT4D; /
>> float u;
>> float v;
>> EIGEN_MAKE_ALIGNED_OPERATOR_NEW
>> };
>>
>> POINT_CLOUD_REGISTER_POINT_STRUCT (PointXYZUV,
>> (float, x, x)
>> (float, y, y)
>> (float, z, z)
>> (float, u, u)
>> (float, v,
>> v))
>>
>> *First Approach:*
>> When I add the line
>>
>> pcl::SACSegmentation<PointXYZUV> segmentor;
>>
>> to my code, it compiles fine but I get linker errors. Based on the
>> discussion above, I added the header in imp, so the relevant part of my
>> include is:
>>
>> #include <pcl/segmentation/sac_segmentation.h>
>> #include <pcl/segmentation/impl/sac_segmentation.hpp>
>>
>> This time, I get *a lot* of linker errors, a typical one is:
>>
>> CMakeFiles/cloud_try.dir/cloud_try.cpp.o:(.rodata._ZTVN3pcl26ProgressiveSampleConsensusI10PointXYZUVEE[vtable
>> for pcl::ProgressiveSampleConsensus<PointXYZUV>]+0x10): undefined reference
>> to `pcl::ProgressiveSampleConsensus<PointXYZUV>::computeModel(int)'
>>
>> *Second Approach*
>> Based on Radu's suggestion in the above thread, I commented the
>> impl/sac_segmentation.hpp include and insttead added the include
>> impl/instantiate.hpp and the line
>>
>> PCL_INSTANTIATE(pcl::SACSegmentation,PointXYZUV);
>>
>> This time I get the compilation error
>>
>> cloud_try/cloud_try.cpp: In function ‘int main(int, char**)’:
>> cloud_try/cloud_try.cpp:59: error: ‘BOOST_PP_IIF_0’ was not declared in this
>> scope
>> cloud_try.cpp:59: error: expected ‘;’ before ‘PointXYZUV’
>> make[2]: *** [CMakeFiles/cloud_try.dir/cloud_try.cpp.o] Error 1
>> make[1]: *** [CMakeFiles/cloud_try.dir/all] Error 2
>> make: *** [all] Error 2
>>
>> How can I make this work? I have attached my code.
>> http://www.pcl-users.org/file/n4019488/cloud_try.cpp cloud_try.cpp
>>
>> Thanks a lot for the help!
>>
>>
>>
>> --
>> View this message in context:
>> http://www.pcl-users.org/Problem-running-PCL-algorithm-on-cloud-with-custom-point-type-tp4019488.html
>> Sent from the Point Cloud Library (PCL) Users mailing list archive at Nabble.com.
>> _______________________________________________
>> [hidden email] / http://pointclouds.org
>> http://pointclouds.org/mailman/listinfo/pcl-users
>
>
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users