2018-01-02:Concatenate the points of two Point Clouds

concatenate denotes series connection, in this tutorial, we will show concatenate two points and concatenate two fields.

  • concatenate two fields:
    This means that two point clouds should have the same number of points.

  • concatenate two points:
    This means taht two point clouds should have the same number of fields and the same data type of every field.


main.cpp

#include
#include
#include

int main(int argc, char** argv)
{
    if(argc!=2)
    {
        std::cerr<<"Please specify command line argument '-f' or '-p'"< cloud_a, cloud_b, cloud_c;
    pcl::PointCloud n_cloud_b;
    pcl::PointCloud p_n_cloud_c;

    cloud_a.width=5;
    cloud_a.height=cloud_b.height=n_cloud_b.height=1;
    cloud_a.points.resize(cloud_a.width*cloud_a.height);

    if(strcmp(argv[1],"-p")==0)
    {
        cloud_b.width=3;
        cloud_b.points.resize(cloud_b.width*cloud_b.height);
    }

    else if(strcmp(argv[1], "-f")==0)
    {
        n_cloud_b.width=5;
        n_cloud_b.points.resize(n_cloud_b.width*n_cloud_b.height);
    }

    else
    {
        std::cerr<<"Unknown argument!Please specify '-p' or '-f'"<

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

project(concatenate_points)
find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES})

The execute results are as follows:


2018-01-02:Concatenate the points of two Point Clouds_第1张图片
Screenshot from 2018-01-02 20-07-52.png
2018-01-02:Concatenate the points of two Point Clouds_第2张图片
Screenshot from 2018-01-02 20-08-12.png

你可能感兴趣的:(2018-01-02:Concatenate the points of two Point Clouds)