mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-05 01:27:46 +08:00
fixed cuda capable checks
This commit is contained in:
@@ -30,7 +30,6 @@ add_test(NAME test_util3d_registration COMMAND test_util3d_registration)
|
||||
add_executable(test_util3d_features test_util3d_features.cpp)
|
||||
target_link_libraries(test_util3d_features gtest_main rtabmap_core)
|
||||
add_test(NAME test_util3d_features COMMAND test_util3d_features)
|
||||
set_tests_properties(test_util3d_features PROPERTIES TIMEOUT 600)
|
||||
|
||||
#util3d_correspondences.h
|
||||
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)
|
||||
target_link_libraries(test_stereo_dense gtest_main rtabmap_core)
|
||||
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)
|
||||
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)
|
||||
target_link_libraries(test_localgrid gtest_main rtabmap_core)
|
||||
add_test(NAME test_localgrid COMMAND test_localgrid)
|
||||
set_tests_properties(test_localgrid PROPERTIES TIMEOUT 600)
|
||||
|
||||
#Features2d.h
|
||||
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
|
||||
// with the same asset paths the actual run uses; otherwise SuperPoint
|
||||
// variants log a (harmless) load failure.
|
||||
bool useGpu = false;
|
||||
bool gpuAvailable = false;
|
||||
{
|
||||
ParametersMap probeParams;
|
||||
if(detectorType == Feature2D::kFeatureSuperPointTorch)
|
||||
@@ -2042,9 +2042,15 @@ TEST_F(RtabmapIntegrationFixture, AppearanceOnly_PrecisionRecall)
|
||||
probeParams[Parameters::kSuperPointRpautratModelPath()] = superpointRpautratModel;
|
||||
}
|
||||
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;
|
||||
// the TF-IDF variant adds a second run on the default detector
|
||||
// (kFeatureGfttOrb) so the alternative likelihood path stays
|
||||
@@ -2052,6 +2058,7 @@ TEST_F(RtabmapIntegrationFixture, AppearanceOnly_PrecisionRecall)
|
||||
std::vector<bool> tfIdfVariants = {false};
|
||||
if(detectorType == defaultDetector) tfIdfVariants.push_back(true);
|
||||
|
||||
for(bool useGpu : gpuVariants)
|
||||
for(bool tfIdfUsed : tfIdfVariants)
|
||||
{
|
||||
const std::string detectorLabel = typeName
|
||||
@@ -2079,9 +2086,10 @@ TEST_F(RtabmapIntegrationFixture, AppearanceOnly_PrecisionRecall)
|
||||
params[Parameters::kKAZEThreshold()] = "0.0001";
|
||||
// GFTT-specific: tighten the minimum keypoint separation (default
|
||||
// 7 px) so more candidates fit per frame.
|
||||
params[Parameters::kGFTTMinDistance()] = "5";
|
||||
params[Parameters::kGFTTMinDistance()] = "3";
|
||||
params[Parameters::kMemBadSignaturesIgnored()] = "false";
|
||||
params[Parameters::kMemRehearsalSimilarity()] = "0.20";
|
||||
params[Parameters::kBRIEFBytes()] = "64";
|
||||
|
||||
// Backend-specific asset paths + GPU/CUDA toggle. `useGpu` only
|
||||
// reaches here when this detector reports a usable GPU path; we
|
||||
|
||||
@@ -62,17 +62,11 @@ TEST_F(VWDictionaryTest, AddNewWordsIncremental)
|
||||
|
||||
for(VWDictionary::NNStrategy strategy : strategies)
|
||||
{
|
||||
// Reset dictionary for each strategy
|
||||
dict->clear();
|
||||
dict->setNNStrategy(strategy);
|
||||
|
||||
EXPECT_TRUE(dict->isIncremental());
|
||||
|
||||
if(strategy == VWDictionary::kNNBruteForceGPU)
|
||||
{
|
||||
#if CV_MAJOR_VERSION < 3
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
if(!cv::gpu::getCudaEnabledDeviceCount())
|
||||
if(cv::gpu::getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
strategy = VWDictionary::kNNBruteForce;
|
||||
}
|
||||
@@ -81,7 +75,7 @@ TEST_F(VWDictionaryTest, AddNewWordsIncremental)
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
||||
if(!cv::cuda::getCudaEnabledDeviceCount())
|
||||
if(cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
strategy = VWDictionary::kNNBruteForce;
|
||||
}
|
||||
@@ -90,6 +84,12 @@ TEST_F(VWDictionaryTest, AddNewWordsIncremental)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Reset dictionary for each strategy
|
||||
dict->clear();
|
||||
dict->setNNStrategy(strategy);
|
||||
|
||||
EXPECT_TRUE(dict->isIncremental());
|
||||
EXPECT_EQ(dict->getNNStrategy(), strategy);
|
||||
|
||||
// Add initial words to dictionary (2D descriptors)
|
||||
@@ -636,15 +636,11 @@ TEST_F(VWDictionaryTest, SerializeDeserializeIndex)
|
||||
|
||||
for(VWDictionary::NNStrategy strategy : strategies)
|
||||
{
|
||||
// Reset dictionary for each strategy
|
||||
dict->clear();
|
||||
dict->setNNStrategy(strategy);
|
||||
|
||||
if(strategy == VWDictionary::kNNBruteForceGPU)
|
||||
{
|
||||
#if CV_MAJOR_VERSION < 3
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
if(!cv::gpu::getCudaEnabledDeviceCount())
|
||||
if(cv::gpu::getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
continue; // Skip if no GPU available
|
||||
}
|
||||
@@ -653,7 +649,7 @@ TEST_F(VWDictionaryTest, SerializeDeserializeIndex)
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_OPENCV_CUDAFEATURES2D
|
||||
if(!cv::cuda::getCudaEnabledDeviceCount())
|
||||
if(cv::cuda::getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
continue; // Skip if no GPU available
|
||||
}
|
||||
@@ -663,6 +659,10 @@ TEST_F(VWDictionaryTest, SerializeDeserializeIndex)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Reset dictionary for each strategy
|
||||
dict->clear();
|
||||
dict->setNNStrategy(strategy);
|
||||
|
||||
// Add words and build index
|
||||
cv::Mat descriptors(5, 32, CV_32F);
|
||||
cv::randu(descriptors, cv::Scalar(0), cv::Scalar(1));
|
||||
|
||||
Reference in New Issue
Block a user