├── CMakeLists.txt ├── Doxyfile.in ├── LICENSE.txt ├── PCLConfig.cmake.in ├── PCLConfigVersion.cmake.in ├── cmake ├── CMakeParseArguments.cmake ├── CudaComputeTargetFlags.cmake ├── Modules │ ├── FindEigen.cmake │ ├── FindFlann.cmake │ ├── FindGLEW.cmake │ ├── FindMPI.cmake │ ├── FindOpenNI.cmake │ ├── FindQhull.cmake │ ├── FindSphinx.cmake │ └── NSIS.template.in ├── cpack_options.cmake.in ├── dep_graph.cmake ├── merge_cmake_install.py ├── pcl_all_in_one_installer.cmake ├── pcl_cpack.cmake ├── pcl_examples.cmake ├── pcl_find_boost.cmake ├── pcl_find_python.cmake ├── pcl_find_sse.cmake ├── pcl_openmp.cmake ├── pcl_options.cmake ├── pcl_pclconfig.cmake ├── pcl_targets.cmake ├── pcl_tests.cmake ├── pcl_utils.cmake ├── pkgconfig.cmake.in └── uninstall_target.cmake.in ├── core ├── CMakeLists.txt ├── include │ └── pcl2 │ │ ├── cloud.h │ │ ├── conversions.h │ │ ├── core.h │ │ ├── create.h │ │ ├── eigen_math.h │ │ ├── eigen_matrix.h │ │ ├── eigen_matrix_impl.h │ │ ├── exception.h │ │ ├── impl │ │ ├── eigen_math.hpp │ │ ├── eigen_matrix.hpp │ │ ├── eigen_matrix_impl.hpp │ │ ├── math.hpp │ │ ├── matrix_row_impl.hpp │ │ ├── matrix_view_impl.hpp │ │ ├── row.hpp │ │ ├── stats.hpp │ │ └── typed_matrix.hpp │ │ ├── kernels.h │ │ ├── math.h │ │ ├── matrix.h │ │ ├── matrix_impl.h │ │ ├── matrix_row_impl.h │ │ ├── matrix_view_impl.h │ │ ├── pcl_macros.h │ │ ├── row.h │ │ ├── spatial_index.h │ │ ├── stats.h │ │ ├── typed_matrix.h │ │ └── typed_matrix_impl.h └── src │ ├── cloud.cpp │ ├── conversions.cpp │ ├── eigen_matrix.cpp │ ├── math.cpp │ ├── matrix.cpp │ ├── row.cpp │ └── stats.cpp ├── data └── bunny.pcd ├── doc └── Mainpage.dox ├── features └── include │ └── pcl2 │ └── features │ └── normals.h ├── io ├── CMakeLists.txt ├── include │ └── pcl2 │ │ └── io │ │ └── io.h └── src │ └── io.cpp ├── pcl2_config.h.in ├── registration ├── CMakeLists.txt ├── include │ └── pcl2 │ │ └── registration │ │ ├── correspondence_identification.h │ │ ├── fit.h │ │ ├── icp.h │ │ ├── impl │ │ └── fit.hpp │ │ └── transform.h └── src │ ├── fit.cpp │ ├── icp.cpp │ └── transform.cpp ├── search ├── CMakeLists.txt ├── include │ └── pcl2 │ │ └── search │ │ ├── kdtree.h │ │ └── neighbors.h └── src │ └── neighbors.cpp └── tools ├── CMakeLists.txt ├── cloud_intro.cpp ├── mat_intro.cpp ├── pcl2_test.cpp └── rst_test.cpp /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Point Cloud Library (PCL) - www.pointclouds.org 4 | Copyright (c) 2009-2011, Willow Garage, Inc. 5 | Copyright (c) XXX, respective authors. 6 | 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions 11 | are met: 12 | 13 | * Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above 16 | copyright notice, this list of conditions and the following 17 | disclaimer in the documentation and/or other materials provided 18 | with the distribution. 19 | * Neither the name of Willow Garage, Inc. nor the names of its 20 | contributors may be used to endorse or promote products derived 21 | from this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | POSSIBILITY OF SUCH DAMAGE. 35 | -------------------------------------------------------------------------------- /PCLConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 2 | 3 | set(PACKAGE_VERSION @PCL_VERSION@) 4 | 5 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 6 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 7 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 8 | else() 9 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 10 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 11 | set(PACKAGE_VERSION_EXACT TRUE) 12 | endif() 13 | endif() -------------------------------------------------------------------------------- /cmake/CMakeParseArguments.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE_PARSE_ARGUMENTS( args...) 2 | # 3 | # CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for 4 | # parsing the arguments given to that macro or function. 5 | # It processes the arguments and defines a set of variables which hold the 6 | # values of the respective options. 7 | # 8 | # The argument contains all options for the respective macro, 9 | # i.e. keywords which can be used when calling the macro without any value 10 | # following, like e.g. the OPTIONAL keyword of the install() command. 11 | # 12 | # The argument contains all keywords for this macro 13 | # which are followed by one value, like e.g. DESTINATION keyword of the 14 | # install() command. 15 | # 16 | # The argument contains all keywords for this macro 17 | # which can be followed by more than one value, like e.g. the TARGETS or 18 | # FILES keywords of the install() command. 19 | # 20 | # When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the 21 | # keywords listed in , and 22 | # a variable composed of the given 23 | # followed by "_" and the name of the respective keyword. 24 | # These variables will then hold the respective value from the argument list. 25 | # For the keywords this will be TRUE or FALSE. 26 | # 27 | # All remaining arguments are collected in a variable 28 | # _UNPARSED_ARGUMENTS, this can be checked afterwards to see whether 29 | # your macro was called with unrecognized parameters. 30 | # 31 | # As an example here a my_install() macro, which takes similar arguments as the 32 | # real install() command: 33 | # 34 | # function(MY_INSTALL) 35 | # set(options OPTIONAL FAST) 36 | # set(oneValueArgs DESTINATION RENAME) 37 | # set(multiValueArgs TARGETS CONFIGURATIONS) 38 | # cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) 39 | # ... 40 | # 41 | # Assume my_install() has been called like this: 42 | # my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) 43 | # 44 | # After the cmake_parse_arguments() call the macro will have set the following 45 | # variables: 46 | # MY_INSTALL_OPTIONAL = TRUE 47 | # MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() 48 | # MY_INSTALL_DESTINATION = "bin" 49 | # MY_INSTALL_RENAME = "" (was not used) 50 | # MY_INSTALL_TARGETS = "foo;bar" 51 | # MY_INSTALL_CONFIGURATIONS = "" (was not used) 52 | # MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" 53 | # 54 | # You can the continue and process these variables. 55 | # 56 | # Keywords terminate lists of values, e.g. if directly after a one_value_keyword 57 | # another recognized keyword follows, this is interpreted as the beginning of 58 | # the new option. 59 | # E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in 60 | # MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would 61 | # be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. 62 | 63 | #============================================================================= 64 | # Copyright 2010 Alexander Neundorf 65 | # 66 | # Distributed under the OSI-approved BSD License (the "License"); 67 | # see accompanying file Copyright.txt for details. 68 | # 69 | # This software is distributed WITHOUT ANY WARRANTY; without even the 70 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 71 | # See the License for more information. 72 | #============================================================================= 73 | # (To distribute this file outside of CMake, substitute the full 74 | # License text for the above reference.) 75 | 76 | 77 | if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) 78 | return() 79 | endif() 80 | set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) 81 | 82 | 83 | function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) 84 | # first set all result variables to empty/FALSE 85 | foreach(arg_name ${_singleArgNames} ${_multiArgNames}) 86 | set(${prefix}_${arg_name}) 87 | endforeach(arg_name) 88 | 89 | foreach(option ${_optionNames}) 90 | set(${prefix}_${option} FALSE) 91 | endforeach(option) 92 | 93 | set(${prefix}_UNPARSED_ARGUMENTS) 94 | 95 | set(insideValues FALSE) 96 | set(currentArgName) 97 | 98 | # now iterate over all arguments and fill the result variables 99 | foreach(currentArg ${ARGN}) 100 | list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword 101 | list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword 102 | list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword 103 | 104 | if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) 105 | if(insideValues) 106 | if("${insideValues}" STREQUAL "SINGLE") 107 | set(${prefix}_${currentArgName} ${currentArg}) 108 | set(insideValues FALSE) 109 | elseif("${insideValues}" STREQUAL "MULTI") 110 | list(APPEND ${prefix}_${currentArgName} ${currentArg}) 111 | endif() 112 | else(insideValues) 113 | list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) 114 | endif(insideValues) 115 | else() 116 | if(NOT ${optionIndex} EQUAL -1) 117 | set(${prefix}_${currentArg} TRUE) 118 | set(insideValues FALSE) 119 | elseif(NOT ${singleArgIndex} EQUAL -1) 120 | set(currentArgName ${currentArg}) 121 | set(${prefix}_${currentArgName}) 122 | set(insideValues "SINGLE") 123 | elseif(NOT ${multiArgIndex} EQUAL -1) 124 | set(currentArgName ${currentArg}) 125 | set(${prefix}_${currentArgName}) 126 | set(insideValues "MULTI") 127 | endif() 128 | endif() 129 | 130 | endforeach(currentArg) 131 | 132 | # propagate the result variables to the caller: 133 | foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) 134 | set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) 135 | endforeach(arg_name) 136 | set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) 137 | 138 | endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) 139 | -------------------------------------------------------------------------------- /cmake/CudaComputeTargetFlags.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Compute target flags macros by Anatoly Baksheev 3 | # 4 | # Usage in CmakeLists.txt: 5 | # include(CudaComputeTargetFlags.cmake) 6 | # APPEND_TARGET_ARCH_FLAGS() 7 | 8 | #compute flags macros 9 | MACRO(CUDA_COMPUTE_TARGET_FLAGS arch_bin arch_ptx cuda_nvcc_target_flags) 10 | string(REGEX REPLACE "\\." "" ARCH_BIN_WITHOUT_DOTS "${${arch_bin}}") 11 | string(REGEX REPLACE "\\." "" ARCH_PTX_WITHOUT_DOTS "${${arch_ptx}}") 12 | 13 | set(cuda_computer_target_flags_temp "") 14 | 15 | # Tell NVCC to add binaries for the specified GPUs 16 | string(REGEX MATCHALL "[0-9()]+" ARCH_LIST "${ARCH_BIN_WITHOUT_DOTS}") 17 | foreach(ARCH IN LISTS ARCH_LIST) 18 | if (ARCH MATCHES "([0-9]+)\\(([0-9]+)\\)") 19 | # User explicitly specified PTX for the concrete BIN 20 | set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1}) 21 | else() 22 | # User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN 23 | set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${ARCH},code=sm_${ARCH}) 24 | endif() 25 | endforeach() 26 | 27 | # Tell NVCC to add PTX intermediate code for the specified architectures 28 | string(REGEX MATCHALL "[0-9]+" ARCH_LIST "${ARCH_PTX_WITHOUT_DOTS}") 29 | foreach(ARCH IN LISTS ARCH_LIST) 30 | set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${ARCH},code=compute_${ARCH}) 31 | endforeach() 32 | 33 | set(${cuda_nvcc_target_flags} ${cuda_computer_target_flags_temp}) 34 | ENDMACRO() 35 | 36 | MACRO(APPEND_TARGET_ARCH_FLAGS) 37 | set(cuda_nvcc_target_flags "") 38 | CUDA_COMPUTE_TARGET_FLAGS(CUDA_ARCH_BIN CUDA_ARCH_PTX cuda_nvcc_target_flags) 39 | if (cuda_nvcc_target_flags) 40 | message(STATUS "CUDA NVCC target flags: ${cuda_nvcc_target_flags}") 41 | list(APPEND CUDA_NVCC_FLAGS ${cuda_nvcc_target_flags}) 42 | endif() 43 | ENDMACRO() -------------------------------------------------------------------------------- /cmake/Modules/FindEigen.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find Eigen3 3 | # 4 | # This sets the following variables: 5 | # EIGEN_FOUND - True if Eigen was found. 6 | # EIGEN_INCLUDE_DIRS - Directories containing the Eigen include files. 7 | # EIGEN_DEFINITIONS - Compiler flags for Eigen. 8 | 9 | find_package(PkgConfig) 10 | pkg_check_modules(PC_EIGEN eigen3) 11 | set(EIGEN_DEFINITIONS ${PC_EIGEN_CFLAGS_OTHER}) 12 | 13 | find_path(EIGEN_INCLUDE_DIR Eigen/Core 14 | HINTS ${PC_EIGEN_INCLUDEDIR} ${PC_EIGEN_INCLUDE_DIRS} "${EIGEN_ROOT}" "$ENV{EIGEN_ROOT}" 15 | PATHS "$ENV{PROGRAMFILES}/Eigen" "$ENV{PROGRAMW6432}/Eigen" 16 | "$ENV{PROGRAMFILES}/Eigen 3.0.0" "$ENV{PROGRAMW6432}/Eigen 3.0.0" 17 | PATH_SUFFIXES eigen3 include/eigen3 include) 18 | 19 | set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR}) 20 | 21 | include(FindPackageHandleStandardArgs) 22 | find_package_handle_standard_args(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIR) 23 | 24 | mark_as_advanced(EIGEN_INCLUDE_DIR) 25 | 26 | if(EIGEN_FOUND) 27 | message(STATUS "Eigen found (include: ${EIGEN_INCLUDE_DIRS})") 28 | endif(EIGEN_FOUND) 29 | 30 | -------------------------------------------------------------------------------- /cmake/Modules/FindFlann.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find Flann 3 | # 4 | # This sets the following variables: 5 | # FLANN_FOUND - True if FLANN was found. 6 | # FLANN_INCLUDE_DIRS - Directories containing the FLANN include files. 7 | # FLANN_LIBRARIES - Libraries needed to use FLANN. 8 | # FLANN_DEFINITIONS - Compiler flags for FLANN. 9 | 10 | find_package(PkgConfig) 11 | pkg_check_modules(PC_FLANN flann) 12 | set(FLANN_DEFINITIONS ${PC_FLANN_CFLAGS_OTHER}) 13 | 14 | find_path(FLANN_INCLUDE_DIR flann/flann.hpp 15 | HINTS ${PC_FLANN_INCLUDEDIR} ${PC_FLANN_INCLUDE_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}" 16 | PATHS "$ENV{PROGRAMFILES}/Flann" "$ENV{PROGRAMW6432}/Flann" 17 | "$ENV{PROGRAMFILES}/flann 1.6.9" "$ENV{PROGRAMW6432}/flann 1.6.9" 18 | PATH_SUFFIXES include) 19 | 20 | # Prefer static libraries in Windows over shared ones 21 | if(WIN32) 22 | find_library(FLANN_LIBRARY 23 | NAMES flann_cpp_s flann_cpp 24 | HINTS ${PC_FLANN_LIBDIR} ${PC_FLANN_LIBRARY_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}" 25 | PATHS "$ENV{PROGRAMFILES}/Flann" "$ENV{PROGRAMW6432}/Flann" 26 | "$ENV{PROGRAMFILES}/flann 1.6.9" "$ENV{PROGRAMW6432}/flann 1.6.9" 27 | PATH_SUFFIXES lib) 28 | 29 | find_library(FLANN_LIBRARY_DEBUG 30 | NAMES flann_cpp_s-gd flann_cpp-gd flann_cpp_s flann_cpp 31 | HINTS ${PC_FLANN_LIBDIR} ${PC_FLANN_LIBRARY_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}" 32 | PATHS "$ENV{PROGRAMFILES}/Flann" "$ENV{PROGRAMW6432}/Flann" 33 | "$ENV{PROGRAMFILES}/flann 1.6.9" "$ENV{PROGRAMW6432}/flann 1.6.9" 34 | PATH_SUFFIXES lib) 35 | else(WIN32) 36 | find_library(FLANN_LIBRARY 37 | NAMES flann_cpp 38 | HINTS ${PC_FLANN_LIBDIR} ${PC_FLANN_LIBRARY_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}" 39 | PATH_SUFFIXES lib) 40 | 41 | find_library(FLANN_LIBRARY_DEBUG 42 | NAMES flann_cpp-gd flann_cpp 43 | HINTS ${PC_FLANN_LIBDIR} ${PC_FLANN_LIBRARY_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}" 44 | PATH_SUFFIXES lib) 45 | endif(WIN32) 46 | 47 | if(NOT FLANN_LIBRARY_DEBUG) 48 | set(FLANN_LIBRARY_DEBUG ${FLANN_LIBRARY}) 49 | endif(NOT FLANN_LIBRARY_DEBUG) 50 | 51 | set(FLANN_INCLUDE_DIRS ${FLANN_INCLUDE_DIR}) 52 | set(FLANN_LIBRARIES optimized ${FLANN_LIBRARY} debug ${FLANN_LIBRARY_DEBUG}) 53 | 54 | include(FindPackageHandleStandardArgs) 55 | find_package_handle_standard_args(Flann DEFAULT_MSG 56 | FLANN_LIBRARY FLANN_INCLUDE_DIR) 57 | 58 | mark_as_advanced(FLANN_LIBRARY FLANN_LIBRARY_DEBUG FLANN_INCLUDE_DIR) 59 | 60 | if(FLANN_FOUND) 61 | message(STATUS "FLANN found (include: ${FLANN_INCLUDE_DIRS}, lib: ${FLANN_LIBRARIES})") 62 | if(WIN32) 63 | get_filename_component(flann_lib ${FLANN_LIBRARY} NAME_WE) 64 | if("${flann_lib}" STREQUAL "flann_cpp_s") 65 | add_definitions(-DFLANN_STATIC) 66 | endif("${flann_lib}" STREQUAL "flann_cpp_s") 67 | endif(WIN32) 68 | endif(FLANN_FOUND) 69 | 70 | -------------------------------------------------------------------------------- /cmake/Modules/FindGLEW.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009 Boudewijn Rempt 2 | # 3 | # Redistribution and use is allowed according to the terms of the BSD license. 4 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 5 | # 6 | # - try to find glew library and include files 7 | # GLEW_INCLUDE_DIR, where to find GL/glew.h, etc. 8 | # GLEW_LIBRARIES, the libraries to link against 9 | # GLEW_FOUND, If false, do not try to use GLEW. 10 | # Also defined, but not for general use are: 11 | # GLEW_GLEW_LIBRARY = the full path to the glew library. 12 | 13 | IF (WIN32) 14 | 15 | IF(CYGWIN) 16 | 17 | FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h) 18 | 19 | FIND_LIBRARY( GLEW_GLEW_LIBRARY glew32 20 | ${OPENGL_LIBRARY_DIR} 21 | /usr/lib/w32api 22 | /usr/X11R6/lib 23 | ) 24 | 25 | 26 | ELSE(CYGWIN) 27 | 28 | FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h 29 | $ENV{GLEW_ROOT_PATH}/include 30 | ) 31 | 32 | FIND_LIBRARY( GLEW_GLEW_LIBRARY 33 | NAMES glew glew32 34 | PATHS 35 | $ENV{GLEW_ROOT_PATH}/lib 36 | ${OPENGL_LIBRARY_DIR} 37 | ) 38 | 39 | ENDIF(CYGWIN) 40 | 41 | ELSE (WIN32) 42 | 43 | IF (APPLE) 44 | # These values for Apple could probably do with improvement. 45 | FIND_PATH( GLEW_INCLUDE_DIR glew.h 46 | /System/Library/Frameworks/GLEW.framework/Versions/A/Headers 47 | ${OPENGL_LIBRARY_DIR} 48 | ) 49 | SET(GLEW_GLEW_LIBRARY "-framework GLEW" CACHE STRING "GLEW library for OSX") 50 | SET(GLEW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX") 51 | ELSE (APPLE) 52 | 53 | FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h 54 | /usr/include/GL 55 | /usr/openwin/share/include 56 | /usr/openwin/include 57 | /usr/X11R6/include 58 | /usr/include/X11 59 | /opt/graphics/OpenGL/include 60 | /opt/graphics/OpenGL/contrib/libglew 61 | ) 62 | 63 | FIND_LIBRARY( GLEW_GLEW_LIBRARY GLEW 64 | /usr/openwin/lib 65 | /usr/X11R6/lib 66 | ) 67 | 68 | ENDIF (APPLE) 69 | 70 | ENDIF (WIN32) 71 | 72 | SET( GLEW_FOUND "NO" ) 73 | IF(GLEW_INCLUDE_DIR) 74 | IF(GLEW_GLEW_LIBRARY) 75 | # Is -lXi and -lXmu required on all platforms that have it? 76 | # If not, we need some way to figure out what platform we are on. 77 | SET( GLEW_LIBRARIES 78 | ${GLEW_GLEW_LIBRARY} 79 | ${GLEW_cocoa_LIBRARY} 80 | ) 81 | SET( GLEW_FOUND "YES" ) 82 | 83 | #The following deprecated settings are for backwards compatibility with CMake1.4 84 | SET (GLEW_LIBRARY ${GLEW_LIBRARIES}) 85 | SET (GLEW_INCLUDE_PATH ${GLEW_INCLUDE_DIR}) 86 | 87 | ENDIF(GLEW_GLEW_LIBRARY) 88 | ENDIF(GLEW_INCLUDE_DIR) 89 | 90 | IF(GLEW_FOUND) 91 | IF(NOT GLEW_FIND_QUIETLY) 92 | MESSAGE(STATUS "Found Glew: ${GLEW_LIBRARIES}") 93 | ENDIF(NOT GLEW_FIND_QUIETLY) 94 | ELSE(GLEW_FOUND) 95 | IF(GLEW_FIND_REQUIRED) 96 | MESSAGE(FATAL_ERROR "Could not find Glew") 97 | ENDIF(GLEW_FIND_REQUIRED) 98 | ENDIF(GLEW_FOUND) 99 | 100 | MARK_AS_ADVANCED( 101 | GLEW_INCLUDE_DIR 102 | GLEW_GLEW_LIBRARY 103 | GLEW_Xmu_LIBRARY 104 | GLEW_Xi_LIBRARY 105 | ) 106 | -------------------------------------------------------------------------------- /cmake/Modules/FindOpenNI.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find OpenNI 3 | # 4 | # This sets the following variables: 5 | # OPENNI_FOUND - True if OPENNI was found. 6 | # OPENNI_INCLUDE_DIRS - Directories containing the OPENNI include files. 7 | # OPENNI_LIBRARIES - Libraries needed to use OPENNI. 8 | # OPENNI_DEFINITIONS - Compiler flags for OPENNI. 9 | 10 | find_package(PkgConfig) 11 | if(${CMAKE_VERSION} VERSION_LESS 2.8.2) 12 | pkg_check_modules(PC_OPENNI openni-dev) 13 | else() 14 | pkg_check_modules(PC_OPENNI QUIET openni-dev) 15 | endif() 16 | 17 | set(OPENNI_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER}) 18 | 19 | #add a hint so that it can find it without the pkg-config 20 | find_path(OPENNI_INCLUDE_DIR XnStatus.h 21 | HINTS ${PC_OPENNI_INCLUDEDIR} ${PC_OPENNI_INCLUDE_DIRS} /usr/include/openni /usr/include/ni "${OPENNI_ROOT}" "$ENV{OPENNI_ROOT}" 22 | PATHS "$ENV{PROGRAMFILES}/OpenNI/Include" "$ENV{PROGRAMW6432}/OpenNI/Include" 23 | PATH_SUFFIXES openni include Include) 24 | #add a hint so that it can find it without the pkg-config 25 | find_library(OPENNI_LIBRARY 26 | NAMES OpenNI64 OpenNI 27 | HINTS ${PC_OPENNI_LIBDIR} ${PC_OPENNI_LIBRARY_DIRS} /usr/lib "${OPENNI_ROOT}" "$ENV{OPENNI_ROOT}" 28 | PATHS "$ENV{PROGRAMFILES}/OpenNI/Lib" "$ENV{PROGRAMW6432}/OpenNI/Lib64" 29 | PATH_SUFFIXES lib Lib Lib64) 30 | 31 | set(OPENNI_INCLUDE_DIRS ${OPENNI_INCLUDE_DIR}) 32 | if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 33 | set(OPENNI_LIBRARIES ${OPENNI_LIBRARY} usb-1.0) 34 | else() 35 | set(OPENNI_LIBRARIES ${OPENNI_LIBRARY}) 36 | endif() 37 | 38 | include(FindPackageHandleStandardArgs) 39 | find_package_handle_standard_args(OpenNI DEFAULT_MSG 40 | OPENNI_LIBRARY OPENNI_INCLUDE_DIR) 41 | 42 | mark_as_advanced(OPENNI_LIBRARY OPENNI_INCLUDE_DIR) 43 | if(OPENNI_FOUND) 44 | set(HAVE_OPENNI ON) 45 | include_directories(${OPENNI_INCLUDE_DIRS}) 46 | message(STATUS "OpenNI found (include: ${OPENNI_INCLUDE_DIR}, lib: ${OPENNI_LIBRARY})") 47 | endif(OPENNI_FOUND) 48 | 49 | -------------------------------------------------------------------------------- /cmake/Modules/FindQhull.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find QHULL 3 | # 4 | # This sets the following variables: 5 | # QHULL_FOUND - True if QHULL was found. 6 | # QHULL_INCLUDE_DIRS - Directories containing the QHULL include files. 7 | # QHULL_LIBRARIES - Libraries needed to use QHULL. 8 | # QHULL_DEFINITIONS - Compiler flags for QHULL. 9 | 10 | set(QHULL_MAJOR_VERSION 6) 11 | 12 | find_file(QHULL_HEADER 13 | NAMES libqhull/libqhull.h qhull.h 14 | HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" "${QHULL_INCLUDE_DIR}" 15 | PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" 16 | "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" 17 | PATH_SUFFIXES qhull src/libqhull libqhull include) 18 | 19 | set(QHULL_HEADER "${QHULL_HEADER}" CACHE INTERNAL "QHull header" FORCE ) 20 | 21 | if(QHULL_HEADER) 22 | get_filename_component(qhull_header ${QHULL_HEADER} NAME_WE) 23 | if("${qhull_header}" STREQUAL "qhull") 24 | set(HAVE_QHULL_2011 OFF) 25 | get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH) 26 | elseif("${qhull_header}" STREQUAL "libqhull") 27 | set(HAVE_QHULL_2011 ON) 28 | get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH) 29 | get_filename_component(QHULL_INCLUDE_DIR ${QHULL_INCLUDE_DIR} PATH) 30 | endif() 31 | else(QHULL_HEADER) 32 | set(QHULL_INCLUDE_DIR "QHULL_INCLUDE_DIR-NOTFOUND") 33 | endif(QHULL_HEADER) 34 | 35 | set(QHULL_INCLUDE_DIR "${QHULL_INCLUDE_DIR}" CACHE PATH "QHull include dir." FORCE) 36 | 37 | # Prefer static libraries in Windows over shared ones 38 | if(WIN32) 39 | find_library(QHULL_LIBRARY 40 | NAMES qhullstatic qhull qhull${QHULL_MAJOR_VERSION} 41 | HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" 42 | PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" 43 | "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" 44 | PATH_SUFFIXES project build bin lib) 45 | 46 | find_library(QHULL_LIBRARY_DEBUG 47 | NAMES qhullstatic_d qhull_d qhull${QHULL_MAJOR_VERSION}_d qhull qhull${QHULL_MAJOR_VERSION} 48 | HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" 49 | PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull" 50 | "$ENV{PROGRAMFILES}/qhull 6.2.0.1373" "$ENV{PROGRAMW6432}/qhull 6.2.0.1373" 51 | PATH_SUFFIXES project build bin lib) 52 | else(WIN32) 53 | find_library(QHULL_LIBRARY 54 | NAMES qhull qhull${QHULL_MAJOR_VERSION} 55 | HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" 56 | PATH_SUFFIXES project build bin lib) 57 | 58 | find_library(QHULL_LIBRARY_DEBUG 59 | NAMES qhull_d qhull_d${QHULL_MAJOR_VERSION} qhull qhull${QHULL_MAJOR_VERSION} 60 | HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" 61 | PATH_SUFFIXES project build bin lib) 62 | endif(WIN32) 63 | 64 | if(NOT QHULL_LIBRARY_DEBUG) 65 | set(QHULL_LIBRARY_DEBUG ${QHULL_LIBRARY}) 66 | endif(NOT QHULL_LIBRARY_DEBUG) 67 | 68 | set(QHULL_INCLUDE_DIRS ${QHULL_INCLUDE_DIR}) 69 | set(QHULL_LIBRARIES optimized ${QHULL_LIBRARY} debug ${QHULL_LIBRARY_DEBUG}) 70 | 71 | include(FindPackageHandleStandardArgs) 72 | find_package_handle_standard_args(Qhull DEFAULT_MSG QHULL_LIBRARY 73 | QHULL_INCLUDE_DIR) 74 | 75 | mark_as_advanced(QHULL_LIBRARY QHULL_LIBRARY_DEBUG QHULL_INCLUDE_DIR) 76 | 77 | if(QHULL_FOUND) 78 | set(HAVE_QHULL ON) 79 | get_filename_component(qhull_lib ${QHULL_LIBRARY} NAME_WE) 80 | if(NOT "${qhull_lib}" STREQUAL "qhullstatic") 81 | add_definitions("-Dqh_QHpointer") 82 | endif(NOT "${qhull_lib}" STREQUAL "qhullstatic") 83 | message(STATUS "QHULL found (include: ${QHULL_INCLUDE_DIRS}, lib: ${QHULL_LIBRARIES})") 84 | endif(QHULL_FOUND) 85 | -------------------------------------------------------------------------------- /cmake/Modules/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find Sphinx 3 | # 4 | # This sets the following variables: 5 | # SPHINX_FOUND - True if Sphinx was found. 6 | # SPHINX_EXECUTABLE - Sphinx-build executable 7 | 8 | find_package(PkgConfig) 9 | pkg_check_modules(PC_SPHINX sphinx-build) 10 | 11 | find_package(PythonInterp) 12 | 13 | if(PYTHONINTERP_FOUND) 14 | get_filename_component(PYTHON_DIR "${PYTHON_EXECUTABLE}" PATH) 15 | endif(PYTHONINTERP_FOUND) 16 | 17 | find_program(SPHINX_EXECUTABLE NAMES sphinx-build 18 | HINTS ${PC_SPHINX_EXECUTABLE} $ENV{SPHINX_DIR} ${PYTHON_DIR}/Scripts 19 | PATH_SUFFIXES bin 20 | DOC "Sphinx documentation generator" 21 | ) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) 25 | 26 | mark_as_advanced(SPHINX_EXECUTABLE) 27 | -------------------------------------------------------------------------------- /cmake/cpack_options.cmake.in: -------------------------------------------------------------------------------- 1 | set(CPACK_PACKAGE_NAME "@PROJECT_NAME@") 2 | set(CPACK_PACKAGE_VENDOR "PointClouds.org") 3 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Point Cloud Library (PCL)") 4 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "@PROJECT_NAME@ @PCL_VERSION@") 5 | set(CPACK_RESOURCE_FILE_LICENSE "@PROJECT_SOURCE_DIR@/LICENSE.txt") 6 | set(CPACK_RESOURCE_FILE_README "@PROJECT_SOURCE_DIR@/AUTHORS.txt") 7 | 8 | @PCL_CPACK_COMPONENTS@ 9 | 10 | IF ((WIN32 OR UNIX) AND (CPACK_GENERATOR STREQUAL "NSIS")) 11 | set(CPACK_NSIS_DISPLAY_NAME "@PROJECT_NAME@-@PCL_VERSION@") 12 | set(CPACK_NSIS_MUI_ICON "@PROJECT_SOURCE_DIR@/cmake/images/pcl.ico") 13 | set(CPACK_NSIS_MUI_UNIICON "@PROJECT_SOURCE_DIR@/cmake/images/pcl.ico") 14 | set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.pointclouds.org") 15 | set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.pointclouds.org") 16 | set(CPACK_NSIS_MODIFY_PATH ON) 17 | set(CPACK_PACKAGE_EXECUTABLES @PCL_EXECUTABLES@) 18 | set(CPACK_NSIS_MENU_LINKS 19 | "share/doc/pcl/tutorials/html/index.html" "Tutorials" 20 | "share/doc/pcl/tutorials/html/sources" "Tutorials sources" 21 | "share/doc/pcl/html/pcl-@PCL_MAJOR_VERSION@.@PCL_MINOR_VERSION@.chm" "Documentation" 22 | "http://www.pointclouds.org" "PCL Website") 23 | #set(CPACK_NSIS_MENU_LINKS "share/doc/@PROJECT_NAME@/user_guide.pdf" "User's guide") 24 | #set(CPACK_NSIS_MENU_LINKS "share/doc/@PROJECT_NAME@/developer_guide.pdf" "Developer's guide") 25 | if(WIN32 AND NOT UNIX) 26 | # There is a bug in NSI that does not handle full unix paths properly. Make 27 | # sure there is at least one set of four (4) backlasshes. 28 | set(CPACK_PACKAGE_ICON "@PROJECT_SOURCE_DIR@/cmake/images\\\\pcl_horz_large_pos.bmp") 29 | else(WIN32 AND NOT UNIX) 30 | set(CPACK_PACKAGE_ICON "@PROJECT_SOURCE_DIR@/cmake/images/pcl_horz_large_pos.bmp") 31 | endif(WIN32 AND NOT UNIX) 32 | ENDIF () 33 | 34 | IF (UNIX AND ((CPACK_GENERATOR STREQUAL "DEB") OR (CPACK_GENERATOR STREQUAL "RPM"))) 35 | # define stuff for the DEB/RPM packages 36 | set(CPACK_PACKAGE_CONTACT "pcl-developers@pointclouds.org") 37 | ENDIF () 38 | 39 | IF (UNIX AND (CPACK_GENERATOR STREQUAL "DEB")) 40 | SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) 41 | ENDIF () 42 | 43 | IF (APPLE AND (CPACK_GENERATOR STREQUAL "PackageMaker")) 44 | # define stuff for the PackageMaker packages 45 | set(CPACK_OSX_PACKAGE_VERSION 10.5) 46 | set(CPACK_PACKAGE_CONTACT "pcl-developers@pointclouds.org") 47 | set(CPACK_SET_DESTDIR ON) 48 | set(CPACK_PACKAGING_INSTALL_PREFIX /usr/local) 49 | ENDIF () 50 | -------------------------------------------------------------------------------- /cmake/dep_graph.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Make a dependency graph dot file 3 | function(MAKE_DEP_GRAPH) 4 | set(_dot_file "${PROJECT_BINARY_DIR}/pcl.dot") 5 | file(WRITE ${_dot_file} "digraph pcl {\n") 6 | foreach(_ss ${PCL_SUBSYSTEMS}) 7 | if(NOT _ss STREQUAL "global_tests" AND 8 | NOT _ss STREQUAL "apps" AND 9 | NOT _ss STREQUAL "tools" AND 10 | NOT _ss STREQUAL "test" AND 11 | NOT _ss STREQUAL "python" AND 12 | NOT _ss STREQUAL "documentation") 13 | PCL_GET_SUBSYS_STATUS(_status ${_ss}) 14 | if(_status) 15 | file(APPEND ${_dot_file} 16 | " \"${_ss}\" [style=\"filled\" fillcolor=\"#008000\" shape=\"box\"];\n ") 17 | else(_status) 18 | file(APPEND ${_dot_file} 19 | " \"${_ss}\" [style=\"filled\" fillcolor=\"#D40000\" shape=\"box\"];\n ") 20 | endif(_status) 21 | GET_IN_MAP(_deps PCL_SUBSYS_DEPS ${_ss}) 22 | foreach(_dep ${_deps}) 23 | file(APPEND ${_dot_file} " \"${_ss}\" -> \"${_dep}\";\n") 24 | endforeach(_dep) 25 | endif() 26 | endforeach(_ss) 27 | 28 | #file(APPEND ${_dot_file} 29 | # " \"test\" [style=\"filled\" fillcolor=\"#A3A27C\" shape=\"box\"];\n ") 30 | file(APPEND ${_dot_file} "}\n") 31 | endfunction(MAKE_DEP_GRAPH) 32 | 33 | -------------------------------------------------------------------------------- /cmake/merge_cmake_install.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # file: merge_cmake_install.py 3 | 4 | import sys, math 5 | import fnmatch 6 | import os 7 | import shutil 8 | 9 | if len(sys.argv) != 2: 10 | # stop the program and print an error message 11 | sys.exit("Must provide a cmake binary folder") 12 | 13 | base_folder = sys.argv[1] 14 | 15 | string_to_remove_debug = "IF(\"${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\")" 16 | string_to_remove_release = "IF(\"${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$\")" 17 | 18 | matches = [] 19 | for root, dirnames, filenames in os.walk(base_folder): 20 | for filename in fnmatch.filter(filenames, 'cmake_install.cmake'): 21 | matches.append(os.path.join(root, filename)) 22 | 23 | for one_match in matches: 24 | #print one_match, "\n" 25 | shutil.move( one_match, one_match+"~" ) 26 | destination= open( one_match, "w" ) 27 | source= open( one_match+"~", "r" ) 28 | for line in source: 29 | if string_to_remove_debug in line: 30 | destination.write( "\n" ) 31 | elif string_to_remove_release in line: 32 | destination.write( "\n" ) 33 | else: 34 | destination.write( line ) 35 | source.close() 36 | destination.close() -------------------------------------------------------------------------------- /cmake/pcl_all_in_one_installer.cmake: -------------------------------------------------------------------------------- 1 | 2 | if(WIN32) 3 | option(BUILD_all_in_one_installer "Build an all-in-one NSIS installer" OFF) 4 | endif(WIN32) 5 | 6 | if(BUILD_all_in_one_installer) 7 | get_filename_component(BOOST_ROOT "${Boost_INCLUDE_DIR}" PATH) 8 | get_filename_component(EIGEN_ROOT "${EIGEN_INCLUDE_DIRS}" PATH) 9 | get_filename_component(QHULL_ROOT "${QHULL_INCLUDE_DIRS}" PATH) 10 | get_filename_component(FLANN_ROOT "${FLANN_INCLUDE_DIRS}" PATH) 11 | get_filename_component(VTK_ROOT "${VTK_DIR}" PATH) 12 | get_filename_component(VTK_ROOT "${VTK_ROOT}" PATH) 13 | set(PCL_3RDPARTY_COMPONENTS) 14 | foreach(dep Eigen Boost Qhull Flann VTK) 15 | string(TOUPPER ${dep} DEP) 16 | install( 17 | DIRECTORY "${${DEP}_ROOT}" 18 | DESTINATION 3rdParty 19 | COMPONENT ${dep} 20 | PATTERN "*/Uninstall.exe" EXCLUDE 21 | ) 22 | list(APPEND PCL_3RDPARTY_COMPONENTS ${dep}) 23 | endforeach(dep) 24 | 25 | if(CMAKE_CL_64) 26 | set(OPENNI_PACKAGE "OpenNI-Win64-1.3.2-Dev.msi") 27 | set(OPENNI_URL "http://dev.pointclouds.org/attachments/download/360/${OPENNI_PACKAGE}") 28 | set(OPENNI_MD5 e54b5ede27b293c579c42dcede33b289) 29 | set(OPENNI_SENSOR_PACKAGE "Sensor-Win-OpenSource64-5.0.3.msi") 30 | set(OPENNI_SENSOR_URL "http://dev.pointclouds.org/attachments/download/359/${OPENNI_SENSOR_PACKAGE}") 31 | set(OPENNI_SENSOR_MD5 cbf4ce02d5ef430dca17833d5588e060) 32 | else(CMAKE_CL_64) 33 | set(OPENNI_PACKAGE "OpenNI-Win32-1.3.2-Dev.msi") 34 | set(OPENNI_URL "http://dev.pointclouds.org/attachments/download/361/${OPENNI_PACKAGE}") 35 | set(OPENNI_MD5 0b7118a0581abef411b58530d4039cf0) 36 | set(OPENNI_SENSOR_PACKAGE "Sensor-Win-OpenSource32-5.0.3.msi") 37 | set(OPENNI_SENSOR_URL "http://dev.pointclouds.org/attachments/download/358/${OPENNI_SENSOR_PACKAGE}") 38 | set(OPENNI_SENSOR_MD5 8bf14b2e813859f868fc316acb2d08fa) 39 | endif(CMAKE_CL_64) 40 | 41 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " IntCmp $OpenNI_selected 0 noinstall_openni_packages\n") 42 | 43 | file(DOWNLOAD ${OPENNI_URL} "${CMAKE_CURRENT_BINARY_DIR}/${OPENNI_PACKAGE}" 44 | STATUS _openni_download_status LOG _openni_download_log 45 | EXPECTED_MD5 ${OPENNI_MD5} 46 | ) 47 | list(GET _openni_download_status 0 _error_code) 48 | list(GET _openni_download_status 1 _error_message) 49 | if(_error_code EQUAL 0) 50 | install( 51 | FILES "${CMAKE_CURRENT_BINARY_DIR}/${OPENNI_PACKAGE}" 52 | DESTINATION 3rdParty/OpenNI 53 | COMPONENT OpenNI 54 | ) 55 | list(APPEND PCL_3RDPARTY_COMPONENTS OpenNI) 56 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS 57 | "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\n ExecWait 'msiexec /i \\\"$INSTDIR\\\\3rdParty\\\\OpenNI\\\\${OPENNI_PACKAGE}\\\" '") 58 | else(_error_code EQUAL 0) 59 | message("WARNING : Could not download ${OPENNI_URL}, error code : ${_error_code}, error message : ${_error_message}") 60 | endif(_error_code EQUAL 0) 61 | 62 | file(DOWNLOAD ${OPENNI_SENSOR_URL} "${CMAKE_CURRENT_BINARY_DIR}/${OPENNI_SENSOR_PACKAGE}" 63 | STATUS _openni_download_status LOG _openni_download_log 64 | EXPECTED_MD5 ${OPENNI_SENSOR_MD5} 65 | ) 66 | list(GET _openni_download_status 0 _error_code) 67 | list(GET _openni_download_status 1 _error_message) 68 | if(_error_code EQUAL 0) 69 | install( 70 | FILES "${CMAKE_CURRENT_BINARY_DIR}/${OPENNI_SENSOR_PACKAGE}" 71 | DESTINATION 3rdParty/OpenNI 72 | COMPONENT OpenNI 73 | ) 74 | list(APPEND PCL_3RDPARTY_COMPONENTS OpenNI) 75 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS 76 | "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\n ExecWait 'msiexec /i \\\"$INSTDIR\\\\3rdParty\\\\OpenNI\\\\${OPENNI_SENSOR_PACKAGE}\\\" '") 77 | else(_error_code EQUAL 0) 78 | message("WARNING : Could not download ${OPENNI_SENSOR_URL}, error code : ${_error_code}, error message : ${_error_message}") 79 | endif(_error_code EQUAL 0) 80 | list(REMOVE_DUPLICATES PCL_3RDPARTY_COMPONENTS) 81 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}\n noinstall_openni_packages:\n") 82 | endif(BUILD_all_in_one_installer) 83 | -------------------------------------------------------------------------------- /cmake/pcl_cpack.cmake: -------------------------------------------------------------------------------- 1 | # Package creation using CPack 2 | 3 | ############################################################################### 4 | #find available package generators 5 | 6 | # RPM (disabled until RedHat/Fedora users/developers need this) 7 | #find_program(RPM_PROGRAM rpm) 8 | #if(EXISTS ${RPM_PROGRAM}) 9 | # list(APPEND CPACK_GENERATOR "RPM") 10 | #endif(EXISTS ${RPM_PROGRAM}) 11 | 12 | set(CPACK_PACKAGE_VERSION "${PCL_VERSION}") 13 | set(CPACK_PACKAGE_VERSION_MAJOR "${PCL_MAJOR_VERSION}") 14 | set(CPACK_PACKAGE_VERSION_MINOR "${PCL_MINOR_VERSION}") 15 | set(CPACK_PACKAGE_VERSION_PATCH "${PCL_REVISION_VERSION}") 16 | set(CPACK_PACKAGE_CONFIG_INSTALL_DIR ${PCLCONFIG_INSTALL_DIR}) 17 | 18 | # DEB 19 | if("${CMAKE_SYSTEM}" MATCHES "Linux") 20 | find_program(DPKG_PROGRAM dpkg) 21 | if(EXISTS ${DPKG_PROGRAM}) 22 | list(APPEND CPACK_GENERATOR "DEB") 23 | endif(EXISTS ${DPKG_PROGRAM}) 24 | endif() 25 | 26 | # NSIS 27 | if(WIN32) 28 | list(APPEND CPACK_GENERATOR "NSIS") 29 | if(CMAKE_CL_64) 30 | set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") 31 | set(win_system_name win64) 32 | else(CMAKE_CL_64) 33 | set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES32") 34 | set(win_system_name win32) 35 | endif(CMAKE_CL_64) 36 | set(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME}-${PCL_VERSION}") 37 | if(BUILD_all_in_one_installer) 38 | set(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME}-${PCL_VERSION}-AllInOne") 39 | endif(BUILD_all_in_one_installer) 40 | if(MSVC10) 41 | set(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_PACKAGE_NAME}-msvc2010-${win_system_name}") 42 | else(MSVC10) 43 | set(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_PACKAGE_NAME}-${win_system_name}") 44 | endif(MSVC10) 45 | set(CPACK_PACKAGE_FILE_NAME ${CPACK_NSIS_PACKAGE_NAME}) 46 | # force CPACK_PACKAGE_INSTALL_REGISTRY_KEY because of a known limitation in cmake/cpack to be fixed in next releases 47 | # http://public.kitware.com/Bug/view.php?id=9094 48 | # This is to allow a 32bit and a 64bit of PCL to get installed on one system 49 | set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME} ${PCL_VERSION} ${win_system_name}" ) 50 | endif() 51 | 52 | # dpkg 53 | if(APPLE) 54 | find_program(PACKAGE_MAKER_PROGRAM PackageMaker 55 | HINTS /Developer/Applications/Utilities) 56 | if(EXISTS ${PACKAGE_MAKER_PROGRAM}) 57 | list(APPEND CPACK_GENERATOR "PackageMaker") 58 | endif(EXISTS ${PACKAGE_MAKER_PROGRAM}) 59 | endif() 60 | 61 | include(InstallRequiredSystemLibraries) 62 | 63 | set(PCL_CPACK_CFG_FILE "${PCL_BINARY_DIR}/cpack_options.cmake") 64 | 65 | ############################################################################### 66 | # Make the CPack input file. 67 | macro(PCL_MAKE_CPACK_INPUT) 68 | set(_cpack_cfg_in "${PCL_SOURCE_DIR}/cmake/cpack_options.cmake.in") 69 | set(${_var} "${${_var}}\nset(CPACK_COMPONENT_GROUP_PCL_DESCRIPTION \"PCL headers and librairies\")\n") 70 | 71 | # Prepare the components list 72 | set(PCL_CPACK_COMPONENTS) 73 | PCL_CPACK_MAKE_COMPS_OPTS(PCL_CPACK_COMPONENTS "${_comps}") 74 | 75 | # add documentation 76 | if(BUILD_documentation) 77 | set(CPACK_COMPONENTS_ALL "${CPACK_COMPONENTS_ALL} doc") 78 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_DOC_GROUP \"PCL\")\n") 79 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_DOC_DISPLAY_NAME \"Documentation\")\n") 80 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_DOC_DESCRIPTION \"API documentation and tutorials\")\n") 81 | endif(BUILD_documentation) 82 | # add PCLConfig 83 | set(CPACK_COMPONENTS_ALL "${CPACK_COMPONENTS_ALL} pclconfig") 84 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_PCLCONFIG_GROUP \"PCL\")\n") 85 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_PCLCONFIG_DISPLAY_NAME \"PCLConfig\")\n") 86 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_PCLCONFIG_DESCRIPTION \"Helper cmake configuration scripts used by find_package(PCL)\")\n") 87 | 88 | # add 3rdParty libs 89 | if(BUILD_all_in_one_installer) 90 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_GROUP_THIRDPARTY_DISPLAY_NAME \"3rd Party Libraries\")") 91 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_GROUP_THIRDPARTY_DESCRIPTION \"3rd Party Libraries\")") 92 | foreach(dep ${PCL_3RDPARTY_COMPONENTS}) 93 | string(TOUPPER ${dep} DEP) 94 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENT_${DEP}_GROUP \"ThirdParty\")") 95 | set(CPACK_COMPONENTS_ALL "${CPACK_COMPONENTS_ALL} ${dep}") 96 | endforeach(dep) 97 | endif(BUILD_all_in_one_installer) 98 | 99 | set(PCL_CPACK_COMPONENTS "${PCL_CPACK_COMPONENTS}\nset(CPACK_COMPONENTS_ALL${CPACK_COMPONENTS_ALL})\n") 100 | configure_file(${_cpack_cfg_in} ${PCL_CPACK_CFG_FILE} @ONLY) 101 | endmacro(PCL_MAKE_CPACK_INPUT) 102 | 103 | 104 | macro(PCL_CPACK_MAKE_COMPS_OPTS _var _current) 105 | set(_comps_list) 106 | foreach(_ss ${PCL_SUBSYSTEMS}) 107 | if("${_ss}" STREQUAL "global_tests") 108 | # we don't install global_tests 109 | else("${_ss}" STREQUAL "global_tests") 110 | PCL_GET_SUBSYS_STATUS(_status ${_ss}) 111 | if(_status) 112 | set(_comps_list "${_comps_list} ${_ss}") 113 | PCL_CPACK_ADD_COMP_INFO(${_var} ${_ss}) 114 | endif(_status) 115 | endif("${_ss}" STREQUAL "global_tests") 116 | endforeach(_ss) 117 | set(CPACK_COMPONENTS_ALL ${_comps_list}) 118 | endmacro(PCL_CPACK_MAKE_COMPS_OPTS) 119 | 120 | 121 | macro(PCL_CPACK_ADD_COMP_INFO _var _ss) 122 | string(TOUPPER "${_ss}" _comp_name) 123 | set(${_var} 124 | "${${_var}}set(CPACK_COMPONENT_${_comp_name}_DISPLAY_NAME \"${_ss}\")\n") 125 | GET_IN_MAP(_desc PCL_SUBSYS_DESC ${_ss}) 126 | set(${_var} 127 | "${${_var}}set(CPACK_COMPONENT_${_comp_name}_DESCRIPTION \"${_desc}\")\n") 128 | set(_deps_str) 129 | GET_IN_MAP(_deps PCL_SUBSYS_DEPS ${_ss}) 130 | foreach(_dep ${_deps}) 131 | set(_deps_str "${_deps_str} ${_dep}") 132 | endforeach(_dep) 133 | set(${_var} 134 | "${${_var}}set(CPACK_COMPONENT_${_comp_name}_DEPENDS ${_deps_str})\n") 135 | set(${_var} 136 | "${${_var}}set(CPACK_COMPONENT_${_comp_name}_GROUP \"PCL\")\n") 137 | endmacro(PCL_CPACK_ADD_COMP_INFO) 138 | 139 | -------------------------------------------------------------------------------- /cmake/pcl_examples.cmake: -------------------------------------------------------------------------------- 1 | # Example management 2 | 3 | # Add an option so the user can turn tests off 4 | option(BUILD_EXAMPLES "Build the library examples" ${DEFAULT}) 5 | 6 | # Print a suitable status message 7 | if(NOT ${DEFAULT} AND NOT ${BUILD_EXAMPLES}) 8 | if(REASON) 9 | message(STATUS "Examples will not be built: ${REASON}") 10 | else(REASON) 11 | message(STATUS "Examples will not be built: Disabled manually") 12 | endif(REASON) 13 | elseif(NOT ${BUILD_EXAMPLES}) 14 | message(STATUS "Examples will not be built: Disabled manually") 15 | else(NOT ${DEFAULT} AND NOT ${BUILD_EXAMPLES}) 16 | message(STATUS "Examples will be built") 17 | endif(NOT ${DEFAULT} AND NOT ${BUILD_EXAMPLES}) 18 | -------------------------------------------------------------------------------- /cmake/pcl_find_boost.cmake: -------------------------------------------------------------------------------- 1 | # Find and set Boost flags 2 | 3 | if(NOT PCL_SHARED_LIBS OR WIN32) 4 | set(Boost_USE_STATIC_LIBS ON) 5 | set(Boost_USE_STATIC ON) 6 | endif(NOT PCL_SHARED_LIBS OR WIN32) 7 | 8 | if(${CMAKE_VERSION} VERSION_LESS 2.8.5) 9 | SET(Boost_ADDITIONAL_VERSIONS "1.43" "1.43.0" "1.44" "1.44.0" "1.45" "1.45.0" "1.46.1" "1.46.0" "1.46" "1.47" "1.47.0") 10 | else(${CMAKE_VERSION} VERSION_LESS 2.8.5) 11 | SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0") 12 | endif(${CMAKE_VERSION} VERSION_LESS 2.8.5) 13 | 14 | # Disable the config mode of find_package(Boost) 15 | set(Boost_NO_BOOST_CMAKE ON) 16 | 17 | # Optional boost modules 18 | find_package(Boost 1.40.0 COMPONENTS mpi serialization) 19 | 20 | # Required boost modules 21 | find_package(Boost 1.40.0 REQUIRED COMPONENTS system filesystem thread date_time iostreams) 22 | 23 | if(Boost_FOUND) 24 | set(BOOST_FOUND TRUE) 25 | # Obtain diagnostic information about Boost's automatic linking outputted 26 | # during compilation time. 27 | add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) 28 | 29 | include_directories(${Boost_INCLUDE_DIRS}) 30 | link_directories(${Boost_LIBRARY_DIRS}) 31 | endif(Boost_FOUND) 32 | -------------------------------------------------------------------------------- /cmake/pcl_find_python.cmake: -------------------------------------------------------------------------------- 1 | find_package(PythonInterp) 2 | find_package(PythonLibs) 3 | 4 | if(PYTHONINTERP_FOUND) 5 | execute_process(COMMAND ${PYTHON_EXECUTABLE} --version 6 | ERROR_VARIABLE PYTHON_VERSION_FULL 7 | OUTPUT_STRIP_TRAILING_WHITESPACE) 8 | 9 | string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}") 10 | if(UNIX) 11 | set(PYTHON_PLUGIN_INSTALL_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages/opencv) 12 | if(APPLE) 13 | set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages CACHE PATH "Where to install the python packages.") 14 | else() #debian based assumed, install to the dist-packages. 15 | set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.") 16 | endif() 17 | endif() 18 | if(WIN32) 19 | get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE) 20 | set(PYTHON_PLUGIN_INSTALL_PATH "${PYTHON_PATH}/Lib/site-packages/opencv") 21 | set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages") 22 | endif() 23 | 24 | if ("${PYTHON_VERSION_MAJOR_MINOR}" VERSION_GREATER 2.5) 25 | SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} -B) 26 | endif() 27 | endif(PYTHONINTERP_FOUND) 28 | find_package(PythonInterp) 29 | find_package(PythonLibs) 30 | 31 | if(PYTHONINTERP_FOUND) 32 | execute_process(COMMAND ${PYTHON_EXECUTABLE} --version 33 | ERROR_VARIABLE PYTHON_VERSION_FULL 34 | OUTPUT_STRIP_TRAILING_WHITESPACE) 35 | 36 | string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}") 37 | if(UNIX) 38 | set(PYTHON_PLUGIN_INSTALL_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages/opencv) 39 | if(APPLE) 40 | set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages CACHE PATH "Where to install the python packages.") 41 | else() #debian based assumed, install to the dist-packages. 42 | set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.") 43 | endif() 44 | endif() 45 | if(WIN32) 46 | get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE) 47 | set(PYTHON_PLUGIN_INSTALL_PATH "${PYTHON_PATH}/Lib/site-packages/opencv") 48 | set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages") 49 | endif() 50 | 51 | if ("${PYTHON_VERSION_MAJOR_MINOR}" VERSION_GREATER 2.5) 52 | SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} -B) 53 | endif() 54 | endif(PYTHONINTERP_FOUND) 55 | -------------------------------------------------------------------------------- /cmake/pcl_find_sse.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Check for the presence of SSE and figure out the flags to use for it. 3 | macro(PCL_CHECK_FOR_SSE) 4 | include(CheckCXXSourceRuns) 5 | if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) 6 | set(SSE_FLAGS) 7 | 8 | set(CMAKE_REQUIRED_FLAGS "-msse3") 9 | check_cxx_source_runs(" 10 | #include 11 | 12 | int main() 13 | { 14 | __m128d a, b; 15 | double vals[2] = {0}; 16 | a = _mm_loadu_pd(vals); 17 | b = _mm_hadd_pd(a,a); 18 | _mm_storeu_pd(vals, b); 19 | return 0; 20 | }" 21 | HAVE_SSE3_EXTENSIONS) 22 | 23 | set(CMAKE_REQUIRED_FLAGS "-msse2") 24 | check_cxx_source_runs(" 25 | #include 26 | 27 | int main() 28 | { 29 | __m128d a, b; 30 | double vals[2] = {0}; 31 | a = _mm_loadu_pd(vals); 32 | b = _mm_add_pd(a,a); 33 | _mm_storeu_pd(vals,b); 34 | return 0; 35 | }" 36 | HAVE_SSE2_EXTENSIONS) 37 | 38 | set(CMAKE_REQUIRED_FLAGS "-msse") 39 | check_cxx_source_runs(" 40 | #include 41 | int main() 42 | { 43 | __m128 a, b; 44 | float vals[4] = {0}; 45 | a = _mm_loadu_ps(vals); 46 | b = a; 47 | b = _mm_add_ps(a,b); 48 | _mm_storeu_ps(vals,b); 49 | return 0; 50 | }" 51 | HAVE_SSE_EXTENSIONS) 52 | 53 | set(CMAKE_REQUIRED_FLAGS) 54 | 55 | if(HAVE_SSE3_EXTENSIONS) 56 | set(SSE_FLAGS "-msse3 -mfpmath=sse") 57 | message(STATUS "Found SSE3 extensions, using flags: ${SSE_FLAGS}") 58 | elseif(HAVE_SSE2_EXTENSIONS) 59 | set(SSE_FLAGS "-msse2 -mfpmath=sse") 60 | message(STATUS "Found SSE2 extensions, using flags: ${SSE_FLAGS}") 61 | elseif(HAVE_SSE_EXTENSIONS) 62 | set(SSE_FLAGS "-msse -mfpmath=sse") 63 | message(STATUS "Found SSE extensions, using flags: ${SSE_FLAGS}") 64 | endif(HAVE_SSE3_EXTENSIONS) 65 | elseif(MSVC) 66 | check_cxx_source_runs(" 67 | #include 68 | 69 | int main() 70 | { 71 | __m128d a, b; 72 | double vals[2] = {0}; 73 | a = _mm_loadu_pd(vals); 74 | b = _mm_add_pd(a,a); 75 | _mm_storeu_pd(vals,b); 76 | return 0; 77 | }" 78 | HAVE_SSE2_EXTENSIONS) 79 | 80 | if(HAVE_SSE2_EXTENSIONS) 81 | set(SSE_FLAGS "/arch:SSE2 /fp:fast -D__SSE__ -D__SSE2__" ) 82 | message(STATUS "Found SSE2 extensions, using flags: ${SSE_FLAGS}") 83 | endif(HAVE_SSE2_EXTENSIONS) 84 | endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) 85 | endmacro(PCL_CHECK_FOR_SSE) 86 | 87 | 88 | ############################################################################### 89 | # Add the SSE flags to a target. 90 | # _name The name of the target to add the flags to. 91 | macro(PCL_ADD_SSE_FLAGS _name) 92 | if(SSE_FLAGS) 93 | PCL_ADD_CFLAGS(${_name} ${SSE_FLAGS}) 94 | endif(SSE_FLAGS) 95 | endmacro(PCL_ADD_SSE_FLAGS) 96 | 97 | -------------------------------------------------------------------------------- /cmake/pcl_openmp.cmake: -------------------------------------------------------------------------------- 1 | # Find the correct flags to use for OpenMP. 2 | # Taken from rosbuild and edited a little. 3 | 4 | include(${PROJECT_SOURCE_DIR}/cmake/pcl_targets.cmake) 5 | 6 | find_package(OpenMP) 7 | 8 | ############################################################################### 9 | # Add the OpenMP flags to a target. 10 | # _name The name of the target to add the flags to. 11 | macro(PCL_ADD_OPENMP_FLAGS _name) 12 | if(OPENMP_FOUND) 13 | PCL_ADD_CFLAGS(${_name} ${OpenMP_CXX_FLAGS}) 14 | endif(OPENMP_FOUND) 15 | endmacro(PCL_ADD_OPENMP_FLAGS) 16 | 17 | ############################################################################### 18 | # Link to the appropriate OpenMP implementation for the compiler. 19 | # _name The name of the target to link OpenMP into. 20 | macro(PCL_LINK_OPENMP _name) 21 | if(OPENMP_FOUND AND CMAKE_COMPILER_IS_GNUCC) 22 | # For GCC, link to libgomp 23 | target_link_libraries(${_name} gomp) 24 | endif(OPENMP_FOUND AND CMAKE_COMPILER_IS_GNUCC) 25 | endmacro(PCL_LINK_OPENMP) 26 | 27 | -------------------------------------------------------------------------------- /cmake/pcl_options.cmake: -------------------------------------------------------------------------------- 1 | # Options for building PCL. 2 | 3 | # Build shared libraries by default. 4 | cmake_dependent_option(PCL_SHARED_LIBS 5 | "Build shared libraries." ON "NOT ANDROID_NDK" OFF) 6 | 7 | if(PCL_SHARED_LIBS) 8 | set(PCL_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) 9 | set(PCL_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) 10 | set(PCL_LIB_TYPE "SHARED") 11 | else(PCL_SHARED_LIBS) 12 | set(PCL_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}) 13 | set(PCL_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) 14 | set(PCL_LIB_TYPE "STATIC") 15 | endif(PCL_SHARED_LIBS) 16 | mark_as_advanced(PCL_SHARED_LIBS) 17 | -------------------------------------------------------------------------------- /cmake/pcl_pclconfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PCL_SUBSYSTEMS_MODULES ${PCL_SUBSYSTEMS}) 3 | list(REMOVE_ITEM PCL_SUBSYSTEMS_MODULES tools cuda_apps global_tests proctor gpu_kinfu) 4 | 5 | set(PCLCONFIG_AVAILABLE_COMPONENTS) 6 | set(PCLCONFIG_AVAILABLE_COMPONENTS_LIST) 7 | set(PCLCONFIG_INTERNAL_DEPENDENCIES) 8 | set(PCLCONFIG_EXTERNAL_DEPENDENCIES) 9 | set(PCLCONFIG_OPTIONAL_DEPENDENCIES) 10 | foreach(_ss ${PCL_SUBSYSTEMS_MODULES}) 11 | PCL_GET_SUBSYS_STATUS(_status ${_ss}) 12 | if(_status) 13 | set(PCLCONFIG_AVAILABLE_COMPONENTS "${PCLCONFIG_AVAILABLE_COMPONENTS} ${_ss}") 14 | set(PCLCONFIG_AVAILABLE_COMPONENTS_LIST "${PCLCONFIG_AVAILABLE_COMPONENTS_LIST}\n# - ${_ss}") 15 | GET_IN_MAP(_deps PCL_SUBSYS_DEPS ${_ss}) 16 | if(_deps) 17 | set(PCLCONFIG_INTERNAL_DEPENDENCIES "${PCLCONFIG_INTERNAL_DEPENDENCIES}set(pcl_${_ss}_int_dep ") 18 | foreach(_dep ${_deps}) 19 | set(PCLCONFIG_INTERNAL_DEPENDENCIES "${PCLCONFIG_INTERNAL_DEPENDENCIES}${_dep} ") 20 | endforeach(_dep) 21 | set(PCLCONFIG_INTERNAL_DEPENDENCIES "${PCLCONFIG_INTERNAL_DEPENDENCIES})\n") 22 | endif(_deps) 23 | GET_IN_MAP(_ext_deps PCL_SUBSYS_EXT_DEPS ${_ss}) 24 | if(_ext_deps) 25 | set(PCLCONFIG_EXTERNAL_DEPENDENCIES "${PCLCONFIG_EXTERNAL_DEPENDENCIES}set(pcl_${_ss}_ext_dep ") 26 | foreach(_ext_dep ${_ext_deps}) 27 | set(PCLCONFIG_EXTERNAL_DEPENDENCIES "${PCLCONFIG_EXTERNAL_DEPENDENCIES}${_ext_dep} ") 28 | endforeach(_ext_dep) 29 | set(PCLCONFIG_EXTERNAL_DEPENDENCIES "${PCLCONFIG_EXTERNAL_DEPENDENCIES})\n") 30 | endif(_ext_deps) 31 | GET_IN_MAP(_opt_deps PCL_SUBSYS_OPT_DEPS ${_ss}) 32 | if(_opt_deps) 33 | set(PCLCONFIG_OPTIONAL_DEPENDENCIES "${PCLCONFIG_OPTIONAL_DEPENDENCIES}set(pcl_${_ss}_opt_dep ") 34 | foreach(_opt_dep ${_opt_deps}) 35 | set(PCLCONFIG_OPTIONAL_DEPENDENCIES "${PCLCONFIG_OPTIONAL_DEPENDENCIES}${_opt_dep} ") 36 | endforeach(_opt_dep) 37 | set(PCLCONFIG_OPTIONAL_DEPENDENCIES "${PCLCONFIG_OPTIONAL_DEPENDENCIES})\n") 38 | endif(_opt_deps) 39 | endif(_status) 40 | endforeach(_ss) 41 | 42 | configure_file("${PCL_SOURCE_DIR}/PCLConfig.cmake.in" 43 | "${PCL_BINARY_DIR}/PCLConfig.cmake" @ONLY) 44 | configure_file("${PCL_SOURCE_DIR}/PCLConfigVersion.cmake.in" 45 | "${PCL_BINARY_DIR}/PCLConfigVersion.cmake" @ONLY) 46 | install(FILES 47 | "${PCL_BINARY_DIR}/PCLConfig.cmake" 48 | "${PCL_BINARY_DIR}/PCLConfigVersion.cmake" 49 | COMPONENT pclconfig 50 | DESTINATION ${PCLCONFIG_INSTALL_DIR}) -------------------------------------------------------------------------------- /cmake/pcl_tests.cmake: -------------------------------------------------------------------------------- 1 | # Test management 2 | 3 | # Need GTest to build the tests 4 | find_package(GTest) 5 | if(GTEST_FOUND) 6 | set(REASON) 7 | set(DEFAULT ON) 8 | else(GTEST_FOUND) 9 | set(REASON "GTest was not found.") 10 | set(DEFAULT OFF) 11 | endif(GTEST_FOUND) 12 | 13 | # Add an option so the user can turn tests off 14 | option(BUILD_TESTS "Build the library tests" ${DEFAULT}) 15 | 16 | # Print a suitable status message 17 | if(NOT ${DEFAULT} AND NOT ${BUILD_TESTS}) 18 | if(REASON) 19 | message(STATUS "Tests will not be built: ${REASON}") 20 | else(REASON) 21 | message(STATUS "Tests will not be built: Disabled manually") 22 | endif(REASON) 23 | elseif(NOT ${BUILD_TESTS}) 24 | message(STATUS "Tests will not be built: Disabled manually") 25 | else(NOT ${DEFAULT} AND NOT ${BUILD_TESTS}) 26 | message(STATUS "Tests will be built") 27 | endif(NOT ${DEFAULT} AND NOT ${BUILD_TESTS}) 28 | 29 | # Set up for testing if tests are enabled 30 | if(BUILD_TESTS) 31 | enable_testing() 32 | include_directories(${GTEST_INCLUDE_DIRS}) 33 | endif(BUILD_TESTS) 34 | 35 | -------------------------------------------------------------------------------- /cmake/pkgconfig.cmake.in: -------------------------------------------------------------------------------- 1 | # This file was generated by CMake for @PROJECT_NAME@ library @PKG_NAME@ 2 | prefix=@CMAKE_INSTALL_PREFIX@ 3 | exec_prefix=${prefix} 4 | libdir=${prefix}/@LIB_INSTALL_DIR@ 5 | #includedir=${prefix}/@INCLUDE_INSTALL_DIR@ 6 | includedir=${prefix}/include/@PROJECT_NAME_LOWER@-@PCL_MAJOR_VERSION@.@PCL_MINOR_VERSION@ 7 | Name: @PKG_NAME@ 8 | Description: @PKG_DESC@ 9 | Version: @PCL_VERSION@ 10 | Requires: @PKG_EXTERNAL_DEPS@ 11 | Libs: -L${libdir} -l@PKG_NAME@ @PKG_LIBFLAGS@ @PKG_INTERNAL_DEPS@ 12 | Cflags: -I${includedir} @PKG_CFLAGS@ 13 | 14 | -------------------------------------------------------------------------------- /cmake/uninstall_target.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: \"@PROJECT_BINARY_DIR@/install_manifest.txt\"") 3 | endif(NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@PROJECT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 9 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 10 | if(EXISTS "$ENV{DESTDIR}${file}" OR IS_SYMLINK "$ENV{DESTDIR}${file}") 11 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval) 13 | if(NOT "${rm_retval}" STREQUAL 0) 14 | message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 15 | endif(NOT "${rm_retval}" STREQUAL 0) 16 | else(EXISTS "$ENV{DESTDIR}${file}" OR IS_SYMLINK "$ENV{DESTDIR}${file}") 17 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 18 | endif(EXISTS "$ENV{DESTDIR}${file}" OR IS_SYMLINK "$ENV{DESTDIR}${file}") 19 | endforeach(file) 20 | 21 | # remove pcl directory in include (removes all files in it!) 22 | message(STATUS "Uninstalling \"@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_ROOT@\"") 23 | if(EXISTS "@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_ROOT@") 24 | exec_program("@CMAKE_COMMAND@" 25 | ARGS "-E remove_directory \"@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_ROOT@\"" 26 | OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval) 27 | if(NOT "${rm_retval}" STREQUAL 0) 28 | message(FATAL_ERROR 29 | "Problem when removing \"@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_ROOT@\"") 30 | endif(NOT "${rm_retval}" STREQUAL 0) 31 | else(EXISTS "@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_ROOT@") 32 | message(STATUS 33 | "Directory \"@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_ROOT@\" does not exist.") 34 | endif(EXISTS "@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_ROOT@") 35 | 36 | # remove pcl directory in share (removes all files in it!) 37 | # created by CMakeLists.txt for PCLConfig.cmake 38 | message(STATUS "Uninstalling \"@CMAKE_INSTALL_PREFIX@/@PCLCONFIG_INSTALL_DIR@\"") 39 | if(EXISTS "@CMAKE_INSTALL_PREFIX@/@PCLCONFIG_INSTALL_DIR@") 40 | exec_program("@CMAKE_COMMAND@" 41 | ARGS "-E remove_directory \"@CMAKE_INSTALL_PREFIX@/@PCLCONFIG_INSTALL_DIR@\"" 42 | OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval) 43 | if(NOT "${rm_retval}" STREQUAL 0) 44 | message(FATAL_ERROR 45 | "Problem when removing \"@CMAKE_INSTALL_PREFIX@/@PCLCONFIG_INSTALL_DIR@\"") 46 | endif(NOT "${rm_retval}" STREQUAL 0) 47 | else(EXISTS "@CMAKE_INSTALL_PREFIX@/@PCLCONFIG_INSTALL_DIR@") 48 | message(STATUS 49 | "Directory \"@CMAKE_INSTALL_PREFIX@/@PCLCONFIG_INSTALL_DIR@\" does not exist.") 50 | endif(EXISTS "@CMAKE_INSTALL_PREFIX@/@PCLCONFIG_INSTALL_DIR@") 51 | -------------------------------------------------------------------------------- /core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SUBSYS_NAME core) 2 | set(SUBSYS_DESC "libpcl2_core: core structures") 3 | set(SUBSYS_DEPS) 4 | 5 | set(build TRUE) 6 | PCL_SUBSYS_OPTION(build ${SUBSYS_NAME} ${SUBSYS_DESC} ON) 7 | PCL_SUBSYS_DEPEND(build ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} EXT_DEPS eigen boost) 8 | 9 | #PCL_ADD_DOC(${SUBSYS_NAME}) 10 | 11 | if(build) 12 | set(srcs 13 | src/cloud.cpp 14 | src/matrix.cpp 15 | src/row.cpp 16 | src/eigen_matrix.cpp 17 | # src/conversions.cpp 18 | src/math.cpp 19 | src/stats.cpp 20 | #src/create.cpp 21 | ) 22 | 23 | set(incs 24 | include/pcl2/cloud.h 25 | # include/pcl2/conversions.h 26 | include/pcl2/core.h 27 | include/pcl2/create.h 28 | include/pcl2/eigen_matrix.h 29 | include/pcl2/eigen_matrix_impl.h 30 | include/pcl2/exception.h 31 | include/pcl2/kernels.h 32 | include/pcl2/math.h 33 | include/pcl2/matrix.h 34 | include/pcl2/matrix_impl.h 35 | include/pcl2/matrix_row_impl.h 36 | include/pcl2/matrix_view_impl.h 37 | include/pcl2/row.h 38 | include/pcl2/spatial_index.h 39 | include/pcl2/stats.h 40 | include/pcl2/typed_matrix.h 41 | include/pcl2/typed_matrix_impl.h 42 | ) 43 | 44 | set(impl_incs 45 | include/pcl2/impl/eigen_matrix.hpp 46 | include/pcl2/impl/eigen_matrix_impl.hpp 47 | include/pcl2/impl/math.hpp 48 | include/pcl2/impl/matrix_row_impl.hpp 49 | include/pcl2/impl/matrix_view_impl.hpp 50 | include/pcl2/impl/row.hpp 51 | include/pcl2/impl/stats.hpp 52 | include/pcl2/impl/typed_matrix.hpp 53 | #include/pcl2/impl/create.hpp 54 | ) 55 | 56 | set(LIB_NAME pcl2_${SUBSYS_NAME}) 57 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 58 | PCL_ADD_LIBRARY(${LIB_NAME} ${SUBSYS_NAME} ${srcs} ${incs} ${impl_incs}) 59 | PCL_ADD_SSE_FLAGS(${LIB_NAME}) 60 | PCL_MAKE_PKGCONFIG(${LIB_NAME} ${SUBSYS_NAME} "${SUBSYS_DESC}" "" "" "" "" "") 61 | 62 | # Install include files 63 | PCL_ADD_INCLUDES(${SUBSYS_NAME} "" ${incs}) 64 | PCL_ADD_INCLUDES(${SUBSYS_NAME} impl ${impl_incs}) 65 | 66 | #if(BUILD_TESTS) 67 | # add_subdirectory(test) 68 | #endif(BUILD_TESTS) 69 | 70 | #if(BUILD_EXAMPLES) 71 | # add_subdirectory(examples) 72 | #endif(BUILD_EXAMPLES) 73 | endif(build) 74 | -------------------------------------------------------------------------------- /core/include/pcl2/conversions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file conversions.h 39 | * \brief Declares several functions for converting between pcl and pcl2 data structures 40 | */ 41 | 42 | #ifndef PCL2_CONVERSIONS_H 43 | #define PCL2_CONVERSIONS_H 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | #include "pcl2/cloud.h" 50 | #include "pcl2/typed_matrix.h" 51 | 52 | namespace pcl2 53 | { 54 | 55 | pcl::PointCloud::Ptr 56 | convertToPointCloudXYZ (const MatF & xyz); 57 | 58 | boost::shared_ptr 59 | convertCloudToPointCloud2 (const Cloud & input); 60 | 61 | Cloud 62 | convertPointCloud2ToCloud (const sensor_msgs::PointCloud2 & input); 63 | 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /core/include/pcl2/core.h: -------------------------------------------------------------------------------- 1 | #include "pcl2/matrix.h" 2 | #include "pcl2/typed_matrix.h" 3 | #include "pcl2/row.h" 4 | #include "pcl2/cloud.h" 5 | -------------------------------------------------------------------------------- /core/include/pcl2/create.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file create.h 39 | * \brief Declares functions for creating matrices 40 | */ 41 | 42 | #ifndef PCL2_CREATE_H 43 | #define PCL2_CREATE_H 44 | 45 | #include "pcl2/eigen_matrix.h" 46 | #include 47 | #include 48 | 49 | namespace pcl2 50 | { 51 | 52 | template 53 | TypedMat 54 | createZeros (size_t rows, size_t cols) 55 | { 56 | EigenMat output (rows, cols); output << 0; return (output); 57 | } 58 | 59 | template 60 | TypedMat 61 | createOnes (size_t rows, size_t cols) 62 | { 63 | EigenMat output (rows, cols); output << 1; return (output); 64 | } 65 | 66 | template 67 | TypedMat 68 | createIdentity (size_t n) 69 | { 70 | EigenMat output (n, n); 71 | output << 0; 72 | for (size_t i = 0; i < n; ++i) 73 | output (i, i) = 1; 74 | return (output); 75 | } 76 | 77 | template 78 | TypedMat 79 | createRandom (size_t rows, size_t cols) 80 | { 81 | unsigned seed = static_cast (std::time(0)); 82 | boost::mt19937 generator (seed); 83 | boost::uniform_01<> uniform_dist; 84 | boost::variate_generator > rand (generator, uniform_dist); 85 | 86 | EigenMat output (rows, cols); 87 | for (size_t j = 0; j < cols; ++j) 88 | for (size_t i = 0; i < rows; ++i) 89 | output (i, j) = rand (); 90 | return (output); 91 | } 92 | 93 | template 94 | TypedMat 95 | createSeries (T start, T end, T step=1) 96 | { 97 | size_t nr_elements = ceil(1.0*(end - start) / step); 98 | EigenMat output (nr_elements, 1); 99 | 100 | size_t i = 0; 101 | for (T x = start; x < end; x += step) 102 | output (i++, 0) = x; 103 | 104 | return (output); 105 | } 106 | 107 | } 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /core/include/pcl2/eigen_matrix.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file eigen_matrix.h 39 | * \brief Contains class declarations for EigenMat and ConstEigenMat 40 | */ 41 | 42 | #ifndef PCL2_EIGEN_MATRIX_H 43 | #define PCL2_EIGEN_MATRIX_H 44 | 45 | #include "pcl2/typed_matrix.h" 46 | 47 | namespace pcl2 48 | { 49 | 50 | namespace core 51 | { 52 | template class EigenMatImpl; 53 | } 54 | 55 | /////////////////////////////////////////////////////////////////////////////// 56 | /** \brief A shared wrapper of an Eigen matrix 57 | * 58 | * Extends the TypedMat class to add constructors for creating new Eigen 59 | * matrices 60 | * \see ConstEigenMat 61 | */ 62 | template 63 | class EigenMat : public TypedMat 64 | { 65 | protected: 66 | using TypedMat::matrix_ptr_; 67 | 68 | private: 69 | EigenMat (); 70 | 71 | protected: 72 | /** \brief A shared pointer to the implementation */ 73 | typedef boost::shared_ptr MatImplPtr; 74 | 75 | /** \brief Construct a EigenMat around the provided MatImpl 76 | * 77 | * \throws Throws a BadCastException if the provided MatImpl cannot be cast 78 | * to an EigenMatrixImpl. 79 | * \todo Make this throw an exception instead of an assertion failure 80 | */ 81 | EigenMat (MatImplPtr matrix); 82 | 83 | public: 84 | /** \brief Construct a EigenMat from a generic Mat. 85 | * 86 | * \throws Throws a BadCastException if the provided matrix cannot be cast to an 87 | * EigenMatrix. 88 | * \todo Make this throw an exception instead of an assertion failure 89 | */ 90 | EigenMat (const Mat & shared_matrix); 91 | 92 | /** \brief Construct a new EigenMat with the specified number of rows and columns 93 | * 94 | * \param rows The number of rows 95 | * \param cols The number of cols 96 | */ 97 | EigenMat (size_t rows, size_t cols); 98 | 99 | protected: 100 | /** \brief A shared pointer to the matrix implementation */ 101 | boost::shared_ptr > eigen_matrix_ptr_; 102 | }; 103 | 104 | } 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /core/include/pcl2/eigen_matrix_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file eigen_matrix_impl.h 39 | * \brief Contains class declaration for pcl2::EigenMatImpl 40 | */ 41 | 42 | #ifndef PCL2_EIGEN_MATRIX_IMPL_H 43 | #define PCL2_EIGEN_MATRIX_IMPL_H 44 | 45 | #include "pcl2/eigen_matrix.h" 46 | 47 | #include "pcl2/matrix_impl.h" 48 | #include "pcl2/typed_matrix_impl.h" 49 | 50 | #include 51 | #include 52 | #include 53 | 54 | namespace pcl2 55 | { 56 | 57 | template class EigenMat; 58 | template class ConstEigenMat; 59 | 60 | namespace core 61 | { 62 | 63 | /** \brief The implementation for a shared Eigen matrix */ 64 | template 65 | class EigenMatImpl : public TypedMatImpl, public boost::enable_shared_from_this > 66 | { 67 | public: 68 | /** \brief a shared pointer to a EigenMatImpl */ 69 | typedef boost::shared_ptr > Ptr; 70 | 71 | /** \brief a const shared pointer to a EigenMatImpl */ 72 | typedef boost::shared_ptr > ConstPtr; 73 | 74 | private: 75 | /** \brief This constructor is disabled */ 76 | EigenMatImpl (); 77 | 78 | /** \brief The copy constructor is disabled */ 79 | EigenMatImpl (const EigenMatImpl & f); 80 | 81 | protected: 82 | /** \brief Construct a new EigenMatImpl with the specified number of rows and columns 83 | * 84 | * \param rows The number of rows 85 | * \param cols The number of cols 86 | */ 87 | EigenMatImpl (size_t rows, size_t cols); 88 | 89 | public: 90 | virtual MatImpl::Ptr copy () const; 91 | 92 | /** \brief Create a new EigenMatImpl of the given size 93 | * 94 | * \param rows The number of rows in the new matrix 95 | * \param cols The number of cols in the new matrix 96 | * \return A shared pointer to a new matrix 97 | */ 98 | virtual MatImpl::Ptr createNew (size_t rows, size_t cols) const; 99 | 100 | /** \brief Create a new MatViewImpl from this EigenMatImpl and the 101 | * provided indices 102 | * 103 | * \param indices A matrix of integers indexing rows of this matrix 104 | * \return A shared pointer to a new MatViewImpl 105 | */ 106 | virtual MatImpl::Ptr createView (const typename TypedMatImpl::ConstPtr & indices); 107 | 108 | virtual size_t rows () const; 109 | virtual size_t cols () const; 110 | 111 | virtual void fill (const TypedMatImpl & matrix_ptr); 112 | virtual void fill (const T & value); 113 | 114 | virtual typename TypedMatImpl::Ptr operator + (const T & operand) const; 115 | virtual typename TypedMatImpl::Ptr operator - (const T & operand) const; 116 | virtual typename TypedMatImpl::Ptr operator * (const T & operand) const; 117 | virtual typename TypedMatImpl::Ptr operator / (const T & operand) const; 118 | 119 | virtual typename TypedMatImpl::Ptr operator + (const TypedMatImpl & operand) const; 120 | virtual typename TypedMatImpl::Ptr operator - (const TypedMatImpl & operand) const; 121 | 122 | virtual void operator += (const TypedMatImpl & operand); 123 | virtual void operator -= (const TypedMatImpl & operand); 124 | virtual void operator *= (const TypedMatImpl & operand); 125 | virtual void operator /= (const TypedMatImpl & operand); 126 | 127 | /** \brief Access an element in the matrix 128 | * \param i The row of the element 129 | * \param j The column of the element 130 | * \return A reference to the element in the ith row and jth column 131 | */ 132 | virtual T & operator () (size_t i, size_t j); 133 | 134 | /** \brief Access an element in the matrix 135 | * \param i The row of the element 136 | * \param j The column of the element 137 | * \return A const reference to the element in the ith row and jth column 138 | */ 139 | virtual const T & operator () (size_t i, size_t j) const; 140 | 141 | protected: 142 | 143 | /** \brief The number of rows */ 144 | size_t rows_; 145 | 146 | /** \brief The number of columns */ 147 | size_t cols_; 148 | 149 | /** \brief The matrix data (stored in column major form) */ 150 | Eigen::Matrix data_; 151 | 152 | friend class pcl2::EigenMat; 153 | friend class pcl2::ConstEigenMat; 154 | }; 155 | 156 | } // namespace core 157 | } // namespace pcl2 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /core/include/pcl2/exception.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file exception.h 39 | * \brief Contains class definitions for pcl2::Exception and its various subclasses 40 | */ 41 | 42 | #ifndef PCL2_EXCEPTION_H 43 | #define PCL2_EXCEPTION_H 44 | 45 | #include 46 | 47 | namespace pcl2 48 | { 49 | 50 | /** \brief The base exception class */ 51 | class Exception 52 | { 53 | public: 54 | /** \brief Get the exception's description 55 | * \return A string describing the exception 56 | */ 57 | virtual std::string what () { return ("GenericException"); } 58 | }; 59 | 60 | /** \brief Bad cast exception 61 | * 62 | * Thrown when attempting to convert a pointer to an improper type 63 | */ 64 | class BadCastException : public Exception 65 | { 66 | public: 67 | virtual std::string what () { return ("BadCastException"); } 68 | }; 69 | 70 | /** \brief Channel not found exception 71 | * 72 | * Thrown when attempting to access a non-existent channel 73 | */ 74 | class ChannelNotFoundException : public Exception 75 | { 76 | public: 77 | virtual std::string what () { return ("ChannelNotFoundException"); } 78 | }; 79 | 80 | /** \brief Incompatible size exception 81 | * 82 | * Thrown when attempting to perform an operation with clouds/matrices whose 83 | * sizes are mismatched. 84 | */ 85 | class IncompatibleSizeException : public Exception 86 | { 87 | public: 88 | virtual std::string what () { return ("IncompatibleSizesException"); } 89 | }; 90 | 91 | } 92 | 93 | #endif // PCL2_EXCEPTION_H 94 | -------------------------------------------------------------------------------- /core/include/pcl2/impl/eigen_matrix.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file eigen_matrix.hpp 39 | * \brief Contains class definitions for pcl2::EigenMat and pcl2::ConstEigenMat 40 | */ 41 | 42 | #ifndef PCL2_EIGEN_MATRIX_HPP 43 | #define PCL2_EIGEN_MATRIX_HPP 44 | 45 | #include "pcl2/eigen_matrix.h" 46 | 47 | #include "pcl2/impl/typed_matrix.hpp" 48 | #include "pcl2/impl/eigen_matrix_impl.hpp" 49 | 50 | template 51 | pcl2::EigenMat::EigenMat (core::MatImpl::Ptr matrix) : TypedMat (matrix) 52 | { 53 | eigen_matrix_ptr_ = boost::dynamic_pointer_cast > (matrix); 54 | assert (eigen_matrix_ptr_); 55 | } 56 | 57 | template 58 | pcl2::EigenMat::EigenMat (const Mat & shared_matrix) : TypedMat (shared_matrix) 59 | { 60 | eigen_matrix_ptr_ = boost::dynamic_pointer_cast > (matrix_ptr_); 61 | assert (eigen_matrix_ptr_); 62 | } 63 | 64 | template 65 | pcl2::EigenMat::EigenMat (size_t rows, size_t cols) : 66 | TypedMat (typename core::EigenMatImpl::Ptr (new core::EigenMatImpl (rows, cols))) 67 | { 68 | eigen_matrix_ptr_ = boost::dynamic_pointer_cast > (matrix_ptr_); 69 | assert (eigen_matrix_ptr_); 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /core/include/pcl2/impl/row.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file row.hpp 39 | * \brief Contains class definitions for pcl2::EigenMat and pcl2::ConstEigenMat 40 | */ 41 | 42 | #ifndef PCL2_ROW_HPP 43 | #define PCL2_ROW_HPP 44 | 45 | #include "pcl2/row.h" 46 | #include "pcl2/impl/matrix_row_impl.hpp" 47 | 48 | 49 | template 50 | pcl2::Row::Row (boost::shared_ptr > matrix_ptr, size_t row) : 51 | TypedMat (typename core::MatRowImpl::Ptr (new core::MatRowImpl (matrix_ptr, row))) 52 | { 53 | typedef core::MatRowImpl Impl; 54 | mat_row_ptr_ = boost::dynamic_pointer_cast (matrix_ptr_); 55 | } 56 | 57 | template int 58 | pcl2::Row::getIndex () const 59 | { 60 | return (mat_row_ptr_->getIndex ()); 61 | } 62 | 63 | template bool 64 | pcl2::Row::hasNext () const 65 | { 66 | return (mat_row_ptr_->hasNext ()); 67 | } 68 | 69 | template void 70 | pcl2::Row::advance () 71 | { 72 | mat_row_ptr_->advance (); 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /core/include/pcl2/impl/stats.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file stats.hpp 39 | * \brief Defines functions for computing statistical properties of a matrix 40 | */ 41 | 42 | #include "pcl2/stats.h" 43 | #include "pcl2/row.h" 44 | #include "pcl2/eigen_matrix.h" 45 | #include "pcl2/math.h" 46 | 47 | template 48 | pcl2::TypedMat 49 | pcl2::computeMean (const TypedMat & input) 50 | { 51 | EigenMat sum = computeSum (input); 52 | return (sum / input.rows ()); 53 | } 54 | 55 | template 56 | pcl2::TypedMat 57 | pcl2::computeCovariance (const TypedMat & input) 58 | { 59 | TypedMat mean = computeMean (input); 60 | return (computeCovariance (input, mean)); 61 | } 62 | 63 | template 64 | pcl2::TypedMat 65 | pcl2::computeCovariance (const TypedMat & input, const TypedMat & mean) 66 | { 67 | EigenMat unnormalized_cov (input.cols (), input.cols ()); 68 | unnormalized_cov.fill (0); 69 | for (typename TypedMat::Row row = input (0); row.hasNext (); row.advance ()) 70 | { 71 | TypedMat demeaned_row = row - mean; 72 | unnormalized_cov += computeOuterProduct (demeaned_row, demeaned_row); 73 | } 74 | return (unnormalized_cov / (input.rows () - 1)); 75 | } 76 | 77 | template 78 | void 79 | pcl2::computeMeanAndCovariance (const TypedMat & input, TypedMat & mean, TypedMat & covariance) 80 | { 81 | mean = computeMean (input); 82 | covariance = computeCovariance (input, mean); 83 | } 84 | -------------------------------------------------------------------------------- /core/include/pcl2/math.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file math.h 39 | * \brief Declares functions for performing basic arithmethic on matrices 40 | */ 41 | 42 | #ifndef PCL2_MATH_H 43 | #define PCL2_MATH_H 44 | 45 | #include "pcl2/typed_matrix.h" 46 | 47 | namespace pcl2 48 | { 49 | 50 | template 51 | TypedMat 52 | computeSum (const TypedMat & input); 53 | 54 | template 55 | TypedMat 56 | computeProduct (const TypedMat & input); 57 | 58 | template 59 | TypedMat 60 | computeCumulativeSum (const TypedMat & input); 61 | 62 | template 63 | TypedMat 64 | computeCumulativeProduct (const TypedMat & input); 65 | 66 | template 67 | TypedMat 68 | computeOuterSum (const TypedMat & vec1, const TypedMat & vec2); 69 | 70 | template 71 | TypedMat 72 | computeOuterProduct (const TypedMat & vec1, const TypedMat & vec2); 73 | 74 | // --- Move these to a different file --- 75 | template 76 | TypedMat 77 | computeEigenvalues3x3 (const TypedMat & input); 78 | 79 | template 80 | TypedMat 81 | computeEigenvectors3x3 (const TypedMat & input); 82 | 83 | template 84 | void 85 | computeEigendecomposition3x3 (const TypedMat & input, TypedMat & eigenvalues, TypedMat & eigenvectors); 86 | 87 | 88 | 89 | } 90 | #endif 91 | -------------------------------------------------------------------------------- /core/include/pcl2/matrix.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file matrix.h 39 | * \brief Contains class declaration for pcl2::Mat 40 | */ 41 | 42 | #ifndef PCL2_MATRIX_H 43 | #define PCL2_MATRIX_H 44 | 45 | #include 46 | 47 | namespace pcl2 48 | { 49 | 50 | // Forward declarations 51 | namespace core 52 | { 53 | class MatImpl; 54 | } 55 | 56 | template class TypedMat; 57 | 58 | /** \brief This class defines a shared 2D matrix object and serves as the core 59 | * matrix data structure in PCL 60 | * 61 | * This is the data structure in which all point data is stored (e.g., a point's 62 | * x,y,z-position, color, 3D surface normal, feature descritor, etc.). When 63 | * representing point data, each row of the matrix will represent a single 64 | * point, and each column will represent a dimension. For example, a cloud of N 65 | * 3-dimensional points, will be stored as an N by 3 Mat. Such Mats of 66 | * point data are often labeled with a channel name (e.g., "xyz") and stored in 67 | * a Cloud object so that multiple channels of data can be associated together. 68 | * 69 | * \note This class serves as a pointer to the actual data, so copying this 70 | * object does not create a unique copy of its data. The actual implementation 71 | * (i.e., the data and methods for operating on it) is contained in an internal 72 | * MatImpl object. These MatImpl classes should never be used directly. 73 | * 74 | * \see TypedMat 75 | * \see EigenMat 76 | */ 77 | class Mat 78 | { 79 | private: 80 | Mat (); 81 | 82 | protected: 83 | /** \brief A shared pointer to the implementation */ 84 | typedef boost::shared_ptr MatImplPtr; 85 | 86 | /** \brief Construct a Mat around the provided MatImpl */ 87 | Mat (const MatImplPtr matrix_ptr); 88 | 89 | /** \brief Get the shared pointer to the underlying MatImpl 90 | * 91 | * \return A shared pointer to the underlying MatImpl 92 | */ 93 | virtual MatImplPtr getPtr (); 94 | 95 | /** \brief Get a const shared pointer to the underlying Mat 96 | * 97 | * \return A shared pointer to the underlying Mat 98 | */ 99 | virtual const MatImplPtr getPtr () const; 100 | 101 | public: 102 | /** \brief Create a new copy of this matrix and its data 103 | * 104 | * \return A shared matrix with a new copy of the underlying data 105 | */ 106 | virtual Mat copy () const; 107 | 108 | /** \brief Get the number of rows in the matrix 109 | * 110 | * \return The number of rows in the matrix 111 | */ 112 | virtual size_t rows () const; 113 | 114 | /** \brief Get the number of columns in the matrix 115 | * 116 | * \return The number of columns in the matrix 117 | */ 118 | virtual size_t cols () const; 119 | 120 | /** \brief Create a view of a subset of rows in this matrix 121 | * 122 | * This operator creates a view of the matrix based on a matrix of indices. 123 | * The resulting view will contain a row for each row index defined in 124 | * \a indices. The elements in each row of the view will be references to the 125 | * corresponding elements in the original matrix. 126 | * 127 | * Note that the matrix data is not copied; any changes made to the view's data 128 | * will also affect the corresponding values in the original matrix and vice 129 | * versa. 130 | * 131 | * \param indices An N by 1 matrix of integer indices in the matrix. Each 132 | * element in must be a valid row index in the matrix. 133 | * \return An NxM matrix referencing the rows indexed by \a indices, where N is 134 | * the number of rows in \a indices and M is the number of columns in the 135 | * original matrix. 136 | */ 137 | Mat operator () (const TypedMat & indices); 138 | 139 | protected: 140 | /** A pointer to the underlying MatImpl containing the actual data */ 141 | boost::shared_ptr matrix_ptr_; 142 | 143 | template friend class TypedMat; 144 | 145 | }; 146 | 147 | } 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /core/include/pcl2/matrix_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file matrix_impl.h 39 | * \brief Contains class declaration for pcl2::MatImpl 40 | */ 41 | 42 | #ifndef PCL2_MATRIX_IMPL_H 43 | #define PCL2_MATRIX_IMPL_H 44 | 45 | #include 46 | 47 | namespace pcl2 48 | { 49 | namespace core 50 | { 51 | 52 | template class TypedMatImpl; 53 | 54 | /** \brief An abstract class defining the matrix implementation interface. 55 | * For internal use only. 56 | * 57 | * Subclasses of MatImpl will provide the actual implementation for the Mat 58 | * class. They are responsible for storing the actual matrix data and providing 59 | * various methods for operating on it. 60 | * 61 | * \note These MatImpl classes are intended to be used exclusively by Mat 62 | * and its subclasses. PCL users are not meant to use MatImpl or any of its 63 | * subclasses in their code. 64 | */ 65 | class MatImpl 66 | { 67 | public: 68 | /** \brief A shared pointer to an MatImpl */ 69 | typedef boost::shared_ptr Ptr; 70 | 71 | /** \brief A const shared pointer to an MatImpl */ 72 | typedef boost::shared_ptr ConstPtr; 73 | 74 | /** \brief Create a new copy of this matrix and its data 75 | * 76 | * \return A shared pointer to a new copy of this matrix 77 | */ 78 | virtual MatImpl::Ptr copy () const = 0; 79 | 80 | /** \brief Create a new MatImpl of the given size 81 | * 82 | * \param rows The number of rows in the new matrix 83 | * \param cols The number of cols in the new matrix 84 | * \return A shared pointer to a new matrix 85 | */ 86 | virtual MatImpl::Ptr createNew (size_t rows, size_t cols) const = 0; 87 | 88 | /** \brief Create a new MatViewImpl from this MatImpl and the provided 89 | * indices 90 | * 91 | * \param indices An matrix of integers indexing rows of this matrix 92 | * \return A shared pointer to a new MatViewImpl 93 | */ 94 | virtual MatImpl::Ptr createView (const boost::shared_ptr > & indices) = 0; 95 | 96 | /** \brief Get the number of rows in the matrix 97 | * 98 | * \return The number of rows in the matrix 99 | */ 100 | virtual size_t rows () const = 0; 101 | 102 | /** \brief Get the number of columns in the matrix 103 | * 104 | * \return The number of columns in the matrix 105 | */ 106 | virtual size_t cols () const = 0; 107 | 108 | }; 109 | 110 | } // namespace core 111 | } // namespace pcl2 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /core/include/pcl2/matrix_row_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file matrix_row_impl.h 39 | * \brief Contains class declaration for pcl2::MatRowImpl 40 | */ 41 | 42 | #ifndef PCL2_MATRIX_ROW_IMPL_H 43 | #define PCL2_MATRIX_ROW_IMPL_H 44 | 45 | #include "typed_matrix_impl.h" 46 | 47 | #include 48 | #include 49 | 50 | namespace pcl2 51 | { 52 | namespace core 53 | { 54 | 55 | /** \todo Document this class */ 56 | template 57 | class MatRowImpl : public TypedMatImpl, public boost::enable_shared_from_this > 58 | { 59 | public: 60 | /** \brief A shared pointer to a MatRowImpl */ 61 | typedef boost::shared_ptr > Ptr; 62 | typedef boost::shared_ptr > ConstPtr; 63 | 64 | protected: 65 | MatRowImpl (); 66 | MatRowImpl (const MatRowImpl & a); 67 | 68 | public: 69 | /** \todo document this */ 70 | MatRowImpl (typename TypedMatImpl::Ptr matrix, size_t row_index); 71 | 72 | virtual MatImpl::Ptr copy () const; 73 | 74 | virtual MatImpl::Ptr createNew (size_t rows, size_t cols) const; 75 | virtual MatImpl::Ptr createView (const TypedMatImpl::ConstPtr & indices); 76 | 77 | virtual size_t rows () const; 78 | virtual size_t cols () const; 79 | 80 | virtual void fill (const TypedMatImpl & matrix); 81 | virtual void fill (const T & value); 82 | 83 | virtual typename TypedMatImpl::Ptr operator + (const T & operand) const; 84 | virtual typename TypedMatImpl::Ptr operator - (const T & operand) const; 85 | virtual typename TypedMatImpl::Ptr operator * (const T & operand) const; 86 | virtual typename TypedMatImpl::Ptr operator / (const T & operand) const; 87 | 88 | virtual typename TypedMatImpl::Ptr operator + (const TypedMatImpl & operand) const; 89 | virtual typename TypedMatImpl::Ptr operator - (const TypedMatImpl & operand) const; 90 | 91 | virtual void operator += (const TypedMatImpl & operand); 92 | virtual void operator -= (const TypedMatImpl & operand); 93 | virtual void operator *= (const TypedMatImpl & operand); 94 | virtual void operator /= (const TypedMatImpl & operand); 95 | 96 | virtual T & operator () (size_t i, size_t j); 97 | virtual const T & operator () (size_t i, size_t j) const; 98 | 99 | inline size_t getIndex () const 100 | { 101 | return (row_index_); 102 | } 103 | 104 | inline bool hasNext () const 105 | { 106 | return (row_index_ < matrix_ptr_->rows ()); 107 | } 108 | 109 | inline void advance () 110 | { 111 | assert (hasNext ()); 112 | ++row_index_; 113 | } 114 | 115 | protected: 116 | /** \todo document this */ 117 | typename TypedMatImpl::Ptr matrix_ptr_; 118 | 119 | /** The index of the row being referenced by this MatRowImpl */ 120 | size_t row_index_; 121 | 122 | }; 123 | 124 | } // namespace core 125 | } // namespace pcl2 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /core/include/pcl2/matrix_view_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file matrix_view_impl.h 39 | * \brief Contains class declaration for pcl2::MatViewImpl 40 | */ 41 | 42 | #ifndef PCL2_MATRIX_VIEW_IMPL_H 43 | #define PCL2_MATRIX_VIEW_IMPL_H 44 | 45 | #include "typed_matrix_impl.h" 46 | 47 | namespace pcl2 48 | { 49 | namespace core 50 | { 51 | 52 | /** \brief A "view" into a matrix, appearing to contain only the specified subset 53 | * and/or permutation of rows from the original matrix. 54 | * 55 | * A MatViewImpl wraps a source matrix and a list of indices and creates a new 56 | * matrix that appears to contain a row for each index in the provided indices, 57 | * where the elements in each row of the view correspond to the elements at that 58 | * row in the source matrix. Note that although a view can be used like a true 59 | * matrix, it is not an independent copy of the source matrix. Thus, any changes 60 | * made to a view's data will also affect the corresponding values in the source 61 | * matrix and vice versa. 62 | */ 63 | template 64 | class MatViewImpl : public TypedMatImpl, public boost::enable_shared_from_this > 65 | { 66 | public: 67 | /** \brief A shared pointer to a MatViewImpl */ 68 | typedef boost::shared_ptr > Ptr; 69 | 70 | protected: 71 | MatViewImpl (); 72 | MatViewImpl (const MatViewImpl & a); 73 | 74 | public: 75 | /** \brief Create a view into the specified rows of the provided matrix 76 | * 77 | * This constructor creates a view from a source \a matrix and a matrix of 78 | * \a indices. The resulting view will contain a row for each row index 79 | * defined in \a indices, and the elements in each row of the view will be 80 | * references to the corresponding elements in the original matrix. 81 | * 82 | * \param matrix The source matrix (i.e., the matrix that is to be "viewed") 83 | * \param indices A matrix of integers indexing rows of the source \a matrix. 84 | */ 85 | MatViewImpl (typename TypedMatImpl::Ptr matrix_ptr, TypedMatImpl::ConstPtr indices_ptr); 86 | 87 | virtual MatImpl::Ptr copy () const; 88 | 89 | virtual MatImpl::Ptr createNew (size_t rows, size_t cols) const; 90 | virtual MatImpl::Ptr createView (const TypedMatImpl::ConstPtr & indices); 91 | 92 | virtual size_t rows () const; 93 | virtual size_t cols () const; 94 | 95 | virtual void fill (const TypedMatImpl & matrix); 96 | virtual void fill (const T & value); 97 | 98 | virtual typename TypedMatImpl::Ptr operator + (const T & operand) const; 99 | virtual typename TypedMatImpl::Ptr operator - (const T & operand) const; 100 | virtual typename TypedMatImpl::Ptr operator * (const T & operand) const; 101 | virtual typename TypedMatImpl::Ptr operator / (const T & operand) const; 102 | 103 | virtual typename TypedMatImpl::Ptr operator + (const TypedMatImpl & operand) const; 104 | virtual typename TypedMatImpl::Ptr operator - (const TypedMatImpl & operand) const; 105 | 106 | virtual void operator += (const TypedMatImpl & operand); 107 | virtual void operator -= (const TypedMatImpl & operand); 108 | virtual void operator *= (const TypedMatImpl & operand); 109 | virtual void operator /= (const TypedMatImpl & operand); 110 | 111 | virtual T & operator () (size_t i, size_t j); 112 | virtual const T & operator () (size_t i, size_t j) const; 113 | 114 | protected: 115 | /** The matrix being "viewed" */ 116 | typename TypedMatImpl::Ptr matrix_ptr_; 117 | 118 | /** The list of indices into matrix_ that defines this view */ 119 | TypedMatImpl::ConstPtr indices_ptr_; 120 | 121 | }; 122 | 123 | } // namespace core 124 | } // namespace pcl2 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /core/include/pcl2/row.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file row.h 39 | * \brief Contains class declarations for Row and ConstRow 40 | */ 41 | 42 | #ifndef PCL2_ROW_H 43 | #define PCL2_ROW_H 44 | 45 | #include "pcl2/typed_matrix.h" 46 | 47 | #include 48 | #include 49 | #include 50 | 51 | namespace pcl2 52 | { 53 | template class TypedMat; 54 | namespace core 55 | { 56 | template class TypedMatImpl; 57 | template class MatRowImpl; 58 | } 59 | 60 | /////////////////////////////////////////////////////////////////////////////// 61 | /** \brief \todo Write me 62 | * 63 | * Extends the TypedMat class to... 64 | */ 65 | template 66 | class Row : public TypedMat 67 | { 68 | protected: 69 | using TypedMat::matrix_ptr_; 70 | 71 | private: 72 | Row (); 73 | 74 | protected: 75 | /** \brief Construct a Row view into the provided TypedMatImpl 76 | */ 77 | Row (boost::shared_ptr > matrix_ptr, size_t row); 78 | 79 | public: 80 | int 81 | getIndex () const; 82 | 83 | bool 84 | hasNext () const; 85 | 86 | void 87 | advance (); 88 | 89 | protected: 90 | /** \brief A shared pointer to the matrix implementation */ 91 | boost::shared_ptr > mat_row_ptr_; 92 | 93 | friend class TypedMat; 94 | }; 95 | 96 | template 97 | std::ostream& operator << (std::ostream& out, const pcl2::Row & row) 98 | { 99 | for (size_t i = 0; i < row.cols (); ++i) 100 | out << row (0, i) << " "; 101 | 102 | return (out); 103 | } 104 | 105 | } 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /core/include/pcl2/spatial_index.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2011, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file spatial_index.h 39 | * \brief Contains class declaration for pcl2::SpatialIndex 40 | */ 41 | 42 | #ifndef PCL2_SPATIAL_INDEX_H 43 | #define PCL2_SPATIAL_INDEX_H 44 | 45 | // see http://en.wikipedia.org/wiki/Spatial_database#Spatial_Index 46 | 47 | #include "pcl2/typed_matrix.h" 48 | #include 49 | 50 | namespace pcl2 51 | { 52 | 53 | template 54 | class SpatialIndex 55 | { 56 | public: 57 | typedef TypedMat MatT; 58 | typedef boost::shared_ptr > Ptr; 59 | 60 | virtual void 61 | buildIndex (const MatT & input) = 0; 62 | 63 | virtual MatI 64 | findKNearestNeighbors (const MatT & query, size_t k) const = 0; 65 | 66 | virtual MatI 67 | findFixedRadiusNeighbors (const MatT & query, float r) const = 0; 68 | 69 | virtual std::pair 70 | findKNearestNeighborsAndDistances (const MatT & query, size_t k) const = 0; 71 | 72 | virtual std::pair 73 | findFixedRadiusNeighborsAndDistances (const MatT & query, float r) const = 0; 74 | }; 75 | 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /core/include/pcl2/stats.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file stats.h 39 | * \brief Declares functions for computing statistical properties of a matrix 40 | */ 41 | 42 | #ifndef PCL2_STATS_H 43 | #define PCL2_STATS_H 44 | 45 | #include "pcl2/typed_matrix.h" 46 | 47 | namespace pcl2 48 | { 49 | 50 | template 51 | TypedMat 52 | computeMean (const TypedMat & input); 53 | 54 | template 55 | TypedMat 56 | computeCovariance (const TypedMat & input); 57 | 58 | template 59 | TypedMat 60 | computeCovariance (const TypedMat & input, const TypedMat & mean); 61 | 62 | template 63 | void 64 | computeMeanAndCovariance (const TypedMat & input, TypedMat & mean, TypedMat & covariance); 65 | 66 | 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /core/include/pcl2/typed_matrix_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file typed_matrix_impl.h 39 | * \brief Contains class declaration for pcl2::TypedMatImpl 40 | */ 41 | 42 | #ifndef PCL2_TYPED_MATRIX_IMPL_H 43 | #define PCL2_TYPED_MATRIX_IMPL_H 44 | #include 45 | #include "pcl2/matrix_impl.h" 46 | #include "pcl2/spatial_index.h" 47 | 48 | namespace pcl2 49 | { 50 | 51 | template class SpatialIndex; 52 | 53 | namespace core 54 | { 55 | 56 | /** \brief An abstract matrix implementation templated on scalar type 57 | * (e.g., float, int) 58 | * 59 | * The TypedMatImpl class extends the base MatImpl class to add element 60 | * accessors. It must be templated on the matrix's scalar type. 61 | */ 62 | template 63 | class TypedMatImpl : public MatImpl 64 | { 65 | 66 | public: 67 | /** \brief A shared pointer to a TypedMatImpl */ 68 | typedef boost::shared_ptr > Ptr; 69 | 70 | /** \brief A const shared pointer to a TypedMatImpl */ 71 | typedef boost::shared_ptr > ConstPtr; 72 | 73 | /** \brief Fill in the values of this matrix using the values from the provided 74 | * matrix 75 | * \param matrix_ptr The matrix whose values will be copied into this matrix. 76 | * The size of the input matrix must be compatible with the matrix being filled. 77 | * 78 | * \throws IncompatibleSizeException 79 | * \see Mat::fill (const Mat & matrix) 80 | */ 81 | virtual void fill (const TypedMatImpl & matrix) = 0; 82 | 83 | virtual void fill (const T & value) = 0; 84 | 85 | /** \brief Access an element in the matrix 86 | * \param i The row of the element 87 | * \param j The column of the element 88 | * \return A reference to the element in the ith row and jth column 89 | */ 90 | virtual T & operator () (size_t i, size_t j) = 0; 91 | 92 | /** \brief Access an element in the matrix 93 | * \param i The row of the element 94 | * \param j The column of the element 95 | * \return A const reference to the element in the ith row and jth column 96 | */ 97 | virtual const T & operator () (size_t i, size_t j) const = 0; 98 | 99 | /** \brief Perform scalar addition */ 100 | virtual typename TypedMatImpl::Ptr operator + (const T & operand) const = 0; 101 | /** \brief Perform scalar subtraction */ 102 | virtual typename TypedMatImpl::Ptr operator - (const T & operand) const = 0; 103 | /** \brief Perform scalar multiplication */ 104 | virtual typename TypedMatImpl::Ptr operator * (const T & operand) const = 0; 105 | /** \brief Perform scalar division */ 106 | virtual typename TypedMatImpl::Ptr operator / (const T & operand) const = 0; 107 | 108 | /** \brief Perform element-wise addition */ 109 | virtual typename TypedMatImpl::Ptr operator + (const TypedMatImpl & operand) const = 0; 110 | /** \brief Perform element-wise subtraction */ 111 | virtual typename TypedMatImpl::Ptr operator - (const TypedMatImpl & operand) const = 0; 112 | 113 | /** \brief Perform in-place element-wise addition */ 114 | virtual void operator += (const TypedMatImpl & operand) = 0; 115 | /** \brief Perform in-place element-wise subtraction */ 116 | virtual void operator -= (const TypedMatImpl & operand) = 0; 117 | /** \brief Perform in-place element-wise multiplication */ 118 | virtual void operator *= (const TypedMatImpl & operand) = 0; 119 | /** \brief Perform in-place element-wise division */ 120 | virtual void operator /= (const TypedMatImpl & operand) = 0; 121 | 122 | mutable typename SpatialIndex::Ptr spatial_index_; 123 | }; 124 | 125 | } // namespace core 126 | } // namespace pcl2 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /core/src/cloud.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file cloud.cpp 39 | * \brief Contains class definition for \ref pcl2::Cloud 40 | */ 41 | 42 | #include "pcl2/cloud.h" 43 | 44 | pcl2::Cloud::Cloud () : size_ (0) 45 | { 46 | 47 | } 48 | 49 | pcl2::Cloud::Cloud (const std::string & channel_name, Mat channel_data) : size_ (channel_data.rows ()) 50 | { 51 | channels_.emplace (channel_name, channel_data); 52 | } 53 | 54 | size_t 55 | pcl2::Cloud::size () const 56 | { 57 | return (size_); 58 | } 59 | 60 | size_t 61 | pcl2::Cloud::channelCount () const 62 | { 63 | return (channels_.size ()); 64 | } 65 | 66 | bool 67 | pcl2::Cloud::empty () const 68 | { 69 | return (channelCount () == 0); 70 | } 71 | 72 | std::vector 73 | pcl2::Cloud::getChannelNames () const 74 | { 75 | std::vector names (channelCount ()); 76 | ChannelMap::const_iterator itr = channels_.begin (); 77 | for (size_t i = 0; i < names.size (); ++i) 78 | { 79 | names[i] = itr->first; 80 | ++itr; 81 | } 82 | return (names); 83 | } 84 | 85 | pcl2::Mat & 86 | pcl2::Cloud::operator[] (const std::string & channel_name) 87 | { 88 | ChannelMap::iterator itr = channels_.find (channel_name); 89 | if (itr == channels_.end ()) 90 | { 91 | throw ChannelNotFoundException (); 92 | } 93 | return (itr->second); 94 | } 95 | 96 | const pcl2::Mat & 97 | pcl2::Cloud::operator[] (const std::string & channel_name) const 98 | { 99 | ChannelMap::const_iterator itr = channels_.find (channel_name); 100 | if (itr == channels_.end ()) 101 | { 102 | throw ChannelNotFoundException (); 103 | } 104 | return (itr->second); 105 | } 106 | 107 | #include 108 | pcl2::Cloud 109 | pcl2::Cloud::operator() (const TypedMat & indices) 110 | { 111 | Cloud output; 112 | for (ChannelMap::iterator itr = channels_.begin (); itr != channels_.end (); ++itr) 113 | { 114 | output.insert (itr->first, itr->second (indices)); 115 | } 116 | return (output); 117 | } 118 | 119 | bool 120 | pcl2::Cloud::hasChannel (const std::string & channel_name) const 121 | { 122 | return (channels_.count (channel_name) > 0); 123 | } 124 | 125 | void 126 | pcl2::Cloud::insert (const std::string & channel_name, Mat channel_data) 127 | { 128 | if (!empty ()) 129 | { 130 | // Check if sizes match 131 | if (channel_data.rows () != size_) 132 | { 133 | throw IncompatibleSizeException (); 134 | } 135 | } 136 | else 137 | { 138 | size_ = channel_data.rows (); 139 | } 140 | channels_.emplace (channel_name, channel_data); 141 | } 142 | 143 | void 144 | pcl2::Cloud::remove (const std::string & channel_name) 145 | { 146 | size_t n = channels_.erase (channel_name); 147 | if (n == 0) 148 | throw pcl2::ChannelNotFoundException (); 149 | } 150 | 151 | pcl2::Cloud & 152 | pcl2::Cloud::operator += (const Cloud & cloud) 153 | { 154 | /// \todo Implement a cloud.begin () and cloud.end () 155 | for (ChannelMap::const_iterator itr = cloud.channels_.begin (); 156 | itr != cloud.channels_.end (); 157 | ++itr) 158 | { 159 | channels_.emplace (itr->first, itr->second); 160 | } 161 | return (*this); 162 | } 163 | 164 | pcl2::Cloud 165 | pcl2::Cloud::copy () const 166 | { 167 | Cloud cloud_copy; 168 | for (ChannelMap::const_iterator itr = channels_.begin (); 169 | itr != channels_.end (); 170 | ++itr) 171 | { 172 | cloud_copy.channels_.emplace (itr->first, itr->second.copy ()); 173 | } 174 | return (cloud_copy); 175 | } 176 | -------------------------------------------------------------------------------- /core/src/eigen_matrix.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | #include "pcl2/impl/eigen_matrix.hpp" 39 | 40 | template class pcl2::TypedMat; 41 | template class pcl2::TypedMat; 42 | template class pcl2::TypedMat; 43 | 44 | template class pcl2::EigenMat; 45 | template class pcl2::EigenMat; 46 | template class pcl2::EigenMat; 47 | 48 | /// \todo Move this! 49 | template std::ostream& pcl2::operator << (std::ostream&, const pcl2::TypedMat &); 50 | template std::ostream& pcl2::operator << (std::ostream&, const pcl2::TypedMat &); 51 | template std::ostream& pcl2::operator << (std::ostream&, const pcl2::TypedMat &); 52 | -------------------------------------------------------------------------------- /core/src/math.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file math.h 39 | * \brief Instantiate functions for performing basic arithmethic on matrices 40 | */ 41 | 42 | #include "pcl2/impl/math.hpp" 43 | 44 | template pcl2::TypedMat pcl2::computeSum (const TypedMat &); 45 | template pcl2::TypedMat pcl2::computeSum (const TypedMat &); 46 | template pcl2::TypedMat pcl2::computeSum (const TypedMat &); 47 | 48 | template pcl2::TypedMat pcl2::computeProduct (const TypedMat &); 49 | template pcl2::TypedMat pcl2::computeProduct (const TypedMat &); 50 | template pcl2::TypedMat pcl2::computeProduct (const TypedMat &); 51 | 52 | template pcl2::TypedMat pcl2::computeCumulativeSum (const TypedMat &); 53 | template pcl2::TypedMat pcl2::computeCumulativeSum (const TypedMat &); 54 | template pcl2::TypedMat pcl2::computeCumulativeSum (const TypedMat &); 55 | 56 | template pcl2::TypedMat pcl2::computeCumulativeProduct (const TypedMat &); 57 | template pcl2::TypedMat pcl2::computeCumulativeProduct (const TypedMat &); 58 | template pcl2::TypedMat pcl2::computeCumulativeProduct (const TypedMat &); 59 | 60 | template pcl2::TypedMat pcl2::computeOuterSum (const TypedMat &, const TypedMat &); 61 | template pcl2::TypedMat pcl2::computeOuterSum (const TypedMat &, const TypedMat &); 62 | template pcl2::TypedMat pcl2::computeOuterSum (const TypedMat &, const TypedMat &); 63 | 64 | template pcl2::TypedMat pcl2::computeOuterProduct (const TypedMat &, const TypedMat &); 65 | template pcl2::TypedMat pcl2::computeOuterProduct (const TypedMat &, const TypedMat &); 66 | template pcl2::TypedMat pcl2::computeOuterProduct (const TypedMat &, const TypedMat &); 67 | 68 | template pcl2::TypedMat pcl2::computeEigenvalues3x3 (const TypedMat &); 69 | template pcl2::TypedMat pcl2::computeEigenvalues3x3 (const TypedMat &); 70 | 71 | template pcl2::TypedMat pcl2::computeEigenvectors3x3 (const TypedMat &); 72 | template pcl2::TypedMat pcl2::computeEigenvectors3x3 (const TypedMat &); 73 | 74 | template void pcl2::computeEigendecomposition3x3 (const TypedMat &, TypedMat &, TypedMat &); 75 | template void pcl2::computeEigendecomposition3x3 (const TypedMat &, TypedMat &, TypedMat &); 76 | -------------------------------------------------------------------------------- /core/src/matrix.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file matrix.cpp 39 | * \brief Contains class definition for \ref pcl2::Mat 40 | */ 41 | 42 | #include 43 | #include "pcl2/matrix.h" 44 | #include "pcl2/matrix_impl.h" 45 | #include "pcl2/typed_matrix.h" 46 | 47 | #include "pcl2/matrix_view_impl.h" 48 | 49 | pcl2::Mat::Mat (const core::MatImpl::Ptr matrix_ptr) : matrix_ptr_ (matrix_ptr) {} 50 | 51 | pcl2::core::MatImpl::Ptr 52 | pcl2::Mat::getPtr () 53 | { 54 | return (matrix_ptr_); 55 | } 56 | 57 | const pcl2::core::MatImpl::Ptr 58 | pcl2::Mat::getPtr () const 59 | { 60 | return (matrix_ptr_); 61 | } 62 | 63 | pcl2::Mat 64 | pcl2::Mat::copy () const 65 | { 66 | return (Mat (matrix_ptr_->copy ())); 67 | } 68 | 69 | size_t 70 | pcl2::Mat::rows () const 71 | { 72 | return (matrix_ptr_->rows ()); 73 | } 74 | 75 | size_t 76 | pcl2::Mat::cols () const 77 | { 78 | return (matrix_ptr_->cols ()); 79 | } 80 | 81 | pcl2::Mat 82 | pcl2::Mat::operator () (const TypedMat & indices) 83 | { 84 | typedef core::TypedMatImpl Impl; 85 | Impl::ConstPtr idx = boost::dynamic_pointer_cast (indices.getPtr ()); 86 | return (Mat (matrix_ptr_->createView (idx))); 87 | } 88 | -------------------------------------------------------------------------------- /core/src/row.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | #include "pcl2/impl/row.hpp" 39 | 40 | template class pcl2::Row; 41 | template class pcl2::Row; 42 | template class pcl2::Row; 43 | -------------------------------------------------------------------------------- /core/src/stats.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file stats.cpp 39 | * \brief Instantiate functions for computing statistical properties of a matrix 40 | */ 41 | 42 | #include "pcl2/impl/stats.hpp" 43 | 44 | template pcl2::TypedMat pcl2::computeMean (const TypedMat &); 45 | template pcl2::TypedMat pcl2::computeMean (const TypedMat &); 46 | 47 | template pcl2::TypedMat pcl2::computeCovariance (const TypedMat &); 48 | template pcl2::TypedMat pcl2::computeCovariance (const TypedMat &); 49 | 50 | template pcl2::TypedMat pcl2::computeCovariance (const TypedMat &, const TypedMat &); 51 | template pcl2::TypedMat pcl2::computeCovariance (const TypedMat &, const TypedMat &); 52 | 53 | template void pcl2::computeMeanAndCovariance (const TypedMat &, TypedMat &, TypedMat &); 54 | template void pcl2::computeMeanAndCovariance (const TypedMat &, TypedMat &, TypedMat &); 55 | -------------------------------------------------------------------------------- /doc/Mainpage.dox: -------------------------------------------------------------------------------- 1 | namespace pcl2 2 | { 3 | 4 | /** 5 | 6 | \mainpage Point %Cloud Library 2.0 7 | 8 | The Point %Cloud Libary is an awesome open source lirbary for 3-D point 9 | cloud processing. This paragraph says some introductory things about the 10 | library and what it can be used for. 11 | 12 | \section getting_started Getting started 13 | 14 | One of the first steps in get started with the PCL 2.0 is to get familiar with 15 | the basic data structures. The first is the Cloud class. This is one of the 16 | most central data structures in PCL. It is used to represent all of the 17 | various geometric, color, and feature data related to point cloud processing 18 | Most of the high-level algorithms in PCL are designed to expect a Cloud as 19 | input and to return a Cloud as output. [There is WAY more to say, but I'll 20 | get to that later. This is just a placeholder...] 21 | 22 | To provide a concrete example... 23 | \code 24 | // Think of lots of code examples... 25 | using namespace pcl2; 26 | Cloud cloud = loadCloud ("example.pcd"); 27 | FloatMatrix points = cloud["xyz"]; 28 | \endcode 29 | 30 | Also, the Matrix class. [Say a bunch of stuff about Matrix and its 31 | subclasses.] 32 | 33 | \section faq Frequently Asked Questions 34 | 35 | \li Q: Why isn't this page finished? 36 | \li A: Because. 37 | 38 | \li Q: How do I do something awesome with PCL? 39 | \li A: Take a look at the following example: 40 | 41 | \code 42 | using namespace pcl2; 43 | Cloud cloud = loadCloud ("example.pcd"); 44 | cloud += doSomethingAwesome (cloud); 45 | saveCloud ("awesome_result.pcd", cloud); 46 | \endcode 47 | 48 | */ 49 | 50 | } -------------------------------------------------------------------------------- /features/include/pcl2/features/normals.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file normals.h 39 | * \brief Declares functions for estimating surface normals 40 | */ 41 | 42 | #ifndef PCL2_NEIGHBORS_H 43 | #define PCL2_NEIGHBORS_H 44 | 45 | #include "pcl2/cloud.h" 46 | #include "pcl2/typed_matrix.h" 47 | 48 | 49 | namespace pcl2 50 | { 51 | 52 | Cloud estimateSurfaceNormals (const Cloud & cloud, float nhood_radius); 53 | Cloud estimateSurfaceNormals (const MatF & points, float nhood_radius); 54 | 55 | Cloud estimateSurfaceNormals (const MatF & surface_points, const MatF & query_points, float nhood_radius); 56 | 57 | Cloud estimateSurfaceNormalsKNN (const Cloud & cloud, int k); 58 | 59 | // 60 | // Cloud estimateSurfaceNormals (Cloud cloud, NeighborhoodSpec ns); 61 | // e.g., cld += estimateSurfaceNormals (cld, FixedRadius (0.1)); 62 | // cld += estimateSurfaceNormals (cld, KNearest (0.1)); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SUBSYS_NAME io) 2 | set(SUBSYS_DESC "libpcl2_io: I/O operations") 3 | set(SUBSYS_DEPS core) 4 | 5 | set(build TRUE) 6 | PCL_SUBSYS_OPTION(build ${SUBSYS_NAME} ${SUBSYS_DESC} ON) 7 | PCL_SUBSYS_DEPEND(build ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS}) 8 | 9 | #PCL_ADD_DOC(${SUBSYS_NAME}) 10 | 11 | if(build) 12 | set(srcs 13 | src/io.cpp 14 | ) 15 | 16 | set(incs 17 | include/pcl2/io/io.h 18 | ) 19 | 20 | set(impl_incs 21 | ) 22 | 23 | set(LIB_NAME pcl2_${SUBSYS_NAME}) 24 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 25 | PCL_ADD_LIBRARY(${LIB_NAME} ${SUBSYS_NAME} ${srcs} ${incs} ${impl_incs}) 26 | PCL_ADD_SSE_FLAGS(${LIB_NAME}) 27 | PCL_MAKE_PKGCONFIG(${LIB_NAME} ${SUBSYS_NAME} "${SUBSYS_DESC}" "" "" "" "" "") 28 | 29 | # Install include files 30 | PCL_ADD_INCLUDES(${SUBSYS_NAME} "" ${incs}) 31 | PCL_ADD_INCLUDES(${SUBSYS_NAME} impl ${impl_incs}) 32 | 33 | #if(BUILD_TESTS) 34 | # add_subdirectory(test) 35 | #endif(BUILD_TESTS) 36 | 37 | #if(BUILD_EXAMPLES) 38 | # add_subdirectory(examples) 39 | #endif(BUILD_EXAMPLES) 40 | endif(build) 41 | -------------------------------------------------------------------------------- /io/include/pcl2/io/io.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file io.h 39 | * \brief Declares functions for loading and saving .PCD files 40 | */ 41 | 42 | #include "pcl2/cloud.h" 43 | 44 | namespace pcl2 45 | { 46 | 47 | /** \brief Load a PCD file 48 | * \param filename The name of the PCD file to load 49 | * \return A Cloud containing the file's data 50 | */ 51 | Cloud loadCloud (const std::string & filename); 52 | 53 | 54 | /** \brief Save a PCD file 55 | * \param filename The name of the PCD file to create 56 | * \param cloud The Cloud to save 57 | */ 58 | void saveCloud (const std::string & filename, const Cloud & cloud); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /io/src/io.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file io.cpp 39 | * \brief Defines functions declared in io.h 40 | */ 41 | 42 | #include "pcl2/io/io.h" 43 | #include "pcl2/conversions.h" 44 | 45 | #include 46 | 47 | pcl2::Cloud pcl2::loadCloud (const std::string & filename) 48 | { 49 | sensor_msgs::PointCloud2 pc2; 50 | pcl::io::loadPCDFile (filename, pc2); 51 | return (pcl2::convertPointCloud2ToCloud (pc2)); 52 | } 53 | 54 | void pcl2::saveCloud (const std::string & filename, const pcl2::Cloud & cloud) 55 | { 56 | boost::shared_ptr pc2 = convertCloudToPointCloud2 (cloud); 57 | pcl::io::savePCDFile (filename, *pc2); 58 | } 59 | -------------------------------------------------------------------------------- /pcl2_config.h.in: -------------------------------------------------------------------------------- 1 | /* pcl_config.h. Generated by CMake for @PROJECT_NAME@. */ 2 | 3 | /* PCL version information */ 4 | #cmakedefine PCL2_MAJOR_VERSION ${PCL2_MAJOR_VERSION} 5 | #cmakedefine PCL2_MINOR_VERSION ${PCL2_MINOR_VERSION} 6 | #cmakedefine PCL2_REVISION_VERSION ${PCL2_REVISION_VERSION} 7 | #cmakedefine PCL2_VERSION_PRETTY "${PCL_VERSION}" 8 | #define PCL2_VERSION_CALC(MAJ, MIN, PATCH) (MAJ*100000+MIN*100+PATCH) 9 | #cmakedefine PCL2_VERSION \ 10 | PCL_VERSION_CALC(PCL2_MAJOR_VERSION,PCL2_MINOR_VERSION,PCL2_REVISION_VERSION) 11 | #define PCL2_VERSION_COMPARE(OP,MAJ,MIN,PATCH) \ 12 | (PCL2_VERSION OP PCL2_VERSION_CALC(MAJ,MIN,PATCH)) 13 | 14 | #cmakedefine HAVE_OPENNI 1 15 | #cmakedefine HAVE_CUDA 1 16 | 17 | #cmakedefine HAVE_SSE3_EXTENSIONS 18 | #cmakedefine HAVE_SSE2_EXTENSIONS 19 | #cmakedefine HAVE_SSE_EXTENSIONS 20 | 21 | #ifdef DISABLE_OPENNI 22 | #undef HAVE_OPENNI 23 | #endif 24 | -------------------------------------------------------------------------------- /registration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SUBSYS_NAME registration) 2 | set(SUBSYS_DESC "libpcl2_registration: Iterative Closest Point (ICP) registration") 3 | set(SUBSYS_DEPS core) 4 | 5 | set(build TRUE) 6 | PCL_SUBSYS_OPTION(build ${SUBSYS_NAME} ${SUBSYS_DESC} ON) 7 | PCL_SUBSYS_DEPEND(build ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS}) 8 | 9 | #PCL_ADD_DOC(${SUBSYS_NAME}) 10 | 11 | if(build) 12 | set(srcs 13 | src/fit.cpp 14 | src/icp.cpp 15 | src/transform.cpp 16 | ) 17 | 18 | set(incs 19 | include/pcl2/registration/correspondence_identification.h 20 | include/pcl2/registration/fit.h 21 | include/pcl2/registration/icp.h 22 | include/pcl2/registration/transform.h 23 | ) 24 | 25 | set(impl_incs 26 | ) 27 | 28 | set(LIB_NAME pcl2_${SUBSYS_NAME}) 29 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 30 | PCL_ADD_LIBRARY(${LIB_NAME} ${SUBSYS_NAME} ${srcs} ${incs} ${impl_incs}) 31 | PCL_ADD_SSE_FLAGS(${LIB_NAME}) 32 | PCL_MAKE_PKGCONFIG(${LIB_NAME} ${SUBSYS_NAME} "${SUBSYS_DESC}" "" "" "" "" "") 33 | 34 | # Install include files 35 | PCL_ADD_INCLUDES(${SUBSYS_NAME} "" ${incs}) 36 | PCL_ADD_INCLUDES(${SUBSYS_NAME} impl ${impl_incs}) 37 | 38 | #if(BUILD_TESTS) 39 | # add_subdirectory(test) 40 | #endif(BUILD_TESTS) 41 | 42 | #if(BUILD_EXAMPLES) 43 | # add_subdirectory(examples) 44 | #endif(BUILD_EXAMPLES) 45 | endif(build) 46 | -------------------------------------------------------------------------------- /registration/include/pcl2/registration/correspondence_identification.h: -------------------------------------------------------------------------------- 1 | /** \file correspondence_identification.h 2 | * \brief Declares classes for finding corresponding points in two clouds 3 | */ 4 | 5 | #ifndef PCL2_CORRESPONDENCE_IDENTIFICATION_H 6 | #define PCL2_CORRESPONDENCE_IDENTIFICATION_H 7 | 8 | #include "pcl2/cloud.h" 9 | #include "pcl2/typed_matrix.h" 10 | 11 | #include 12 | 13 | namespace pcl2 14 | { 15 | 16 | class PointCorrespondences 17 | { 18 | public: 19 | PointCorrespondences (Cloud source, Cloud target); // source_indices and target_indices are initialized to 1,2,...,n 20 | PointCorrespondences (Cloud source, // source_indices is initialized to 1,2,...,n 21 | Cloud target, MatI target_indices); 22 | PointCorrespondences (Cloud source, MatI source_indices, 23 | Cloud target, MatI target_indices); 24 | PointCorrespondences (Cloud source, MatI source_indices, MatF source_distances, 25 | Cloud target, MatI target_indices, MatF target_distances); 26 | 27 | inline Cloud & getSource () { return (source_); } 28 | inline Cloud & getTarget () { return (target_); } 29 | 30 | inline void setCorrespondenceIndices (MatI source_indices, MatI target_indices); 31 | inline void setCorrespondenceDistances (MatF source_distances, MatF target_distances); 32 | inline void setWeights (MatF weights) { weights_ = weights; }; 33 | 34 | protected: 35 | Cloud source_, target_; 36 | MatI source_indices_, target_indices_; // source_(source_indices_) corresponds to target_(target_indices) 37 | MatF distances_, weights_; 38 | }; 39 | 40 | class CorrespondenceIdentification 41 | { 42 | public: 43 | typedef boost::shared_ptr Ptr; 44 | 45 | class Matching 46 | { 47 | public: 48 | typedef boost::shared_ptr Ptr; 49 | virtual PointCorrespondences match (const Cloud & source, const Cloud & target) const = 0; 50 | }; 51 | 52 | class Weighting 53 | { 54 | public: 55 | typedef boost::shared_ptr Ptr; 56 | virtual MatF weight (const PointCorrespondences & correspondences) const = 0; 57 | }; 58 | 59 | class Rejection 60 | { 61 | public: 62 | typedef boost::shared_ptr Ptr; 63 | virtual PointCorrespondences reject (const PointCorrespondences & correspondences) const = 0; 64 | }; 65 | 66 | CorrespondenceIdentification () 67 | {} 68 | 69 | inline void setMatchingFunction (const Matching::Ptr & matching) 70 | { 71 | matching_ = matching; 72 | } 73 | 74 | inline void setWeightingFunction (const Weighting::Ptr & weighting) { weighting_ = weighting; } 75 | inline void addRejectionFunction (const Rejection::Ptr & rejection) { rejection_.push_back (rejection); } 76 | 77 | inline PointCorrespondences identifyCorrespondences (const Cloud source, const Cloud target) const 78 | { 79 | // Find matches 80 | PointCorrespondences correspondences = matching_->match (source, target); 81 | 82 | // Apply rejection criteria 83 | std::vector::const_iterator itr; 84 | for (itr = rejection_.begin (); itr != rejection_.end (); ++itr) 85 | { 86 | correspondences = (*itr)->reject (correspondences); 87 | } 88 | 89 | // Weight the remaining correspondences 90 | if (weighting_) 91 | correspondences.setWeights (weighting_->weight (correspondences)); 92 | 93 | return (correspondences); 94 | } 95 | 96 | protected: 97 | Matching::Ptr matching_; 98 | Weighting::Ptr weighting_; 99 | std::vector rejection_; 100 | }; 101 | 102 | 103 | class NearestNeighborMatching : public CorrespondenceIdentification::Matching 104 | { 105 | virtual PointCorrespondences match (const Cloud & source, const Cloud & target) const 106 | { 107 | /* 108 | MatI indices (source.size (), 1); 109 | for (int i = 0; i < source.size (); ++i) 110 | { 111 | MatI i_in_mat (1, 1); i_in_mat (0, 0) = i; // ick! 112 | MatF query = source (i_in_mat); 113 | indices (i, 0) = findNearestNeighbor (target, query); 114 | } 115 | 116 | MatF::Row query = source.getRow (0); 117 | MatF::Row idx = indices.getRow (0); 118 | while (query.getIndex () != source.size ()) 119 | { 120 | idx.fill (target, query); 121 | query.next (); 122 | idx.next (); 123 | } 124 | 125 | return (PointCorrespondences correspondences (source, target, indices)); 126 | */ 127 | assert (false); 128 | } 129 | }; 130 | 131 | 132 | } 133 | 134 | #endif // PCL2_CORRESPONDENCE_IDENTIFICATION_H 135 | -------------------------------------------------------------------------------- /registration/include/pcl2/registration/fit.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file fit.h 39 | * \brief Declares example functions for fitting planes to point clouds 40 | */ 41 | 42 | /// \todo Move this file (fit.h) to a different module (not registration) 43 | 44 | #ifndef PCL2_FIT_H 45 | #define PCL2_FIT_H 46 | 47 | #include "pcl2/cloud.h" 48 | #include "pcl2/typed_matrix.h" 49 | 50 | namespace pcl2 51 | { 52 | 53 | /** \brief Fit a plane to a given cloud of 3D points using Linear Least Squares (LLS) 54 | * \param cloud A cloud containing an "xyz" channel of 3D points 55 | * \return A MatF containing the 4 coefficients of the best fitting plane, 56 | * given in \f$ c_0 x + c_1 y + c_2 z = c_3 \f$ form 57 | */ 58 | MatF fitPlaneLLS (const Cloud & cloud); 59 | 60 | /** \brief Fit a plane to a channel of 3D points using Linear Least Squares (LLS) 61 | * \param points An n by 3 MatF representing n 3D points 62 | * \return A MatF containing the 4 coefficients of the best fitting plane, 63 | * given in \f$ c_0 x + c_1 y + c_2 z = c_3 \f$ form 64 | */ 65 | template 66 | TypedMat fitPlaneLLS (const TypedMat & points); 67 | 68 | /** \brief Fit a plane to a given cloud of 3D points using Random Sample Consensus (RANSAC) 69 | * \param cloud A cloud containing an "xyz" channel of 3D points 70 | * \param inlier_threshold The maximum point-to-plane distance at which a point will be considered an inlier 71 | * \return A MatF containing the 4 coefficients of the best fitting plane, 72 | * given in \f$ c_0 x + c_1 y + c_2 z = c_3 \f$ form 73 | */ 74 | MatF fitPlaneRANSAC (const Cloud & cloud, float inlier_threshold); 75 | 76 | /** \brief Fit a plane to a channel of 3D points using Random Sample Consensus (RANSAC) 77 | * \param points An n by 3 MatF representing n 3D points 78 | * \param inlier_threshold The maximum point-to-plane distance at which a point will be considered an inlier 79 | * \return A MatF containing the 4 coefficients of the best fitting plane, 80 | * given in \f$ c_0 x + c_1 y + c_2 z = c_3 \f$ form 81 | */ 82 | template 83 | TypedMat fitPlaneRANSAC (const TypedMat & points, float inlier_threshold); 84 | 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /registration/include/pcl2/registration/icp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file icp.h 39 | * \brief Declares classes and functions for aligning point clouds using the Iterative Closest Point (ICP) algorithm. 40 | */ 41 | 42 | // This is still just an outline, which I doubt will even compile. 43 | // It also contains lots of stuff that belongs in other files. 44 | 45 | #ifndef PCL2_ICP_H 46 | #define PCL2_ICP_H 47 | 48 | #include "pcl2/cloud.h" 49 | #include "pcl2/registration/correspondence_identification.h" 50 | #include "pcl2/eigen_matrix.h" 51 | 52 | namespace pcl2 53 | { 54 | 55 | class RigidTransformationEstimation 56 | { 57 | public: 58 | typedef boost::shared_ptr Ptr; 59 | 60 | RigidTransformationEstimation (); 61 | virtual MatF estimateTransformation (const PointCorrespondences & correspondences); 62 | }; 63 | 64 | class ICP 65 | { 66 | public: 67 | /** \brief \b ICP is an implementation of the classic Iterative Closest Point algorithm. 68 | * This implementation allows for multiple configurations "Efficient Variants of the ICP Algorithm" 69 | */ 70 | ICP (size_t max_iterations = 100); 71 | 72 | /** \brief Align a source cloud to a target cloud by solving for the rigid transformation that minimizes the 73 | * registration error between the two clouds. 74 | * \param source The cloud that will be aligned 75 | * \param target The cloud to which the source will be aligned 76 | * \return A copy of the source cloud that has been transformed to align with the target. 77 | */ 78 | Cloud align (const Cloud & source, const Cloud & target); 79 | 80 | /** \todo write me */ 81 | void setCorrespondenceIdentification (const CorrespondenceIdentification::Ptr & ci) 82 | { 83 | correspondence_identification_ = ci; 84 | } 85 | 86 | /** \todo write me */ 87 | void setRigidTransformationEstimation (const RigidTransformationEstimation::Ptr & rte) 88 | { 89 | transformation_estimation_ = rte; 90 | } 91 | 92 | /** \brief Get the source-to-target transform estimated by the most recent alignment. 93 | * \return A 4x4 matrix containing the estimated rigid transformation from the source cloud to the target cloud. 94 | */ 95 | inline MatF getFinalTransformation () const 96 | { 97 | return (transformation_); 98 | } 99 | 100 | /** \brief Get the estimated registration error of the most recent alignment. 101 | * \return The registration error of the last alignment, as determined by the specified error metric. 102 | */ 103 | inline float getRegistrationError () const 104 | { 105 | return (registration_error_); 106 | } 107 | 108 | /** \brief Determine if the convergence criteria were satisfied by the most recent alignment. 109 | * \return The convergence state of the last alignment. This return value will be true if the specified convergence 110 | * critera were met; it will be false if the maximum number of iterations was reached. 111 | */ 112 | inline bool converged () const 113 | { 114 | return (converged_); 115 | } 116 | 117 | protected: 118 | size_t max_iterations_; 119 | CorrespondenceIdentification::Ptr correspondence_identification_; 120 | RigidTransformationEstimation::Ptr transformation_estimation_; 121 | 122 | bool converged_; 123 | EigenMat transformation_; 124 | float registration_error_; 125 | 126 | }; 127 | 128 | } 129 | 130 | #endif // PCL2_ICP_H 131 | -------------------------------------------------------------------------------- /registration/include/pcl2/registration/impl/fit.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file fit.hpp 39 | * \brief Defines functions declared in fit.h 40 | */ 41 | 42 | #include "pcl2/registration/fit.h" 43 | 44 | #include "pcl2/core.h" 45 | #include "pcl2/eigen_matrix.h" 46 | #include "pcl2/stats.h" 47 | #include "pcl2/math.h" 48 | 49 | #include "pcl2/conversions.h" 50 | #include 51 | 52 | template 53 | pcl2::TypedMat 54 | pcl2::fitPlaneLLS (const TypedMat & points) 55 | { 56 | typedef TypedMat MatT; 57 | MatT cov = computeCovariance (points); 58 | MatT eigvecs = computeEigenvectors3x3 (cov); 59 | MatT normal = eigvecs (0).copy (); 60 | 61 | ////// Double-check 62 | pcl::PointCloud::Ptr point_cloud = convertToPointCloudXYZ (points); 63 | Eigen::Vector4f plane_parameters; 64 | float curvature; 65 | pcl::computePointNormal (*point_cloud, plane_parameters, curvature); 66 | for (int i = 0; i < 3; ++i) 67 | { 68 | assert (fabs(normal (0, i) - plane_parameters (i)) < 1e-3 || 69 | fabs(normal (0, i) + plane_parameters (i)) < 1e-3); 70 | } 71 | ////// 72 | 73 | return (normal); 74 | } 75 | 76 | 77 | template 78 | pcl2::TypedMat 79 | pcl2::fitPlaneRANSAC (const TypedMat & points, float inlier_threshold) 80 | { 81 | const bool SORRY_NOT_IMPLEMENTED_YET = false; 82 | assert (SORRY_NOT_IMPLEMENTED_YET); 83 | } 84 | -------------------------------------------------------------------------------- /registration/include/pcl2/registration/transform.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file transform.h 39 | * \brief Declares functions for transforming point clouds 40 | */ 41 | 42 | #ifndef PCL2_TRANSFORM_H 43 | #define PCL2_TRANSFORM_H 44 | 45 | #include "pcl2/cloud.h" 46 | #include "pcl2/typed_matrix.h" 47 | 48 | namespace pcl2 49 | { 50 | 51 | Cloud transform (Cloud cloud, const MatF & tform); 52 | 53 | } 54 | 55 | #endif // PCL2_TRANSFORM_H 56 | -------------------------------------------------------------------------------- /registration/src/fit.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file fit.cpp 39 | * \brief Defines functions declared in fit.h 40 | */ 41 | 42 | #include "pcl2/registration/fit.h" 43 | #include "pcl2/registration/impl/fit.hpp" 44 | 45 | pcl2::MatF 46 | pcl2::fitPlaneLLS (const Cloud & cloud) 47 | { 48 | MatF points = cloud["xyz"]; 49 | return (fitPlaneLLS (points)); 50 | } 51 | 52 | pcl2::MatF 53 | pcl2::fitPlaneRANSAC (const Cloud & cloud, float inlier_threshold) 54 | { 55 | MatF points = cloud["xyz"]; 56 | return (fitPlaneRANSAC (points, inlier_threshold)); 57 | } 58 | -------------------------------------------------------------------------------- /registration/src/icp.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file icp.cpp 39 | * \brief Defines functions and classes declared in icp.h 40 | */ 41 | 42 | #include "pcl2/registration/icp.h" 43 | #include "pcl2/registration/transform.h" 44 | 45 | pcl2::ICP::ICP (size_t max_iterations) : 46 | max_iterations_ (max_iterations), 47 | correspondence_identification_ (new CorrespondenceIdentification), 48 | transformation_estimation_ (new RigidTransformationEstimation), 49 | converged_ (false), 50 | transformation_ (4, 4) 51 | { 52 | // todo: set transformation to the identity matrix 53 | } 54 | 55 | pcl2::Cloud 56 | pcl2::ICP::align (const Cloud & source, const Cloud & target) 57 | { 58 | Cloud aligned_source = source; 59 | for (size_t i = 0; i < max_iterations_; ++i) 60 | { 61 | // Identify correspondences 62 | PointCorrespondences correspondences = 63 | correspondence_identification_->identifyCorrespondences (aligned_source, target); 64 | 65 | // Estimate a rigid transformation between 66 | transformation_ *= transformation_estimation_->estimateTransformation (correspondences); 67 | 68 | // Transform source cloud 69 | aligned_source = transform (source, transformation_); 70 | 71 | // Check for convergence 72 | converged_ = false; /// \todo checkForConvergenceSomehow (); 73 | if (converged_) 74 | break; 75 | } 76 | return (aligned_source); 77 | } 78 | 79 | 80 | 81 | /// \todo Move me to a different file! 82 | 83 | pcl2::RigidTransformationEstimation::RigidTransformationEstimation () {} 84 | 85 | pcl2::MatF 86 | pcl2::RigidTransformationEstimation::estimateTransformation (const PointCorrespondences & correspondences) 87 | { 88 | EigenMat tform (4,4); 89 | return (tform); 90 | } 91 | -------------------------------------------------------------------------------- /registration/src/transform.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file transform.cpp 39 | * \brief Defines functions declared in transform.h 40 | */ 41 | 42 | #include "pcl2/registration/transform.h" 43 | 44 | pcl2::Cloud 45 | pcl2::transform (Cloud cloud, const MatF & tform) 46 | { 47 | /// \todo Implement me! 48 | return (cloud); 49 | } 50 | -------------------------------------------------------------------------------- /search/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SUBSYS_NAME search) 2 | set(SUBSYS_DESC "libpcl2_search: Nearest neighbor and radius search") 3 | set(SUBSYS_DEPS core) 4 | 5 | set(build TRUE) 6 | PCL_SUBSYS_OPTION(build ${SUBSYS_NAME} ${SUBSYS_DESC} ON) 7 | PCL_SUBSYS_DEPEND(build ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS}) 8 | 9 | #PCL_ADD_DOC(${SUBSYS_NAME}) 10 | 11 | if(build) 12 | set(srcs 13 | src/neighbors.cpp 14 | ) 15 | 16 | set(incs 17 | include/pcl2/search/neighbors.h 18 | include/pcl2/search/kdtree.h 19 | ) 20 | 21 | set(impl_incs 22 | ) 23 | 24 | set(LIB_NAME pcl2_${SUBSYS_NAME}) 25 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 26 | PCL_ADD_LIBRARY(${LIB_NAME} ${SUBSYS_NAME} ${srcs} ${incs} ${impl_incs}) 27 | PCL_ADD_SSE_FLAGS(${LIB_NAME}) 28 | PCL_MAKE_PKGCONFIG(${LIB_NAME} ${SUBSYS_NAME} "${SUBSYS_DESC}" "" "" "" "" "") 29 | 30 | # Install include files 31 | PCL_ADD_INCLUDES(${SUBSYS_NAME} "" ${incs}) 32 | PCL_ADD_INCLUDES(${SUBSYS_NAME} impl ${impl_incs}) 33 | 34 | #if(BUILD_TESTS) 35 | # add_subdirectory(test) 36 | #endif(BUILD_TESTS) 37 | 38 | #if(BUILD_EXAMPLES) 39 | # add_subdirectory(examples) 40 | #endif(BUILD_EXAMPLES) 41 | endif(build) 42 | -------------------------------------------------------------------------------- /search/include/pcl2/search/kdtree.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2011, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | /** \file kdtree.h 39 | * \brief Contains class declaration for pcl2::SpatialIndex 40 | */ 41 | 42 | #ifndef PCL2_KDTREE_H 43 | #define PCL2_KDTREE_H 44 | 45 | 46 | #include "pcl2/spatial_index.h" 47 | 48 | #include 49 | 50 | namespace pcl2 51 | { 52 | 53 | namespace search 54 | { 55 | 56 | template 57 | class KDTree : public SpatialIndex 58 | { 59 | public: 60 | typedef TypedMat MatT; 61 | 62 | virtual void 63 | buildIndex (const MatT & input) 64 | { 65 | assert (input.rows () >= 1); 66 | assert (input.cols () == 3); 67 | 68 | pcl::PointCloud::Ptr pcl_pointcloud (new pcl::PointCloud); 69 | pcl_pointcloud->width = input.rows (); 70 | pcl_pointcloud->height = 1; 71 | pcl_pointcloud->is_dense = false; 72 | pcl_pointcloud->points.resize (input.rows ()); 73 | for (size_t i = 0; i < input.rows (); ++i) 74 | { 75 | pcl_pointcloud->points[i].x = input (i, 0); 76 | pcl_pointcloud->points[i].y = input (i, 1); 77 | pcl_pointcloud->points[i].z = input (i, 2); 78 | } 79 | 80 | kdtree_.setInputCloud (pcl_pointcloud); 81 | } 82 | 83 | virtual MatI 84 | findKNearestNeighbors (const MatT & query, size_t k) const 85 | { 86 | // Convert query point 87 | assert (query.rows () == 1); 88 | assert (query.cols () == 3); 89 | pcl::PointXYZ q; 90 | q.x = query (0, 0); 91 | q.y = query (0, 1); 92 | q.z = query (0, 2); 93 | 94 | std::vector indices (k); 95 | std::vector dists (k); 96 | k = (size_t) kdtree_.nearestKSearch (q, k, indices, dists); 97 | assert (k == indices.size ()); 98 | 99 | // Convert output 100 | EigenMat output (k, 1); 101 | for (size_t i = 0; i < indices.size (); ++i) 102 | output (i, 0) = indices[i]; 103 | 104 | return (output); 105 | } 106 | 107 | virtual MatI 108 | findFixedRadiusNeighbors (const MatT & query, float r) const 109 | { 110 | // Convert query point 111 | assert (query.rows () == 1); 112 | assert (query.cols () == 3); 113 | pcl::PointXYZ q; 114 | q.x = query (0, 0); 115 | q.y = query (0, 1); 116 | q.z = query (0, 2); 117 | 118 | std::vector indices; 119 | std::vector dists; 120 | int k = (size_t) kdtree_.radiusSearch (q, r, indices, dists); 121 | 122 | // Convert output 123 | EigenMat output (k, 1); 124 | for (size_t i = 0; i < indices.size (); ++i) 125 | output (i, 0) = indices[i]; 126 | 127 | return (output); 128 | }; 129 | 130 | virtual std::pair 131 | findKNearestNeighborsAndDistances (const MatT & query, size_t k) const 132 | { 133 | assert (false); 134 | }; 135 | 136 | virtual std::pair 137 | findFixedRadiusNeighborsAndDistances (const MatT & query, float r) const 138 | { 139 | assert (false); 140 | }; 141 | 142 | protected: 143 | pcl::KdTreeFLANN kdtree_; 144 | }; 145 | 146 | } 147 | 148 | } 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /search/include/pcl2/search/neighbors.h: -------------------------------------------------------------------------------- 1 | /** \file neighbors.h 2 | * \brief Declares functions for finding nearest neighbors 3 | */ 4 | 5 | #ifndef PCL2_NEIGHBORS_H 6 | #define PCL2_NEIGHBORS_H 7 | 8 | #include "pcl2/cloud.h" 9 | #include "pcl2/typed_matrix.h" 10 | 11 | 12 | namespace pcl2 13 | { 14 | 15 | /** \todo Document this class */ 16 | class Neighborhood : public Cloud 17 | { 18 | public: 19 | Neighborhood (Cloud & cloud, const TypedMat & indices) : Cloud (cloud (indices)), indices_ (indices) 20 | { 21 | 22 | } 23 | protected: 24 | MatI indices_; 25 | }; 26 | 27 | /** \brief Find the nearest neighbor to a query point in a given cloud 28 | * \param cloud An input cloud containing a 3D "xyz" channel 29 | * \param query A 3D query point 30 | * \return The index of the nearest neighbor. 31 | * \see http://en.wikipedia.org/wiki/Nearest_neighbor_search#k-nearest_neighbor 32 | */ 33 | int findNearestNeighbor (const Cloud & cloud, const MatF & query); 34 | 35 | /** \brief Find the k nearest neighbors that surround a query point in a given cloud 36 | * \param cloud An input cloud containing a 3D "xyz" channel 37 | * \param query A 3D query point 38 | * \param k the number of nearest neighbors to return 39 | * \return A MatI containing the indices of the k nearest neighbors. 40 | * \see http://en.wikipedia.org/wiki/Nearest_neighbor_search#k-nearest_neighbor 41 | */ 42 | MatI findKNearestNeighbors (const Cloud & cloud, const MatF & query, size_t k); 43 | 44 | /** \brief Find all points within a specified radius surrounding a query point in a given cloud 45 | * \param cloud An input cloud containing a 3D "xyz" channel 46 | * \param query A 3D query point 47 | * \param r the radius of the neighborhood 48 | * \return A MatI containing the indices of all points that fell within the given radius 49 | * \see http://en.wikipedia.org/wiki/Fixed-radius_near_neighbors 50 | * \see computeFixedRadiusNeighborhood 51 | */ 52 | MatI findFixedRadiusNeighbors (Cloud & cloud, const MatF & query, float r); 53 | 54 | /** \brief Compute the subset points that fall within a specified radius surrounding a query point in a given cloud 55 | * \param cloud An input cloud containing a 3D "xyz" channel 56 | * \param query A 3D query point 57 | * \param r the radius of the neighborhood 58 | * \return A neighborhood of points that lie within the given radius around the query point 59 | * \see http://en.wikipedia.org/wiki/Fixed-radius_near_neighbors 60 | * \see findFixedRadiusNeighbors 61 | */ 62 | Neighborhood computeFixedRadiusNeighborhood (Cloud & cloud, const MatF & query, float r); 63 | 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /search/src/neighbors.cpp: -------------------------------------------------------------------------------- 1 | /** \file neighbors.cpp 2 | * \brief Defines functions declared in neighbors.h 3 | */ 4 | 5 | #include "pcl2/search/neighbors.h" 6 | #include "pcl2/eigen_matrix.h" 7 | #include "pcl2/search/kdtree.h" 8 | 9 | #include 10 | 11 | 12 | int 13 | pcl2::findNearestNeighbor (const Cloud & cloud, const MatF & query) 14 | { 15 | // Convert point cloud 16 | MatF xyz = cloud["xyz"]; 17 | assert (xyz.rows () >= 1); 18 | assert (xyz.cols () == 3); 19 | pcl::PointCloud::Ptr input (new pcl::PointCloud); 20 | input->width = cloud.size (); 21 | input->height = 1; 22 | input->is_dense = false; 23 | input->points.resize (cloud.size ()); 24 | for (size_t i = 0; i < xyz.rows (); ++i) 25 | { 26 | input->points[i].x = xyz (i, 0); 27 | input->points[i].y = xyz (i, 1); 28 | input->points[i].z = xyz (i, 2); 29 | } 30 | 31 | // Convert query point 32 | assert (query.rows () == 1); 33 | assert (query.cols () == 3); 34 | pcl::PointXYZ q; 35 | q.x = query (0, 0); 36 | q.y = query (0, 1); 37 | q.z = query (0, 2); 38 | 39 | // Perform neighbor search 40 | pcl::KdTreeFLANN tree; 41 | tree.setInputCloud (input); 42 | 43 | std::vector indices (1); 44 | std::vector dists (1); 45 | int k = (size_t) tree.nearestKSearch (q, 1, indices, dists); 46 | assert (k == 1); 47 | 48 | return (indices[0]); 49 | } 50 | 51 | pcl2::TypedMat 52 | pcl2::findKNearestNeighbors (const Cloud & cloud, const MatF & query, size_t k) 53 | { 54 | // Convert point cloud 55 | MatF xyz = cloud["xyz"]; 56 | assert (xyz.rows () >= 1); 57 | assert (xyz.cols () == 3); 58 | pcl::PointCloud::Ptr input (new pcl::PointCloud); 59 | input->width = cloud.size (); 60 | input->height = 1; 61 | input->is_dense = false; 62 | input->points.resize (cloud.size ()); 63 | for (size_t i = 0; i < xyz.rows (); ++i) 64 | { 65 | input->points[i].x = xyz (i, 0); 66 | input->points[i].y = xyz (i, 1); 67 | input->points[i].z = xyz (i, 2); 68 | } 69 | 70 | // Convert query point 71 | assert (query.rows () == 1); 72 | assert (query.cols () == 3); 73 | pcl::PointXYZ q; 74 | q.x = query (0, 0); 75 | q.y = query (0, 1); 76 | q.z = query (0, 2); 77 | 78 | // Perform neighbor search 79 | pcl::KdTreeFLANN tree; 80 | tree.setInputCloud (input); 81 | 82 | std::vector indices (k); 83 | std::vector dists (k); 84 | k = (size_t) tree.nearestKSearch (q, k, indices, dists); 85 | assert (k == indices.size ()); 86 | 87 | // Convert output 88 | EigenMat output (k, 1); 89 | for (size_t i = 0; i < indices.size (); ++i) 90 | output (i, 0) = indices[i]; 91 | 92 | return (output); 93 | } 94 | 95 | pcl2::TypedMat 96 | pcl2::findFixedRadiusNeighbors (Cloud & cloud, const MatF & query, float r) 97 | { 98 | // Search in the xyx channel 99 | MatF xyz = cloud["xyz"]; 100 | 101 | // Look for a pre-computed spatial search index 102 | SpatialIndex::Ptr spatial_index = xyz.getSpatialIndex (); 103 | if (!spatial_index) 104 | { 105 | // If no spatial index is present, create one 106 | /// \todo: Replace this with buildDefaultSpatialIndex, getSpatialIndex 107 | spatial_index.reset (new search::KDTree ()); 108 | xyz.buildSpatialIndex (spatial_index); 109 | } 110 | 111 | // Use the search index to perform the radius search and return the neigbhor indices 112 | return (spatial_index->findFixedRadiusNeighbors (query, r)); 113 | } 114 | 115 | 116 | pcl2::Neighborhood 117 | pcl2::computeFixedRadiusNeighborhood (Cloud & cloud, const MatF & query, float r) 118 | { 119 | // Convert point cloud 120 | MatF xyz = cloud["xyz"]; 121 | assert (xyz.rows () >= 1); 122 | assert (xyz.cols () == 3); 123 | pcl::PointCloud::Ptr input (new pcl::PointCloud); 124 | input->width = cloud.size (); 125 | input->height = 1; 126 | input->is_dense = false; 127 | input->points.resize (cloud.size ()); 128 | for (size_t i = 0; i < xyz.rows (); ++i) 129 | { 130 | input->points[i].x = xyz (i, 0); 131 | input->points[i].y = xyz (i, 1); 132 | input->points[i].z = xyz (i, 2); 133 | } 134 | 135 | // Convert query point 136 | assert (query.rows () == 1); 137 | assert (query.cols () == 3); 138 | pcl::PointXYZ q; 139 | q.x = query (0, 0); 140 | q.y = query (0, 1); 141 | q.z = query (0, 2); 142 | 143 | // Perform neighbor search 144 | pcl::KdTreeFLANN tree; 145 | tree.setInputCloud (input); 146 | 147 | std::vector idx_vec; 148 | std::vector dist_vec; 149 | size_t k = (size_t) tree.radiusSearch (q, r, idx_vec, dist_vec); 150 | assert (k == idx_vec.size ()); 151 | 152 | // Convert output 153 | EigenMat neighbor_indices (k, 1); 154 | EigenMat squared_distances (k, 1); 155 | for (size_t i = 0; i < k; ++i) 156 | { 157 | neighbor_indices (i, 0) = idx_vec[i]; 158 | squared_distances (i, 0) = dist_vec[i]; 159 | } 160 | 161 | //Cloud neighborhood = cloud (neighbor_indices); 162 | Neighborhood neighborhood (cloud, neighbor_indices); 163 | neighborhood.insert ("dist", squared_distances); 164 | return (neighborhood); 165 | } 166 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (SUBSYS_NAME tools) 2 | set (SUBSYS_DESC "Useful PCL-based command line tools") 3 | set (SUBSYS_DEPS core io registration search) 4 | set (DEFAULT ON) 5 | set (REASON "") 6 | 7 | PCL_SUBSYS_OPTION (build ${SUBSYS_NAME} ${SUBSYS_DESC} ${DEFAULT} ${REASON}) 8 | PCL_SUBSYS_DEPEND (build ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS}) 9 | 10 | if (build) 11 | PCL_ADD_EXECUTABLE (mat_intro ${SUBSYS_NAME} mat_intro.cpp) 12 | target_link_libraries (mat_intro pcl2_core pcl2_io pcl2_search pcl2_registration ${PCL_LIBRARIES}) 13 | 14 | PCL_ADD_EXECUTABLE (cloud_intro ${SUBSYS_NAME} cloud_intro.cpp) 15 | target_link_libraries (cloud_intro pcl2_core pcl2_io pcl2_search pcl2_registration ${PCL_LIBRARIES}) 16 | 17 | PCL_ADD_EXECUTABLE (rst_test ${SUBSYS_NAME} rst_test.cpp) 18 | target_link_libraries (rst_test pcl2_core ${PCL_LIBRARIES}) 19 | 20 | PCL_ADD_EXECUTABLE (pcl2_test ${SUBSYS_NAME} pcl2_test.cpp) 21 | target_link_libraries (pcl2_test pcl2_core pcl2_io pcl2_search pcl2_registration ${PCL_LIBRARIES}) 22 | 23 | endif () 24 | -------------------------------------------------------------------------------- /tools/cloud_intro.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | #include 39 | #include "pcl2/core.h" 40 | #include "pcl2/eigen_matrix.h" 41 | 42 | #include "pcl2/io/io.h" 43 | #include "pcl2/search/neighbors.h" 44 | #include "pcl2/registration/fit.h" 45 | #include "pcl2/create.h" 46 | 47 | #include "pcl2/search/kdtree.h" 48 | 49 | int 50 | main (int argc, char ** argv) 51 | { 52 | // Load a point cloud 53 | pcl2::Cloud bunny = pcl2::loadCloud ("../data/bunny.pcd"); 54 | 55 | // Get the xyz channel from the cloud 56 | pcl2::MatF pts = bunny["xyz"]; 57 | 58 | // Create a new mat to store the surface normals in 59 | pcl2::EigenMat normals (bunny.size (), 3); 60 | 61 | //// Build a spatial search index (this will be automated soon) 62 | //pcl2::search::KDTree tree; 63 | //tree.buildIndex (pts); 64 | 65 | // Loop over every point in the cloud 66 | pcl2::MatF::Row q_normal = normals (0); 67 | for (pcl2::MatF::Row q = pts (0); q.hasNext (); q.advance (), q_normal.advance ()) 68 | { 69 | // Find the neighbors 70 | const float radius = 0.03; 71 | pcl2::MatI nn_idx = pcl2::findFixedRadiusNeighbors (bunny, q, radius); 72 | //pcl2::MatI nn_idx = tree.findFixedRadiusNeighbors (q, radius); 73 | 74 | // Fit a plane to the neighborhood and store the result 75 | q_normal << pcl2::fitPlaneLLS (pts (nn_idx)); 76 | } 77 | 78 | // Add the new normals channel to the cloud... 79 | bunny += pcl2::Cloud ("normals", normals); 80 | // ... and add a dummy curvature channel, too, because pcd_viewer expects one 81 | bunny += pcl2::Cloud ("curvature", pcl2::createZeros (bunny.size (), 1)); 82 | 83 | // Save the cloud for visualization 84 | pcl2::saveCloud ("./bunny_out.pcd", bunny); 85 | 86 | return (0); 87 | } 88 | -------------------------------------------------------------------------------- /tools/mat_intro.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Point Cloud Library (PCL) - www.pointclouds.org 5 | * Copyright (c) 2009-2012, Willow Garage, Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above 16 | * copyright notice, this list of conditions and the following 17 | * disclaimer in the documentation and/or other materials provided 18 | * with the distribution. 19 | * * Neither the name of Willow Garage, Inc. nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | #include 39 | #include "pcl2/matrix.h" 40 | #include "pcl2/eigen_matrix.h" 41 | #include "pcl2/row.h" 42 | #include "pcl2/math.h" 43 | #include "pcl2/stats.h" 44 | #include "pcl2/io/io.h" 45 | #include "pcl2/search/neighbors.h" 46 | #include "pcl2/registration/fit.h" 47 | #include "pcl2/create.h" 48 | 49 | int 50 | main (int argc, char ** argv) 51 | { 52 | // Create an N by M matrix of floats 53 | int n = 8; 54 | int m = 3; 55 | pcl2::EigenMat mat = pcl2::EigenMat (n, m); 56 | 57 | // By default, the values of a matrix are uninitialized 58 | // We can change all the values in the array using 'fill' or the '<<' operator 59 | mat << 10.0; 60 | 61 | // We can access its elements with the () operator 62 | // (it's a matrix, so we follow mathematical convention: rows by columns) 63 | int i = 1; 64 | int j = 2; 65 | std::cout << "The element stored at row " << i+1 << " and column " << j+1 << " is: "; 66 | std::cout << mat (i, j) << std::endl; 67 | 68 | // We can also iterate over the rows and fill in each row individually 69 | for (pcl2::MatF::Row row_i = mat (0); row_i.hasNext (); row_i.advance ()) 70 | row_i << row_i.getIndex () * 100; 71 | 72 | std::cout << "mat = " << std::endl 73 | << mat << std::endl << std::endl; 74 | 75 | // We can create special matrices using the functions declared in create.h 76 | pcl2::MatF ones = pcl2::createOnes (2, 3); 77 | pcl2::MatF zeros = pcl2::createZeros (1, 5); 78 | pcl2::MatF eye = pcl2::createIdentity (3); 79 | pcl2::MatF rand = pcl2::createRandom (2, 4); 80 | 81 | std::cout << "ones = " << std::endl << ones << std::endl; 82 | std::cout << "zeros = " << std::endl << zeros << std::endl; 83 | std::cout << "eye = " << std::endl << eye << std::endl; 84 | std::cout << "rand = " << std::endl << rand << std::endl; 85 | 86 | // A "series" is a useful kind of matrix. It creates a vector of sequential elements 87 | // starting with a value, x0, and increasing in increments of d, up to---but not including-- the value, xN 88 | // S = [x0, x0+d, x0+2d, x0+3d, ..., xN) 89 | pcl2::MatI idx = pcl2::createSeries (0, 8, 2); // will contain: 0, 2, 4, 6 (but not 8!) 90 | 91 | std::cout << "idx = " << std::endl << idx << std::endl; 92 | 93 | // You can use a vector indices to create a "view" into another matrix. 94 | // The view will contain a subset of the the original matrix's rows --- 95 | // one for each element of the provided index vector of the original matrix. 96 | // The view can be operated on just like any other matrix, 97 | // but changes to the view will affect the original 98 | 99 | pcl2::MatF view = mat (idx); 100 | std::cout << "view of mat [mat (idx)] = " << std::endl << view << std::endl; 101 | view << pcl2::createRandom (view.rows (), view.cols ()); 102 | 103 | std::cout << "After filling the view with random values, view = " << std::endl 104 | << view << std::endl << std::endl 105 | << "and mat = " << std::endl 106 | << mat << std::endl << std::endl; 107 | 108 | // Now we'll perform a few operations on matrices 109 | std::cout << "The mean and covariance of mat: " << std::endl; 110 | std::cout << pcl2::computeMean (mat) << std::endl; 111 | std::cout << pcl2::computeCovariance (mat) << std::endl; 112 | 113 | // This works on views, too 114 | std::cout << pcl2::computeMean (mat (idx)) << std::endl; 115 | std::cout << pcl2::computeCovariance (mat (idx)) << std::endl; 116 | 117 | std::cout << "Cumulative sums and products:" << std::endl << std::endl; 118 | 119 | mat << 10.0; 120 | mat = pcl2::computeCumulativeSum (mat); 121 | std::cout << mat << std::endl; 122 | 123 | mat.fill (2.0); 124 | std::cout << pcl2::computeCumulativeProduct (mat) << std::endl; 125 | 126 | std::cout << "Outer sums and products:" << std::endl << std::endl; 127 | 128 | mat << pcl2::computeOuterSum (pcl2::createSeries (0, 80, 10), pcl2::createSeries (0, 3)); 129 | std::cout << mat << std::endl << std::endl; 130 | 131 | pcl2::MatF vec = pcl2::createSeries (0.0, 3.0); 132 | pcl2::MatF mat3x3 = pcl2::computeOuterProduct (vec, vec); 133 | mat (pcl2::createSeries (3, 6)) << mat3x3; 134 | std::cout << mat << std::endl << std::endl; 135 | 136 | 137 | return (0); 138 | } 139 | -------------------------------------------------------------------------------- /tools/pcl2_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "pcl2/cloud.h" 4 | #include "pcl2/matrix.h" 5 | #include "pcl2/eigen_matrix.h" 6 | #include "pcl2/io/io.h" 7 | #include "pcl2/search/neighbors.h" 8 | #include "pcl2/registration/fit.h" 9 | 10 | using namespace std; 11 | 12 | pcl2::TypedMat createIndices (int i1, int i2, int step=1) 13 | { 14 | assert (step > 0); 15 | assert (i2 >= i1); 16 | size_t n = ceil (1.0 * (i2-i1) / step); 17 | 18 | pcl2::EigenMat indices (n, 1); 19 | int index = i1; 20 | for (size_t i = 0; i < n; ++i) 21 | { 22 | indices (i, 0) = index; 23 | index += step; 24 | } 25 | return (indices); 26 | } 27 | 28 | void printChannelNames (const pcl2::Cloud & cloud) 29 | { 30 | vector channel_names = cloud.getChannelNames (); 31 | for (size_t i = 0; i < channel_names.size (); ++i) 32 | cout << " - " << channel_names[i] << endl; 33 | } 34 | 35 | void print (const pcl2::Mat & matrix) 36 | { 37 | pcl2::MatF matf = matrix; 38 | for (size_t i = 0; i < matf.rows (); ++i) 39 | { 40 | cout << matf (i, 0); 41 | for (size_t j = 1; j < matf.cols (); ++j) 42 | cout << ", " << matf (i, j); 43 | cout << endl; 44 | } 45 | } 46 | 47 | void printRow (const pcl2::Mat & matrix, size_t i) 48 | { 49 | pcl2::MatF matf = matrix; 50 | cout << matf (i, 0); 51 | for (size_t j = 1; j < matf.cols (); ++j) 52 | cout << ", " << matf (i, j); 53 | cout << endl; 54 | } 55 | 56 | void examples () 57 | { 58 | // First, I'll create an empty Cloud 59 | pcl2::Cloud cloud; 60 | 61 | // This cloud is just an empty container, so it won't have any channels. 62 | cout << "Created a cloud with " << cloud.channelCount () << "channels. " 63 | << "cloud.empty () = " << cloud.empty () << endl; 64 | 65 | // Now I'll load some data from disk and store it in the cloud. 66 | cloud = pcl2::loadCloud ("bunny.pcd"); 67 | 68 | // It will now have some channels 69 | cout << "This cloud has " << cloud.channelCount () << "channels and " << cloud.size () << " points." << endl; 70 | 71 | // I'll get a list of the channel names and print them out 72 | vector channel_names = cloud.getChannelNames (); 73 | cout << "The channel names are: " << endl; 74 | for (size_t i = 0; i < channel_names.size (); ++i) 75 | cout << " - " << channel_names[i] << endl; 76 | 77 | // Now I'll create a new Nx3 matrix 78 | int n = cloud.size (); 79 | pcl2::EigenMat a (n, 3); 80 | 81 | // 82 | 83 | } 84 | 85 | int main (int argc, char ** argv) 86 | { 87 | // Creating empty cloud 88 | pcl2::Cloud cloud; 89 | cout << "Created cloud: cloud.channelCount () = " << cloud.channelCount () << ", " 90 | << "cloud.empty () = " << cloud.empty () << endl; 91 | 92 | // Creating matrix 93 | pcl2::EigenMat a (100, 3); 94 | cout << "Created matrix: " << a.rows () << " by " << a.cols () << endl; 95 | 96 | // Adding channel to cloud 97 | cloud.insert ("xyz", a); 98 | cout << "Added matrix to cloud: cloud.channelCount () = " << cloud.channelCount () << endl; 99 | cout << "List of channels contained in cloud:" << endl; 100 | printChannelNames (cloud); 101 | 102 | // Accessing/editing channel data 103 | pcl2::Mat & matrix_ref = cloud["xyz"]; 104 | cout << "Accessed matrix from cloud: " << matrix_ref.rows () << " by " << matrix_ref.cols () << endl; 105 | 106 | cout << "Filling in point data..." << endl; 107 | pcl2::MatF pts = cloud["xyz"]; 108 | for (size_t i = 0; i < pts.rows (); ++i) 109 | for (size_t j = 0; j < pts.cols (); ++j) 110 | pts (i, j) = (i+1)+0.1*(j+1); 111 | cout << "...done." << endl; 112 | 113 | for (size_t i = 0; i < 10; ++i) 114 | { 115 | cout << "The " << (i+1) << "th row of pts: " 116 | << pts (i,0) << ", " << pts (i, 1) << ", " << pts (i,2) << endl; 117 | } 118 | cout << "..." << endl; 119 | 120 | // Creating a view 121 | pcl2::TypedMat idx = createIndices (0, 100, 10); 122 | pcl2::MatF view = pts (idx); 123 | for (size_t i = 0; i < view.rows (); ++i) 124 | { 125 | cout << "The " << (i+1) << "th row of view: " 126 | << view (i,0) << ", " << view (i, 1) << ", " << view (i,2) << endl; 127 | } 128 | 129 | // Creating a copy of a view 130 | pcl2::Mat view_copy = view.copy (); 131 | print (view_copy); 132 | 133 | // Changing data will change the view but not the copy 134 | pts (0,0) = 1000.0; 135 | printRow (pts, 0); 136 | printRow (view, 0); 137 | printRow (view_copy, 0); 138 | 139 | 140 | pcl2::Cloud bunny = pcl2::loadCloud ("../data/bunny.pcd"); 141 | 142 | pcl2::EigenMat query_point (1, 3); 143 | query_point (0,0) = -0.01; 144 | query_point (0,1) = 0.1; 145 | query_point (0,2) = 0.04; 146 | 147 | 148 | pcl2::Cloud nhood; 149 | if (false) 150 | { 151 | //pcl2::TypedMat nn_idx = findKNearestNeighbors (bunny, query_point, 20); 152 | pcl2::TypedMat nn_idx = pcl2::findFixedRadiusNeighbors (bunny, query_point, 0.025); 153 | nhood = bunny (nn_idx); 154 | } 155 | else 156 | { 157 | nhood = pcl2::computeFixedRadiusNeighborhood (bunny, query_point, 0.05); 158 | } 159 | pcl2::saveCloud ("foo.pcd", nhood); 160 | 161 | cout << "before!" << endl; 162 | pcl2::MatF plane = pcl2::fitPlaneLLS (nhood); 163 | cout << "after!" << endl; 164 | 165 | pcl2::EigenMat plane_normal (1, 3); 166 | pcl2::EigenMat curvature (1,1); 167 | for (int i = 0; i < 3; ++i) plane_normal (0, i) = plane (0, i); 168 | pcl2::Cloud surf_norm; 169 | surf_norm.insert ("xyz", query_point); 170 | surf_norm.insert ("normals", plane_normal); 171 | surf_norm.insert ("curvature", curvature); 172 | pcl2::saveCloud ("foo2.pcd", surf_norm); 173 | 174 | return (0); 175 | } 176 | -------------------------------------------------------------------------------- /tools/rst_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "pcl2/matrix.h" 6 | #include "pcl2/eigen_matrix.h" 7 | #include "pcl2/row.h" 8 | #include "pcl2/math.h" 9 | #include "pcl2/stats.h" 10 | #include "pcl2/io/io.h" 11 | #include "pcl2/search/neighbors.h" 12 | #include "pcl2/registration/fit.h" 13 | #include "pcl2/create.h" 14 | 15 | #define START_RST_CODEBLOCK(rst) rst.openCodeblock(__FILE__, __LINE__+1); 16 | #define END_RST_CODEBLOCK(rst) rst.closeCodeblock(__LINE__-1); 17 | 18 | class RSTWriter 19 | { 20 | public: 21 | RSTWriter () : codeblock_open_ (false) {} 22 | 23 | void addRaw (const std::string & str) 24 | { 25 | strstream_ << str; 26 | } 27 | void addTitle (const std::string & title) 28 | { 29 | int len = title.length (); 30 | strstream_ << std::setw (len) << std::setfill('=') << "" << std::endl 31 | << title << std::endl 32 | << std::setw (len) << "" << std::endl 33 | << std::endl; 34 | } 35 | void addSubtitle (const std::string & subtitle, size_t depth=1) 36 | { 37 | char fill; 38 | switch (depth) 39 | { 40 | case 0: fill = '-'; 41 | break; 42 | case 1: fill = '*'; 43 | break; 44 | case 2: fill = '^'; 45 | break; 46 | case 3: fill = '%'; 47 | break; 48 | case 4: fill = '#'; 49 | break; 50 | default: fill = '~'; 51 | } 52 | int len = subtitle.length (); 53 | strstream_ << subtitle << std::endl 54 | << std::setfill (fill) << std::setw (len) << "" << std::endl 55 | << std::endl; 56 | } 57 | void addText (const std::string & text) 58 | { 59 | strstream_ << text << std::endl << std::endl; 60 | } 61 | template void addMat (const pcl2::TypedMat & mat) 62 | { 63 | const int w = 15; 64 | int prec = strstream_.precision (); 65 | strstream_.precision (3); 66 | 67 | strstream_ << ".. class:: matrix" << std::endl << std::endl; 68 | for (size_t j = 0; j < mat.cols (); ++j) 69 | strstream_ << std::setfill ('=') << std::setw (w+1) << " "; 70 | strstream_ << std::endl; 71 | for (size_t i = 0; i < mat.rows (); ++i) 72 | { 73 | for (size_t j = 0; j < mat.cols (); ++j) 74 | { 75 | strstream_ << std::setfill (' ') << std::setw (w) << std::fixed << mat (i, j) << " "; 76 | } 77 | strstream_ << std::endl; 78 | } 79 | for (size_t j = 0; j < mat.cols (); ++j) 80 | strstream_ << std::setfill ('=') << std::setw (w+1) << " "; 81 | strstream_ << std::endl << std::endl; 82 | 83 | strstream_.precision (prec); 84 | } 85 | 86 | void addImage (const std::string & filename, int other_stuff=false) 87 | { 88 | strstream_ << ".. image:: " << filename << std::endl << std::endl; 89 | } 90 | 91 | void openCodeblock (const std::string & filename, size_t start) 92 | { 93 | assert (!codeblock_open_); 94 | code_filename_ = filename; 95 | code_start_ = start; 96 | codeblock_open_ = true; 97 | } 98 | void closeCodeblock (size_t end) 99 | { 100 | assert (codeblock_open_); 101 | code_end_ = end; 102 | codeblock_open_ = false; 103 | // write the code block out to rst 104 | strstream_ << ".. literalinclude:: " << code_filename_ << std::endl 105 | << " :language: cpp" << std::endl 106 | << " :lines: " << code_start_ << " - " << code_end_ << std::endl 107 | << std::endl; 108 | } 109 | void write (const std::string filename) 110 | { 111 | std::ofstream output_file; 112 | output_file.open (filename.c_str ()); 113 | output_file << strstream_.str (); 114 | output_file.close(); 115 | } 116 | 117 | protected: 118 | std::stringstream strstream_; 119 | bool codeblock_open_; 120 | std::string code_filename_; 121 | size_t code_start_, code_end_; 122 | }; 123 | 124 | int 125 | main (int argc, char ** argv) 126 | { 127 | RSTWriter rst; 128 | 129 | rst.addTitle ("Example title"); 130 | 131 | rst.addText ("This is a simple example of how to write a tutorial in a single cpp file"); 132 | 133 | rst.addSubtitle ("Example subtitle"); 134 | 135 | rst.addText ("The following example shows how to create " 136 | "a matrix and fill it with random values."); 137 | 138 | START_RST_CODEBLOCK(rst); 139 | // Create an N by M matrix of floats 140 | int n = 8; 141 | int m = 3; 142 | pcl2::EigenMat mat = pcl2::EigenMat (n, m); 143 | mat << pcl2::createRandom (n, m); 144 | END_RST_CODEBLOCK(rst); 145 | 146 | rst.addText ("The next line displays the matrix"); 147 | 148 | START_RST_CODEBLOCK(rst); 149 | std::cout << mat << std::endl; 150 | END_RST_CODEBLOCK(rst); 151 | 152 | rst.addText ("and the output should look like this:"); 153 | rst.addMat (mat); 154 | 155 | rst.addText ("And if we wanted to display an image, we could."); 156 | rst.addImage ("./image.png"); 157 | 158 | rst.write ("rst_test.rst"); 159 | 160 | } 161 | --------------------------------------------------------------------------------