Pcl: ICP runs error in VS2017

Created on 26 Dec 2017  路  11Comments  路  Source: PointCloudLibrary/pcl

The code is

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/registration/icp.h>

int
main(int argc, char** argv)
{
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in(new pcl::PointCloud<pcl::PointXYZ>);
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out(new pcl::PointCloud<pcl::PointXYZ>);

    // Fill in the CloudIn data
    cloud_in->width = 5;
    cloud_in->height = 1;
    cloud_in->is_dense = false;
    cloud_in->points.resize(cloud_in->width * cloud_in->height);
    for (size_t i = 0; i < cloud_in->points.size(); ++i)
    {
        cloud_in->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
        cloud_in->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
        cloud_in->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
    }
    std::cout << "Saved " << cloud_in->points.size() << " data points to input:"
        << std::endl;
    for (size_t i = 0; i < cloud_in->points.size(); ++i) std::cout << "    " <<
        cloud_in->points[i].x << " " << cloud_in->points[i].y << " " <<
        cloud_in->points[i].z << std::endl;
    *cloud_out = *cloud_in;
    std::cout << "size:" << cloud_out->points.size() << std::endl;
    for (size_t i = 0; i < cloud_in->points.size(); ++i)
        cloud_out->points[i].x = cloud_in->points[i].x + 0.7f;
    std::cout << "Transformed " << cloud_in->points.size() << " data points:"
        << std::endl;
    for (size_t i = 0; i < cloud_out->points.size(); ++i)
        std::cout << "    " << cloud_out->points[i].x << " " <<
        cloud_out->points[i].y << " " << cloud_out->points[i].z << std::endl;
    pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
    icp.setInputCloud(cloud_in);
    icp.setInputTarget(cloud_out);
    pcl::PointCloud<pcl::PointXYZ> Final;
    icp.align(Final);
    std::cout << "has converged:" << icp.hasConverged() << " score: " <<
        icp.getFitnessScore() << std::endl;
    std::cout << icp.getFinalTransformation() << std::endl;

    return (0);
}

I install the released code MSVC2017 all-in-one, Windows 10. I run the code in VS2017 x64, and I got the following error:

1>c:program filespcl 1.8.13rdpartyboostincludeboost-1_64boosttypeofmsvctypeof_impl.hpp(125): error C2143: syntax error: missing ';' before '<'
1>c:program filespcl 1.8.13rdpartyboostincludeboost-1_64boosttypeofmsvctypeof_impl.hpp(125): error C2913: explicit specialization; 'boost::type_of::id2type_impl' is not a specialization of a class template

1>c:program filespcl 1.8.13rdpartyboostincludeboost-1_64boosttypeofmsvctypeof_impl.hpp(125): error C2059: syntax error: '<'
1>c:program filespcl 1.8.13rdpartyboostincludeboost-1_64boosttypeofmsvctypeof_impl.hpp(126): error C2334: unexpected token(s) preceding '{'; skipping apparent function body

Maintainer Edit: Formatting

Most helpful comment

Because another guy faces the same problem, it seems some value to post my solution. I found the reason is related to boost. I solve the problem by defining "BOOST_TYPEOF_EMULATION" before including icp.h.

Therefore, to use correctly icp in VS2017, you should use icp like following:

#define BOOST_TYPEOF_EMULATION
#include <pcl/registration/icp.h>

All 11 comments

Please update Visual Studio 2017 to 15.5.

BTW, Please use markdown correctly. The wrong markup is difficult to read.
I recommend that you check displayed correctly in preview.
https://help.github.com/articles/creating-and-highlighting-code-blocks/#fenced-code-blocks

Please update Visual Studio 2017 to 15.5.

Is this a VS bug? (meaning can we close this?)

I think it is a bug in older version of Visual C++ 2017.
It is able to build with latest version.
(Yes, We can close this issue.)

@XiaoshuiHuang If this problem is not resolved, Please reopen this issue.

Hi,I recieved the same error as @XiaoshuiHuang ,but my Visual Studio 2017 is 15.6.6, with pcl 1.8.1,MSVC2017 all-in-one, win10.

Because another guy faces the same problem, it seems some value to post my solution. I found the reason is related to boost. I solve the problem by defining "BOOST_TYPEOF_EMULATION" before including icp.h.

Therefore, to use correctly icp in VS2017, you should use icp like following:

#define BOOST_TYPEOF_EMULATION
#include <pcl/registration/icp.h>

@XiaoshuiHuang My problem solved,thank you.

Got same issue...
@XiaoshuiHuang You save me.

@XiaoshuiHuang Thank you, this solved the problem.

I got the same problem.
Update Visual Studio 2017 to the latest 15.9.22 doesn't help.
@XiaoshuiHuang 's answer solved my problem.
So, it is possibly still a pcl bug. @UnaNancyOwen

Did you try this on PCL 1.10.1 (or master)?

PCL doesn't use Boost typeof directly, so it's not an issue with PCL

With pcl 1.8.1-MSVC2017-all-in-one, win10. @kunaltyagi

Was this page helpful?
0 / 5 - 0 ratings