From fd27380be75dd1eea286547325ad21da4ce8e120 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Tue, 12 Nov 2024 15:00:19 -0800 Subject: [PATCH] CudaSift: switch to SIFT CPU if no cuda devices were found (instead of asserting). --- corelib/src/Features2d.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/corelib/src/Features2d.cpp b/corelib/src/Features2d.cpp index f350462991..73e54471f4 100644 --- a/corelib/src/Features2d.cpp +++ b/corelib/src/Features2d.cpp @@ -1271,10 +1271,17 @@ void SIFT::parseParameters(const ParametersMap & parameters) if(gpu_) { #ifdef RTABMAP_CUDASIFT - UDEBUG("Init SiftData"); - if(cudaSiftData_ == 0) { - cudaSiftData_ = new SiftData(); - InitSiftData(*cudaSiftData_, 8192, true, true); + // Check if there is a cuda device + if(InitCuda(0, ULogger::level() == ULogger::kDebug)) { + UDEBUG("Init SiftData"); + if(cudaSiftData_ == 0) { + cudaSiftData_ = new SiftData(); + InitSiftData(*cudaSiftData_, 8192, true, true); + } + } + else{ + UWARN("No cuda device(s) detected, CudaSift is not available! Using SIFT CPU version instead."); + gpu_ = false; } #else UWARN("RTAB-Map is not built with CudaSift so %s cannot be used!", Parameters::kSIFTGpu().c_str());