GeoPCL

geospatial extensions for PCL

Tutorial

Getting started with GeoPCL is easy! GeoPCL can be used in two different ways. Some functionality can even be used without needing to build any libraries. Others will need to be compiled ahead of time. This tutorial will step you through an example of each.

Header Only (LAS to PCD conversion)

The LAStoPCD conversion routine can be accessed by simply including LAStoPCD.hpp in your source. You will need to have previously built and installed both libLAS and PCL, and will need to link your program against each of these. A very simple example of this is shown below (this example is included in the distribution as apps/LAStoPCD.cpp).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

#include <liblas/liblas.hpp>

#include <geopcl/io/LAStoPCD.hpp>

int main(int argc, char **argv)
{
  if (argc < 3)
  {
    std::cerr << "Required arguments: input.las output.pcd" << std::endl;
    return 1;
  }

  std::string input = argv[1];
  std::string output = argv[2];

  std::cout << "Reading " << input << " and writing " << output << std::endl;

  pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);

  liblas::Header header;
  geopcl::LAStoPCD(input, header, *cloud);

  pcl::io::savePCDFileASCII(output.c_str(), *cloud);

  return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
find_package(PCL 1.6 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

find_package(LibLAS 1.6 REQUIRED)
include_directories(${LIBLAS_INCLUDE_DIRS})
link_directories(${LIBLAS_LIBRARY_DIRS})
add_definitions(${LIBLAS_DEFINITIONS})

include_directories(${CMAKE_SOURCE_DIR}/io/include)

set(LASTOPCD lastopcd)
add_executable(${LASTOPCD} apps/LAStoPCD.cpp)
target_link_libraries(${LASTOPCD} ${PCL_LIBRARIES} ${LIBLAS_LIBRARY})