Updated cmake for ARM/Android build

This commit is contained in:
matlabbe
2016-01-21 17:11:57 -05:00
parent c367fe915e
commit 874816b679
13 changed files with 150 additions and 33 deletions
+34 -4
View File
@@ -119,6 +119,9 @@ set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
IF(APPLE) IF(APPLE)
OPTION(BUILD_AS_BUNDLE "Set to ON to build as bundle (DragNDrop)" OFF) OPTION(BUILD_AS_BUNDLE "Set to ON to build as bundle (DragNDrop)" OFF)
ENDIF(APPLE) ENDIF(APPLE)
OPTION(BUILD_APP "Build main application" ON)
OPTION(BUILD_TOOLS "Build tools" ON)
OPTION(BUILD_EXAMPLES "Build examples" ON)
####### DEPENDENCIES ####### ####### DEPENDENCIES #######
@@ -135,6 +138,20 @@ option(WITH_FLYCAPTURE2 "Include FlyCapture2/Triclops support" 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)
FIND_PACKAGE(ZLIB REQUIRED QUIET) FIND_PACKAGE(ZLIB REQUIRED QUIET)
# OpenMP ("-fopenmp" should be added for flann included in PCL)
# the gcc-4.2.1 coming with MacOS X is not compatible with the OpenMP pragmas we use, so disabling OpenMP for it
if((NOT APPLE) OR (NOT CMAKE_COMPILER_IS_GNUCXX) OR (GCC_VERSION VERSION_GREATER 4.2.1) OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
find_package(OpenMP)
endif()
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
message (STATUS "Found OpenMP")
else(OPENMP_FOUND)
message (STATUS "Not found OpenMP")
endif()
IF(OpenCV_FOUND) IF(OpenCV_FOUND)
MESSAGE(STATUS "Found OpenCV: ${OpenCV_INCLUDE_DIRS}") MESSAGE(STATUS "Found OpenCV: ${OpenCV_INCLUDE_DIRS}")
ENDIF(OpenCV_FOUND) ENDIF(OpenCV_FOUND)
@@ -272,13 +289,19 @@ ADD_SUBDIRECTORY( corelib )
IF(Qt5_FOUND OR (QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND)) IF(Qt5_FOUND OR (QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND))
ADD_SUBDIRECTORY( guilib ) ADD_SUBDIRECTORY( guilib )
ADD_SUBDIRECTORY( app ) IF(BUILD_APP)
ADD_SUBDIRECTORY( app )
ENDIF(BUILD_APP)
ELSEIF(WITH_QT) ELSEIF(WITH_QT)
MESSAGE(WARNING "Qt not found, the GUI lib and the stand-alone application will not be compiled...") MESSAGE(WARNING "Qt not found, the GUI lib and the stand-alone application will not be compiled...")
ENDIF() ENDIF()
ADD_SUBDIRECTORY( tools ) IF(BUILD_TOOLS)
ADD_SUBDIRECTORY( examples ) ADD_SUBDIRECTORY( tools )
ENDIF(BUILD_TOOLS)
IF(BUILD_EXAMPLES)
ADD_SUBDIRECTORY( examples )
ENDIF(BUILD_EXAMPLES)
####################### #######################
# Uninstall target, for "make uninstall" # Uninstall target, for "make uninstall"
@@ -303,7 +326,11 @@ set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/corelib/include"
"${PROJECT_SOURCE_DIR}/guilib/include" "${PROJECT_SOURCE_DIR}/guilib/include"
"${PROJECT_SOURCE_DIR}/utilite/include") "${PROJECT_SOURCE_DIR}/utilite/include")
set(CONF_LIB_DIR "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}") set(CONF_LIB_DIR "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
set(CONF_WITH_GUI ${WITH_QT}) IF(QT4_FOUND OR Qt5_FOUND)
set(CONF_WITH_GUI ON)
ELSE()
set(CONF_WITH_GUI OFF)
ENDIF()
configure_file(RTABMapConfig.cmake.in configure_file(RTABMapConfig.cmake.in
"${PROJECT_BINARY_DIR}/RTABMapConfig.cmake" @ONLY) "${PROJECT_BINARY_DIR}/RTABMapConfig.cmake" @ONLY)
@@ -412,6 +439,9 @@ MESSAGE(STATUS "Info :")
MESSAGE(STATUS " Version : ${RTABMAP_VERSION}") MESSAGE(STATUS " Version : ${RTABMAP_VERSION}")
MESSAGE(STATUS " CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") MESSAGE(STATUS " CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS " CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") MESSAGE(STATUS " CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
MESSAGE(STATUS " BUILD_APP = ${BUILD_APP}")
MESSAGE(STATUS " BUILD_TOOLS = ${BUILD_TOOLS}")
MESSAGE(STATUS " BUILD_EXAMPLES = ${BUILD_EXAMPLES}")
IF(NOT WIN32) IF(NOT WIN32)
# see comment above for the BUILD_SHARED_LIBS option on Windows # see comment above for the BUILD_SHARED_LIBS option on Windows
MESSAGE(STATUS " BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}") MESSAGE(STATUS " BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}")
@@ -35,9 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/core/Camera.h" #include "rtabmap/core/Camera.h"
#include "rtabmap/core/CameraRGB.h" #include "rtabmap/core/CameraRGB.h"
#include <pcl/io/openni_camera/openni_depth_image.h>
#include <pcl/io/openni_camera/openni_image.h>
#include <boost/signals2/connection.hpp> #include <boost/signals2/connection.hpp>
namespace openni namespace openni
+12
View File
@@ -223,12 +223,24 @@ SET(RESOURCES_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/DatabaseSchema_sql.h ${CMAKE_CURRENT_BINARY_DIR}/DatabaseSchema_sql.h
) )
IF(ANDROID)
IF(NOT URESOURCEGENERATOR)
MESSAGE( FATAL_ERROR "URESOURCEGENERATOR is not defined (it should point out on \"uresourcegenerator\" application created by a non-Android build), CMake will exit." )
ENDIF(NOT URESOURCEGENERATOR)
ADD_CUSTOM_COMMAND(
OUTPUT ${RESOURCES_HEADERS}
COMMAND ${URESOURCEGENERATOR} -n rtabmap -p ${CMAKE_CURRENT_BINARY_DIR} ${RESOURCES}
COMMENT "[Creating resources]"
DEPENDS ${R}
)
ELSE()
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${RESOURCES_HEADERS} OUTPUT ${RESOURCES_HEADERS}
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uresourcegenerator -n rtabmap -p ${CMAKE_CURRENT_BINARY_DIR} ${RESOURCES} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uresourcegenerator -n rtabmap -p ${CMAKE_CURRENT_BINARY_DIR} ${RESOURCES}
COMMENT "[Creating resources]" COMMENT "[Creating resources]"
DEPENDS ${R} uresourcegenerator DEPENDS ${R} uresourcegenerator
) )
ENDIF()
#################################### ####################################
# Generate resources files END # Generate resources files END
-3
View File
@@ -437,7 +437,6 @@ std::vector<std::string> CameraImages::filenames() const
SensorData CameraImages::captureImage() SensorData CameraImages::captureImage()
{ {
double actualDelay = 0.0;
if(syncImageRateWithStamps_ && _captureDelay>0.0) if(syncImageRateWithStamps_ && _captureDelay>0.0)
{ {
int sleepTime = (1000*_captureDelay - 1000.0f*_captureTimer.getElapsedTime()); int sleepTime = (1000*_captureDelay - 1000.0f*_captureTimer.getElapsedTime());
@@ -460,8 +459,6 @@ SensorData CameraImages::captureImage()
} }
} }
actualDelay = 1.0/(_captureTimer.getElapsedTime());
// Add precision at the cost of a small overhead // Add precision at the cost of a small overhead
while(_captureTimer.getElapsedTime() < _captureDelay-0.000001) while(_captureTimer.getElapsedTime() < _captureDelay-0.000001)
{ {
+2
View File
@@ -42,6 +42,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_OPENNI #ifdef HAVE_OPENNI
#include <pcl/io/openni_grabber.h> #include <pcl/io/openni_grabber.h>
#include <pcl/io/oni_grabber.h> #include <pcl/io/oni_grabber.h>
#include <pcl/io/openni_camera/openni_depth_image.h>
#include <pcl/io/openni_camera/openni_image.h>
#endif #endif
#ifdef WITH_FREENECT #ifdef WITH_FREENECT
+47 -14
View File
@@ -40,7 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <opencv2/opencv_modules.hpp> #include <opencv2/opencv_modules.hpp>
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
#include <opencv2/gpu/gpu.hpp> #include <opencv2/gpu/gpu.hpp>
#endif
#else #else
#include <opencv2/core/cuda.hpp> #include <opencv2/core/cuda.hpp>
#endif #endif
@@ -891,11 +893,19 @@ void ORB::parseParameters(const ParametersMap & parameters)
Parameters::parse(parameters, Parameters::kFASTNonmaxSuppression(), nonmaxSuppresion_); Parameters::parse(parameters, Parameters::kFASTNonmaxSuppression(), nonmaxSuppresion_);
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
if(gpu_ && cv::gpu::getCudaEnabledDeviceCount() == 0) if(gpu_ && cv::gpu::getCudaEnabledDeviceCount() == 0)
{ {
UWARN("GPU version of ORB not available! Using CPU version instead..."); UWARN("GPU version of ORB not available! Using CPU version instead...");
gpu_ = false; gpu_ = false;
} }
#else
if(gpu_)
{
UWARN("GPU version of ORB not available (OpenCV not built with gpu/cuda module)! Using CPU version instead...");
gpu_ = false;
}
#endif
#else #else
#ifndef HAVE_OPENCV_CUDAFEATURES2D #ifndef HAVE_OPENCV_CUDAFEATURES2D
if(gpu_) if(gpu_)
@@ -913,8 +923,12 @@ void ORB::parseParameters(const ParametersMap & parameters)
if(gpu_) if(gpu_)
{ {
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
_gpuOrb = cv::Ptr<CV_ORB_GPU>(new CV_ORB_GPU(this->getMaxFeatures(), scaleFactor_, nLevels_, edgeThreshold_, firstLevel_, WTA_K_, scoreType_, patchSize_)); _gpuOrb = cv::Ptr<CV_ORB_GPU>(new CV_ORB_GPU(this->getMaxFeatures(), scaleFactor_, nLevels_, edgeThreshold_, firstLevel_, WTA_K_, scoreType_, patchSize_));
_gpuOrb->setFastParams(fastThreshold_, nonmaxSuppresion_); _gpuOrb->setFastParams(fastThreshold_, nonmaxSuppresion_);
#else
UFATAL("not supposed to be here");
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D #ifdef HAVE_OPENCV_CUDAFEATURES2D
UFATAL("not implemented"); UFATAL("not implemented");
@@ -945,9 +959,13 @@ std::vector<cv::KeyPoint> ORB::generateKeypointsImpl(const cv::Mat & image, cons
if(gpu_) if(gpu_)
{ {
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
cv::gpu::GpuMat imgGpu(imgRoi); cv::gpu::GpuMat imgGpu(imgRoi);
cv::gpu::GpuMat maskGpu(maskRoi); cv::gpu::GpuMat maskGpu(maskRoi);
(*_gpuOrb.obj)(imgGpu, maskGpu, keypoints); (*_gpuOrb.obj)(imgGpu, maskGpu, keypoints);
#else
UERROR("Cannot use ORBGPU because OpenCV is not built with gpu module.");
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D #ifdef HAVE_OPENCV_CUDAFEATURES2D
UFATAL("not implemented"); UFATAL("not implemented");
@@ -974,17 +992,10 @@ cv::Mat ORB::generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyP
if(gpu_) if(gpu_)
{ {
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
cv::gpu::GpuMat imgGpu(image); cv::gpu::GpuMat imgGpu(image);
cv::gpu::GpuMat descriptorsGPU; cv::gpu::GpuMat descriptorsGPU;
(*_gpuOrb.obj)(imgGpu, cv::gpu::GpuMat(), keypoints, descriptorsGPU); (*_gpuOrb.obj)(imgGpu, cv::gpu::GpuMat(), keypoints, descriptorsGPU);
#else
cv::cuda::GpuMat imgGpu(image);
cv::cuda::GpuMat descriptorsGPU;
#ifdef HAVE_OPENCV_CUDAFEATURES2D
UFATAL("not implemented");
#endif
#endif
// Download descriptors // Download descriptors
if (descriptorsGPU.empty()) if (descriptorsGPU.empty())
descriptors = cv::Mat(); descriptors = cv::Mat();
@@ -994,6 +1005,16 @@ cv::Mat ORB::generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyP
descriptors = cv::Mat(descriptorsGPU.size(), CV_32F); descriptors = cv::Mat(descriptorsGPU.size(), CV_32F);
descriptorsGPU.download(descriptors); descriptorsGPU.download(descriptors);
} }
#else
UERROR("GPU version of ORB not available (OpenCV not built with gpu/cuda module)! Using CPU version instead...");
#endif
#else
cv::cuda::GpuMat imgGpu(image);
cv::cuda::GpuMat descriptorsGPU;
#ifdef HAVE_OPENCV_CUDAFEATURES2D
UFATAL("not implemented");
#endif
#endif
} }
else else
{ {
@@ -1041,34 +1062,42 @@ void FAST::parseParameters(const ParametersMap & parameters)
UASSERT_MSG(threshold_ <= maxThreshold_, uFormat("%d vs %d", threshold_, maxThreshold_).c_str()); UASSERT_MSG(threshold_ <= maxThreshold_, uFormat("%d vs %d", threshold_, maxThreshold_).c_str());
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
if(gpu_ && cv::gpu::getCudaEnabledDeviceCount() == 0) if(gpu_ && cv::gpu::getCudaEnabledDeviceCount() == 0)
{ {
UWARN("GPU version of FAST not available! Using CPU version instead..."); UWARN("GPU version of FAST not available! Using CPU version instead...");
gpu_ = false; gpu_ = false;
} }
#else #else
if(gpu_)
{
UWARN("GPU version of FAST not available (OpenCV not built with gpu/cuda module)! Using CPU version instead...");
gpu_ = false;
}
#endif
#else
#ifdef HAVE_OPENCV_CUDAFEATURES2D
if(gpu_ && cv::cuda::getCudaEnabledDeviceCount() == 0) if(gpu_ && cv::cuda::getCudaEnabledDeviceCount() == 0)
{ {
UWARN("GPU version of FAST not available! Using CPU version instead..."); UWARN("GPU version of FAST not available! Using CPU version instead...");
gpu_ = false; gpu_ = false;
} }
#ifndef HAVE_OPENCV_CUDAFEATURES2D #else
if(gpu_) if(gpu_)
{ {
UWARN("GPU version of FAST not available (OpenCV cudafeatures2d module)! Using CPU version instead..."); UWARN("GPU version of FAST not available (OpenCV cudafeatures2d module)! Using CPU version instead...");
gpu_ = false; gpu_ = false;
} }
#endif #endif
if(gpu_)
{
UWARN("GPU version of FAST is available but not yet implemented! Using CPU version instead...");
}
gpu_ = false;
#endif #endif
if(gpu_) if(gpu_)
{ {
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
_gpuFast = new CV_FAST_GPU(threshold_, nonmaxSuppression_, gpuKeypointsRatio_); _gpuFast = new CV_FAST_GPU(threshold_, nonmaxSuppression_, gpuKeypointsRatio_);
#else
UFATAL("not supposed to be here!");
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D #ifdef HAVE_OPENCV_CUDAFEATURES2D
UFATAL("not implemented"); UFATAL("not implemented");
@@ -1116,9 +1145,13 @@ std::vector<cv::KeyPoint> FAST::generateKeypointsImpl(const cv::Mat & image, con
if(gpu_) if(gpu_)
{ {
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
cv::gpu::GpuMat imgGpu(imgRoi); cv::gpu::GpuMat imgGpu(imgRoi);
cv::gpu::GpuMat maskGpu(maskRoi); cv::gpu::GpuMat maskGpu(maskRoi);
(*_gpuFast.obj)(imgGpu, maskGpu, keypoints); (*_gpuFast.obj)(imgGpu, maskGpu, keypoints);
#else
UERROR("Cannot use FAST GPU because OpenCV is not built with gpu module.");
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D #ifdef HAVE_OPENCV_CUDAFEATURES2D
UFATAL("not implemented"); UFATAL("not implemented");
+23 -2
View File
@@ -462,24 +462,33 @@ void VWDictionary::setNNStrategy(NNStrategy strategy)
if(strategy!=kNNUndef) if(strategy!=kNNUndef)
{ {
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
if(strategy == kNNBruteForceGPU && !cv::gpu::getCudaEnabledDeviceCount()) if(strategy == kNNBruteForceGPU && !cv::gpu::getCudaEnabledDeviceCount())
{ {
UERROR("Nearest neighobr strategy \"kNNBruteForceGPU\" chosen but no CUDA devices found! Doing \"kNNBruteForce\" instead."); UERROR("Nearest neighobr strategy \"kNNBruteForceGPU\" chosen but no CUDA devices found! Doing \"kNNBruteForce\" instead.");
strategy = kNNBruteForce; strategy = kNNBruteForce;
} }
#else #else
if(strategy == kNNBruteForceGPU)
{
UERROR("Nearest neighobr strategy \"kNNBruteForceGPU\" chosen but OpenCV is not built with GPU/cuda module! Doing \"kNNBruteForce\" instead.");
strategy = kNNBruteForce;
}
#endif
#else
#if HAVE_OPENCV_CUDAFEATURES2D
if(strategy == kNNBruteForceGPU && !cv::cuda::getCudaEnabledDeviceCount()) if(strategy == kNNBruteForceGPU && !cv::cuda::getCudaEnabledDeviceCount())
{ {
UERROR("Nearest neighobr strategy \"kNNBruteForceGPU\" chosen but no CUDA devices found! Doing \"kNNBruteForce\" instead."); UERROR("Nearest neighobr strategy \"kNNBruteForceGPU\" chosen but no CUDA devices found! Doing \"kNNBruteForce\" instead.");
strategy = kNNBruteForce; strategy = kNNBruteForce;
} }
#endif #else
#ifndef HAVE_OPENCV_CUDAFEATURES2D
if(strategy == kNNBruteForceGPU) if(strategy == kNNBruteForceGPU)
{ {
UERROR("Nearest neighobr strategy \"kNNBruteForceGPU\" chosen but OpenCV cudafeatures2d module is not found! Doing \"kNNBruteForce\" instead."); UERROR("Nearest neighobr strategy \"kNNBruteForceGPU\" chosen but OpenCV cudafeatures2d module is not found! Doing \"kNNBruteForce\" instead.");
strategy = kNNBruteForce; strategy = kNNBruteForce;
} }
#endif
#endif #endif
if(RTABMAP_NONFREE == 0 && strategy == kNNFlannKdTree) if(RTABMAP_NONFREE == 0 && strategy == kNNFlannKdTree)
@@ -832,6 +841,7 @@ std::list<int> VWDictionary::addNewWords(const cv::Mat & descriptors,
{ {
bruteForce = true; bruteForce = true;
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
cv::gpu::GpuMat newDescriptorsGpu(descriptors); cv::gpu::GpuMat newDescriptorsGpu(descriptors);
cv::gpu::GpuMat lastDescriptorsGpu(_dataTree); cv::gpu::GpuMat lastDescriptorsGpu(_dataTree);
if(type==CV_8U) if(type==CV_8U)
@@ -844,6 +854,9 @@ std::list<int> VWDictionary::addNewWords(const cv::Mat & descriptors,
cv::gpu::BruteForceMatcher_GPU<cv::L2<float> > gpuMatcher; cv::gpu::BruteForceMatcher_GPU<cv::L2<float> > gpuMatcher;
gpuMatcher.knnMatch(newDescriptorsGpu, lastDescriptorsGpu, matches, k); gpuMatcher.knnMatch(newDescriptorsGpu, lastDescriptorsGpu, matches, k);
} }
#else
UERROR("Cannot use brute Force GPU because OpenCV is not built with gpu module.");
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D #ifdef HAVE_OPENCV_CUDAFEATURES2D
cv::cuda::GpuMat newDescriptorsGpu(descriptors); cv::cuda::GpuMat newDescriptorsGpu(descriptors);
@@ -859,6 +872,8 @@ std::list<int> VWDictionary::addNewWords(const cv::Mat & descriptors,
gpuMatcher = cv::cuda::DescriptorMatcher::createBFMatcher(cv::NORM_L2); gpuMatcher = cv::cuda::DescriptorMatcher::createBFMatcher(cv::NORM_L2);
gpuMatcher->knnMatch(newDescriptorsGpu, lastDescriptorsGpu, matches, k); gpuMatcher->knnMatch(newDescriptorsGpu, lastDescriptorsGpu, matches, k);
} }
#else
UERROR("Cannot use brute Force GPU because OpenCV is not built with cuda module.");
#endif #endif
#endif #endif
} }
@@ -1068,6 +1083,7 @@ std::vector<int> VWDictionary::findNN(const std::list<VisualWord *> & vws) const
{ {
bruteForce = true; bruteForce = true;
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
cv::gpu::GpuMat newDescriptorsGpu(query); cv::gpu::GpuMat newDescriptorsGpu(query);
cv::gpu::GpuMat lastDescriptorsGpu(_dataTree); cv::gpu::GpuMat lastDescriptorsGpu(_dataTree);
if(type==CV_8U) if(type==CV_8U)
@@ -1080,6 +1096,9 @@ std::vector<int> VWDictionary::findNN(const std::list<VisualWord *> & vws) const
cv::gpu::BruteForceMatcher_GPU<cv::L2<float> > gpuMatcher; cv::gpu::BruteForceMatcher_GPU<cv::L2<float> > gpuMatcher;
gpuMatcher.knnMatch(newDescriptorsGpu, lastDescriptorsGpu, matches, k); gpuMatcher.knnMatch(newDescriptorsGpu, lastDescriptorsGpu, matches, k);
} }
#else
UERROR("Cannot use brute Force GPU because OpenCV is not built with gpu module.");
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D #ifdef HAVE_OPENCV_CUDAFEATURES2D
cv::cuda::GpuMat newDescriptorsGpu(query); cv::cuda::GpuMat newDescriptorsGpu(query);
@@ -1095,6 +1114,8 @@ std::vector<int> VWDictionary::findNN(const std::list<VisualWord *> & vws) const
gpuMatcher = cv::cuda::DescriptorMatcher::createBFMatcher(cv::NORM_L2); gpuMatcher = cv::cuda::DescriptorMatcher::createBFMatcher(cv::NORM_L2);
gpuMatcher->knnMatchAsync(newDescriptorsGpu, lastDescriptorsGpu, matches, k); gpuMatcher->knnMatchAsync(newDescriptorsGpu, lastDescriptorsGpu, matches, k);
} }
#else
UERROR("Cannot use brute Force GPU because OpenCV is not built with cuda module.");
#endif #endif
#endif #endif
} }
+9 -1
View File
@@ -36,7 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <pcl/features/normal_3d.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>
#ifndef DISABLE_VTK
#include <pcl/surface/vtk_smoothing/vtk_mesh_quadric_decimation.h> #include <pcl/surface/vtk_smoothing/vtk_mesh_quadric_decimation.h>
#endif
namespace rtabmap namespace rtabmap
{ {
@@ -367,11 +370,16 @@ void adjustNormalsToViewPoints(
pcl::PolygonMesh::Ptr meshDecimation(const pcl::PolygonMesh::Ptr & mesh, float factor) pcl::PolygonMesh::Ptr meshDecimation(const pcl::PolygonMesh::Ptr & mesh, float factor)
{ {
pcl::PolygonMesh::Ptr output(new pcl::PolygonMesh);
#ifndef DISABLE_VTK
pcl::MeshQuadricDecimationVTK mqd; pcl::MeshQuadricDecimationVTK mqd;
mqd.setTargetReductionFactor(factor); mqd.setTargetReductionFactor(factor);
mqd.setInputMesh(mesh); mqd.setInputMesh(mesh);
pcl::PolygonMesh::Ptr output(new pcl::PolygonMesh);
mqd.process (*output); mqd.process (*output);
#else
UWARN("RTAB-Map is not built with VTK module so mesh decimation cannot be used!");
*output = *mesh;
#endif
return output; return output;
} }
+7 -2
View File
@@ -77,10 +77,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <opencv2/opencv_modules.hpp> #include <opencv2/opencv_modules.hpp>
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
#include <opencv2/gpu/gpu.hpp> #include <opencv2/gpu/gpu.hpp>
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D
#include <opencv2/core/cuda.hpp> #include <opencv2/core/cuda.hpp>
#endif #endif
#endif
using namespace rtabmap; using namespace rtabmap;
@@ -104,11 +108,12 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
bool haveCuda = false; bool haveCuda = false;
#if CV_MAJOR_VERSION < 3 #if CV_MAJOR_VERSION < 3
#ifdef HAVE_OPENCV_GPU
haveCuda = cv::gpu::getCudaEnabledDeviceCount() != 0; haveCuda = cv::gpu::getCudaEnabledDeviceCount() != 0;
#endif
#else #else
#ifdef HAVE_OPENCV_CUDAFEATURES2D
haveCuda = cv::cuda::getCudaEnabledDeviceCount() != 0; haveCuda = cv::cuda::getCudaEnabledDeviceCount() != 0;
#ifndef HAVE_OPENCV_CUDAFEATURES2D
haveCuda = false;
#endif #endif
#endif #endif
if(!haveCuda) if(!haveCuda)
+2 -2
View File
@@ -1,9 +1,9 @@
SET(UTILITE_VERSION "0.3.0") SET(UTILITE_VERSION "0.3.0")
ADD_DEFINITIONS(-DUTILITE_VERSION="${UTILITE_VERSION}") ADD_DEFINITIONS(-DUTILITE_VERSION="${UTILITE_VERSION}")
IF(UNIX) if(UNIX AND NOT ANDROID)
FIND_PACKAGE(Pthreads REQUIRED) FIND_PACKAGE(Pthreads REQUIRED)
ENDIF(UNIX) ENDIF(UNIX AND NOT ANDROID)
ADD_SUBDIRECTORY( src ) ADD_SUBDIRECTORY( src )
ADD_SUBDIRECTORY( resource_generator ) ADD_SUBDIRECTORY( resource_generator )
@@ -84,9 +84,10 @@ class UThreadC
static void Exit() static void Exit()
{ pthread_exit(0); } { pthread_exit(0); }
#ifndef ANDROID
static void TestCancel() static void TestCancel()
{ pthread_testcancel(); } { pthread_testcancel(); }
#endif
static Handle Self() static Handle Self()
{ return (Handle)pthread_self(); } { return (Handle)pthread_self(); }
@@ -163,8 +164,10 @@ class UThreadC
static int Join( Handle H ) static int Join( Handle H )
{ return pthread_join(H,0); } { return pthread_join(H,0); }
#ifndef ANDROID
static int Kill( Handle H ) static int Kill( Handle H )
{ return pthread_cancel(H); } { return pthread_cancel(H); }
#endif
static int Detach( Handle H ) static int Detach( Handle H )
{ return pthread_detach(H); } { return pthread_detach(H); }
@@ -180,6 +183,7 @@ class UThreadC
Thread_T Data(I.Data); Thread_T Data(I.Data);
S_Create().release(); S_Create().release();
#ifndef ANDROID
if ( I.Flags & 1 /*CancelEnable*/ ) if ( I.Flags & 1 /*CancelEnable*/ )
{ {
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL);
@@ -193,6 +197,7 @@ class UThreadC
{ {
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL);
} }
#endif
if ( I.Owner ) if ( I.Owner )
I.Owner->ThreadMain(Data); I.Owner->ThreadMain(Data);
@@ -237,8 +242,10 @@ class UThreadC<void>
static void Exit() static void Exit()
{ pthread_exit(0); } { pthread_exit(0); }
#ifndef ANDROID
static void TestCancel() static void TestCancel()
{ pthread_testcancel(); } { pthread_testcancel(); }
#endif
static Handle Self() static Handle Self()
{ return (Handle)pthread_self(); } { return (Handle)pthread_self(); }
@@ -347,8 +354,10 @@ class UThreadC<void>
static int Join( Handle H ) static int Join( Handle H )
{ return pthread_join(H,0); } { return pthread_join(H,0); }
#ifndef ANDROID
static int Kill( Handle H ) static int Kill( Handle H )
{ return pthread_cancel(H); } { return pthread_cancel(H); }
#endif
static int Detach( Handle H ) static int Detach( Handle H )
{ return pthread_detach(H); } { return pthread_detach(H); }
@@ -363,6 +372,7 @@ class UThreadC<void>
Instance I(*Param); Instance I(*Param);
S_Create().release(); S_Create().release();
#ifndef ANDROID
if ( I.Flags & 1 /*CancelEnable*/ ) if ( I.Flags & 1 /*CancelEnable*/ )
{ {
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL);
@@ -376,6 +386,7 @@ class UThreadC<void>
{ {
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL);
} }
#endif
if ( I.Owner ) if ( I.Owner )
I.Owner->ThreadMain(); I.Owner->ThreadMain();
@@ -245,8 +245,10 @@ private:
//Methods from UThread<void> class hided //Methods from UThread<void> class hided
static int Join( Handle H ) static int Join( Handle H )
{ return UThreadC<void>::Join(H); } { return UThreadC<void>::Join(H); }
#ifndef ANDROID
static int Kill( Handle H ) static int Kill( Handle H )
{ return UThreadC<void>::Kill(H); } { return UThreadC<void>::Kill(H); }
#endif
static int Detach( Handle H ) static int Detach( Handle H )
{ return UThreadC<void>::Detach(H); } { return UThreadC<void>::Detach(H); }
-1
View File
@@ -29,7 +29,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/dir.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>