CMake: Added PCL_OMP option (default ON) to use OMP implementations of some PCL classes (#50)

This commit is contained in:
matlabbe
2016-07-17 21:04:11 -04:00
parent d739d04232
commit cf2bb6b599
3 changed files with 15 additions and 4 deletions
+4
View File
@@ -139,6 +139,7 @@ option(WITH_CVSBA "Include cvsba support" ON)
option(WITH_FLYCAPTURE2 "Include FlyCapture2/Triclops support" ON) option(WITH_FLYCAPTURE2 "Include FlyCapture2/Triclops support" ON)
option(WITH_ZED "Include ZED sdk support" ON) option(WITH_ZED "Include ZED sdk support" ON)
option(WITH_OCTOMAP "Include Octomap support" ON) option(WITH_OCTOMAP "Include Octomap support" ON)
option(PCL_OMP "With PCL OMP implementations" ON)
FIND_PACKAGE(OpenCV REQUIRED QUIET) FIND_PACKAGE(OpenCV REQUIRED QUIET)
FIND_PACKAGE(PCL 1.7 REQUIRED QUIET) FIND_PACKAGE(PCL 1.7 REQUIRED QUIET)
@@ -158,6 +159,9 @@ if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
message (STATUS "Found OpenMP") message (STATUS "Found OpenMP")
if(PCL_OMP)
add_definitions(-DPCL_OMP)
endif(PCL_OMP)
else(OPENMP_FOUND) else(OPENMP_FOUND)
message (STATUS "Not found OpenMP") message (STATUS "Not found OpenMP")
endif() endif()
+3 -3
View File
@@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <pcl/filters/random_sample.h> #include <pcl/filters/random_sample.h>
#include <pcl/filters/passthrough.h> #include <pcl/filters/passthrough.h>
#include <pcl/features/normal_3d.h> #include <pcl/features/normal_3d_omp.h>
#include <pcl/search/kdtree.h> #include <pcl/search/kdtree.h>
@@ -1308,7 +1308,7 @@ pcl::IndicesPtr normalFiltering(
typedef pcl::search::KdTree<pcl::PointXYZ> KdTree; typedef pcl::search::KdTree<pcl::PointXYZ> KdTree;
typedef KdTree::Ptr KdTreePtr; typedef KdTree::Ptr KdTreePtr;
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne; pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> ne;
ne.setInputCloud (cloud); ne.setInputCloud (cloud);
if(indices->size()) if(indices->size())
{ {
@@ -1368,7 +1368,7 @@ pcl::IndicesPtr normalFiltering(
typedef pcl::search::KdTree<pcl::PointXYZRGB> KdTree; typedef pcl::search::KdTree<pcl::PointXYZRGB> KdTree;
typedef KdTree::Ptr KdTreePtr; typedef KdTree::Ptr KdTreePtr;
pcl::NormalEstimation<pcl::PointXYZRGB, pcl::Normal> ne; pcl::NormalEstimationOMP<pcl::PointXYZRGB, pcl::Normal> ne;
ne.setInputCloud (cloud); ne.setInputCloud (cloud);
if(indices->size()) if(indices->size())
{ {
+8 -1
View File
@@ -33,7 +33,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <pcl/search/kdtree.h> #include <pcl/search/kdtree.h>
#include <pcl/surface/gp3.h> #include <pcl/surface/gp3.h>
#include <pcl/features/normal_3d_omp.h> #include <pcl/features/normal_3d_omp.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/mls.h> #include <pcl/surface/mls.h>
#include <pcl/surface/texture_mapping.h> #include <pcl/surface/texture_mapping.h>
#include <pcl/features/integral_image_normal.h> #include <pcl/features/integral_image_normal.h>
@@ -619,7 +618,11 @@ pcl::PointCloud<pcl::Normal>::Ptr computeNormals(
} }
// Normal estimation* // Normal estimation*
#ifdef PCL_OMP
pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> n; pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> n;
#else
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
#endif
pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>); pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
n.setInputCloud (cloud); n.setInputCloud (cloud);
// Commented: Keep the output normals size the same as the input cloud // Commented: Keep the output normals size the same as the input cloud
@@ -660,7 +663,11 @@ pcl::PointCloud<pcl::Normal>::Ptr computeNormals(
} }
// Normal estimation* // Normal estimation*
#ifdef PCL_OMP
pcl::NormalEstimationOMP<pcl::PointXYZRGB, pcl::Normal> n; pcl::NormalEstimationOMP<pcl::PointXYZRGB, pcl::Normal> n;
#else
pcl::NormalEstimation<pcl::PointXYZRGB, pcl::Normal> n;
#endif
pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>); pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
n.setInputCloud (cloud); n.setInputCloud (cloud);
// Commented: Keep the output normals size the same as the input cloud // Commented: Keep the output normals size the same as the input cloud