mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 09:07:47 +08:00
fixed cuda capable checks
This commit is contained in:
@@ -1211,13 +1211,13 @@ void SURF::parseParameters(const ParametersMap & parameters)
|
|||||||
|
|
||||||
#ifdef RTABMAP_NONFREE
|
#ifdef RTABMAP_NONFREE
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
if(gpuVersion_ && cv::gpu::getCudaEnabledDeviceCount() == 0)
|
if(gpuVersion_ && cv::gpu::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
UWARN("GPU version of SURF not available! Using CPU version instead...");
|
UWARN("GPU version of SURF not available! Using CPU version instead...");
|
||||||
gpuVersion_ = false;
|
gpuVersion_ = false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(gpuVersion_ && cv::cuda::getCudaEnabledDeviceCount() == 0)
|
if(gpuVersion_ && cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
UWARN("GPU version of SURF not available! Using CPU version instead...");
|
UWARN("GPU version of SURF not available! Using CPU version instead...");
|
||||||
gpuVersion_ = false;
|
gpuVersion_ = false;
|
||||||
@@ -1650,7 +1650,7 @@ void ORB::parseParameters(const ParametersMap & parameters)
|
|||||||
|
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#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;
|
||||||
@@ -1670,7 +1670,7 @@ void ORB::parseParameters(const ParametersMap & parameters)
|
|||||||
gpu_ = false;
|
gpu_ = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(gpu_ && cv::cuda::getCudaEnabledDeviceCount() == 0)
|
if(gpu_ && cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
UWARN("GPU version of ORB not available (no GPU found)! Using CPU version instead...");
|
UWARN("GPU version of ORB not available (no GPU found)! Using CPU version instead...");
|
||||||
gpu_ = false;
|
gpu_ = false;
|
||||||
@@ -1906,7 +1906,7 @@ void FAST::parseParameters(const ParametersMap & parameters)
|
|||||||
|
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#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;
|
||||||
@@ -1920,7 +1920,7 @@ void FAST::parseParameters(const ParametersMap & parameters)
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
#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;
|
||||||
@@ -2215,7 +2215,7 @@ void GFTT::parseParameters(const ParametersMap & parameters)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_CUDAIMGPROC
|
#ifdef HAVE_OPENCV_CUDAIMGPROC
|
||||||
if(_gpu && cv::cuda::getCudaEnabledDeviceCount() == 0)
|
if(_gpu && cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
UWARN("GPU version of GFTT not available! Using CPU version instead...");
|
UWARN("GPU version of GFTT not available! Using CPU version instead...");
|
||||||
_gpu = false;
|
_gpu = false;
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ bool VWDictionary::setNNStrategy(NNStrategy strategy)
|
|||||||
{
|
{
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPU
|
||||||
if(strategy == kNNBruteForceGPU && !cv::gpu::getCudaEnabledDeviceCount())
|
if(strategy == kNNBruteForceGPU && cv::gpu::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
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;
|
||||||
@@ -314,7 +314,7 @@ bool VWDictionary::setNNStrategy(NNStrategy strategy)
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
||||||
if(strategy == kNNBruteForceGPU && !cv::cuda::getCudaEnabledDeviceCount())
|
if(strategy == kNNBruteForceGPU && cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ add_test(NAME test_util3d_registration COMMAND test_util3d_registration)
|
|||||||
add_executable(test_util3d_features test_util3d_features.cpp)
|
add_executable(test_util3d_features test_util3d_features.cpp)
|
||||||
target_link_libraries(test_util3d_features gtest_main rtabmap_core)
|
target_link_libraries(test_util3d_features gtest_main rtabmap_core)
|
||||||
add_test(NAME test_util3d_features COMMAND test_util3d_features)
|
add_test(NAME test_util3d_features COMMAND test_util3d_features)
|
||||||
set_tests_properties(test_util3d_features PROPERTIES TIMEOUT 600)
|
|
||||||
|
|
||||||
#util3d_correspondences.h
|
#util3d_correspondences.h
|
||||||
add_executable(test_util3d_correspondences test_util3d_correspondences.cpp)
|
add_executable(test_util3d_correspondences test_util3d_correspondences.cpp)
|
||||||
@@ -71,7 +70,6 @@ add_test(NAME test_transform COMMAND test_transform)
|
|||||||
add_executable(test_stereo_dense test_stereo_dense.cpp)
|
add_executable(test_stereo_dense test_stereo_dense.cpp)
|
||||||
target_link_libraries(test_stereo_dense gtest_main rtabmap_core)
|
target_link_libraries(test_stereo_dense gtest_main rtabmap_core)
|
||||||
add_test(NAME test_stereo_dense COMMAND test_stereo_dense)
|
add_test(NAME test_stereo_dense COMMAND test_stereo_dense)
|
||||||
set_tests_properties(test_stereo_dense PROPERTIES TIMEOUT 600)
|
|
||||||
|
|
||||||
#Stereo.h (tests both BlockMatching and OpticalFlow strategies)
|
#Stereo.h (tests both BlockMatching and OpticalFlow strategies)
|
||||||
add_executable(test_stereo test_stereo.cpp)
|
add_executable(test_stereo test_stereo.cpp)
|
||||||
@@ -162,7 +160,6 @@ add_test(NAME test_landmark COMMAND test_landmark)
|
|||||||
add_executable(test_localgrid test_localgrid.cpp)
|
add_executable(test_localgrid test_localgrid.cpp)
|
||||||
target_link_libraries(test_localgrid gtest_main rtabmap_core)
|
target_link_libraries(test_localgrid gtest_main rtabmap_core)
|
||||||
add_test(NAME test_localgrid COMMAND test_localgrid)
|
add_test(NAME test_localgrid COMMAND test_localgrid)
|
||||||
set_tests_properties(test_localgrid PROPERTIES TIMEOUT 600)
|
|
||||||
|
|
||||||
#Features2d.h
|
#Features2d.h
|
||||||
add_executable(test_features2d test_features2d.cpp)
|
add_executable(test_features2d test_features2d.cpp)
|
||||||
|
|||||||
@@ -2029,7 +2029,7 @@ TEST_F(RtabmapIntegrationFixture, AppearanceOnly_PrecisionRecall)
|
|||||||
// Probe GPU availability once per detector. Build the temp instance
|
// Probe GPU availability once per detector. Build the temp instance
|
||||||
// with the same asset paths the actual run uses; otherwise SuperPoint
|
// with the same asset paths the actual run uses; otherwise SuperPoint
|
||||||
// variants log a (harmless) load failure.
|
// variants log a (harmless) load failure.
|
||||||
bool useGpu = false;
|
bool gpuAvailable = false;
|
||||||
{
|
{
|
||||||
ParametersMap probeParams;
|
ParametersMap probeParams;
|
||||||
if(detectorType == Feature2D::kFeatureSuperPointTorch)
|
if(detectorType == Feature2D::kFeatureSuperPointTorch)
|
||||||
@@ -2042,9 +2042,15 @@ TEST_F(RtabmapIntegrationFixture, AppearanceOnly_PrecisionRecall)
|
|||||||
probeParams[Parameters::kSuperPointRpautratModelPath()] = superpointRpautratModel;
|
probeParams[Parameters::kSuperPointRpautratModelPath()] = superpointRpautratModel;
|
||||||
}
|
}
|
||||||
std::unique_ptr<Feature2D> probe(Feature2D::create(detectorType, probeParams));
|
std::unique_ptr<Feature2D> probe(Feature2D::create(detectorType, probeParams));
|
||||||
if(probe) useGpu = probe->isGpuAvailable();
|
if(probe) gpuAvailable = probe->isGpuAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GPU-capable detectors are exercised twice (CPU + GPU) so both code
|
||||||
|
// paths stay covered. Detectors that don't report a GPU path run only
|
||||||
|
// once.
|
||||||
|
std::vector<bool> gpuVariants = {false};
|
||||||
|
if(gpuAvailable) gpuVariants.push_back(true);
|
||||||
|
|
||||||
// Run only the default likelihood variant for every detector;
|
// Run only the default likelihood variant for every detector;
|
||||||
// the TF-IDF variant adds a second run on the default detector
|
// the TF-IDF variant adds a second run on the default detector
|
||||||
// (kFeatureGfttOrb) so the alternative likelihood path stays
|
// (kFeatureGfttOrb) so the alternative likelihood path stays
|
||||||
@@ -2052,6 +2058,7 @@ TEST_F(RtabmapIntegrationFixture, AppearanceOnly_PrecisionRecall)
|
|||||||
std::vector<bool> tfIdfVariants = {false};
|
std::vector<bool> tfIdfVariants = {false};
|
||||||
if(detectorType == defaultDetector) tfIdfVariants.push_back(true);
|
if(detectorType == defaultDetector) tfIdfVariants.push_back(true);
|
||||||
|
|
||||||
|
for(bool useGpu : gpuVariants)
|
||||||
for(bool tfIdfUsed : tfIdfVariants)
|
for(bool tfIdfUsed : tfIdfVariants)
|
||||||
{
|
{
|
||||||
const std::string detectorLabel = typeName
|
const std::string detectorLabel = typeName
|
||||||
@@ -2079,9 +2086,10 @@ TEST_F(RtabmapIntegrationFixture, AppearanceOnly_PrecisionRecall)
|
|||||||
params[Parameters::kKAZEThreshold()] = "0.0001";
|
params[Parameters::kKAZEThreshold()] = "0.0001";
|
||||||
// GFTT-specific: tighten the minimum keypoint separation (default
|
// GFTT-specific: tighten the minimum keypoint separation (default
|
||||||
// 7 px) so more candidates fit per frame.
|
// 7 px) so more candidates fit per frame.
|
||||||
params[Parameters::kGFTTMinDistance()] = "5";
|
params[Parameters::kGFTTMinDistance()] = "3";
|
||||||
params[Parameters::kMemBadSignaturesIgnored()] = "false";
|
params[Parameters::kMemBadSignaturesIgnored()] = "false";
|
||||||
params[Parameters::kMemRehearsalSimilarity()] = "0.20";
|
params[Parameters::kMemRehearsalSimilarity()] = "0.20";
|
||||||
|
params[Parameters::kBRIEFBytes()] = "64";
|
||||||
|
|
||||||
// Backend-specific asset paths + GPU/CUDA toggle. `useGpu` only
|
// Backend-specific asset paths + GPU/CUDA toggle. `useGpu` only
|
||||||
// reaches here when this detector reports a usable GPU path; we
|
// reaches here when this detector reports a usable GPU path; we
|
||||||
|
|||||||
@@ -62,17 +62,11 @@ TEST_F(VWDictionaryTest, AddNewWordsIncremental)
|
|||||||
|
|
||||||
for(VWDictionary::NNStrategy strategy : strategies)
|
for(VWDictionary::NNStrategy strategy : strategies)
|
||||||
{
|
{
|
||||||
// Reset dictionary for each strategy
|
|
||||||
dict->clear();
|
|
||||||
dict->setNNStrategy(strategy);
|
|
||||||
|
|
||||||
EXPECT_TRUE(dict->isIncremental());
|
|
||||||
|
|
||||||
if(strategy == VWDictionary::kNNBruteForceGPU)
|
if(strategy == VWDictionary::kNNBruteForceGPU)
|
||||||
{
|
{
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPU
|
||||||
if(!cv::gpu::getCudaEnabledDeviceCount())
|
if(cv::gpu::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
strategy = VWDictionary::kNNBruteForce;
|
strategy = VWDictionary::kNNBruteForce;
|
||||||
}
|
}
|
||||||
@@ -81,7 +75,7 @@ TEST_F(VWDictionaryTest, AddNewWordsIncremental)
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
||||||
if(!cv::cuda::getCudaEnabledDeviceCount())
|
if(cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
strategy = VWDictionary::kNNBruteForce;
|
strategy = VWDictionary::kNNBruteForce;
|
||||||
}
|
}
|
||||||
@@ -90,6 +84,12 @@ TEST_F(VWDictionaryTest, AddNewWordsIncremental)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset dictionary for each strategy
|
||||||
|
dict->clear();
|
||||||
|
dict->setNNStrategy(strategy);
|
||||||
|
|
||||||
|
EXPECT_TRUE(dict->isIncremental());
|
||||||
EXPECT_EQ(dict->getNNStrategy(), strategy);
|
EXPECT_EQ(dict->getNNStrategy(), strategy);
|
||||||
|
|
||||||
// Add initial words to dictionary (2D descriptors)
|
// Add initial words to dictionary (2D descriptors)
|
||||||
@@ -636,15 +636,11 @@ TEST_F(VWDictionaryTest, SerializeDeserializeIndex)
|
|||||||
|
|
||||||
for(VWDictionary::NNStrategy strategy : strategies)
|
for(VWDictionary::NNStrategy strategy : strategies)
|
||||||
{
|
{
|
||||||
// Reset dictionary for each strategy
|
|
||||||
dict->clear();
|
|
||||||
dict->setNNStrategy(strategy);
|
|
||||||
|
|
||||||
if(strategy == VWDictionary::kNNBruteForceGPU)
|
if(strategy == VWDictionary::kNNBruteForceGPU)
|
||||||
{
|
{
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPU
|
||||||
if(!cv::gpu::getCudaEnabledDeviceCount())
|
if(cv::gpu::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
continue; // Skip if no GPU available
|
continue; // Skip if no GPU available
|
||||||
}
|
}
|
||||||
@@ -653,7 +649,7 @@ TEST_F(VWDictionaryTest, SerializeDeserializeIndex)
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
||||||
if(!cv::cuda::getCudaEnabledDeviceCount())
|
if(cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||||
{
|
{
|
||||||
continue; // Skip if no GPU available
|
continue; // Skip if no GPU available
|
||||||
}
|
}
|
||||||
@@ -663,6 +659,10 @@ TEST_F(VWDictionaryTest, SerializeDeserializeIndex)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset dictionary for each strategy
|
||||||
|
dict->clear();
|
||||||
|
dict->setNNStrategy(strategy);
|
||||||
|
|
||||||
// Add words and build index
|
// Add words and build index
|
||||||
cv::Mat descriptors(5, 32, CV_32F);
|
cv::Mat descriptors(5, 32, CV_32F);
|
||||||
cv::randu(descriptors, cv::Scalar(0), cv::Scalar(1));
|
cv::randu(descriptors, cv::Scalar(0), cv::Scalar(1));
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
|||||||
bool haveCuda = false;
|
bool haveCuda = false;
|
||||||
#if CV_MAJOR_VERSION < 3
|
#if CV_MAJOR_VERSION < 3
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#ifdef HAVE_OPENCV_GPU
|
||||||
haveCuda = cv::gpu::getCudaEnabledDeviceCount() != 0;
|
haveCuda = cv::gpu::getCudaEnabledDeviceCount() > 0;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
||||||
haveCuda = cv::cuda::getCudaEnabledDeviceCount() != 0;
|
haveCuda = cv::cuda::getCudaEnabledDeviceCount() > 0;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if(!haveCuda)
|
if(!haveCuda)
|
||||||
|
|||||||
Reference in New Issue
Block a user