Skip to content

Commit 551b6cd

Browse files
predatSylvain Mazierefabiencastan
authored
imageProcessing: check opencv availability
* imageProcessing: guard OpenCV-dependent filters behind ALICEVISION_HAVE_OPENCV * Apply suggestion from @fabiencastan Co-authored-by: Fabien Castan <fabcastan@gmail.com> * fix(imageProcessing): fix guard placement for bilateralFilter and nlmFilter OpenCV checks The `#if ALICEVISION_HAVE_OPENCV` guards were incorrectly placed *before* the `if (pParams.*.enabled)` runtime checks, causing the entire block (including the enabled-check) to be silently skipped at compile time when OpenCV is absent. - Move the preprocessor guard *inside* the runtime `if` block for bilateralFilter and nlmFilter, so the enabled-check is always compiled and evaluated - Add an `#else` branch for nlmFilter that logs an explicit error when OpenCV is unavailable and the filter is requested, instead of silently bypassing it --------- Co-authored-by: Sylvain Maziere <sylvain.maziere@technicolor.com> Co-authored-by: Fabien Castan <fabcastan@gmail.com>
1 parent 20b6f52 commit 551b6cd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/software/utils/main_imageProcessing.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,19 @@ void setupSteps(std::list<std::unique_ptr<ImageProcess>> & steps, const Processi
524524
}
525525
if (pParams.bilateralFilter.enabled)
526526
{
527+
#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_OPENCV)
527528
steps.push_back(std::make_unique<BilateralFilterProcess>(pParams.bilateralFilter.distance, pParams.bilateralFilter.sigmaColor, pParams.bilateralFilter.sigmaSpace));
529+
#else
530+
ALICEVISION_LOG_ERROR("OpenCV support is not enabled in this AliceVision build. Bilateral filter processing is unavailable and will be bypassed.");
531+
#endif
528532
}
529533
if (pParams.claheFilter.enabled)
530534
{
535+
#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_OPENCV)
531536
steps.push_back(std::make_unique<ClaheFilterProcess>(pParams.claheFilter.tileGridSize, pParams.claheFilter.clipLimit));
537+
#else
538+
ALICEVISION_LOG_ERROR("OpenCV support is not enabled in this AliceVision build. Clahe filter processing is unavailable and will be bypassed.");
539+
#endif
532540
}
533541
if (pParams.fillHoles)
534542
{
@@ -539,9 +547,13 @@ void setupSteps(std::list<std::unique_ptr<ImageProcess>> & steps, const Processi
539547
steps.push_back(std::make_unique<NoiseProcess>(ENoiseMethod_enumToString(pParams.noise.method), pParams.noise.A, pParams.noise.B, pParams.noise.mono));
540548
}
541549
if (pParams.nlmFilter.enabled)
550+
#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_OPENCV)
542551
{
543552
steps.push_back(std::make_unique<NlmFilterProcess>(pParams.nlmFilter.filterStrength, pParams.nlmFilter.filterStrengthColor, pParams.nlmFilter.templateWindowSize, pParams.nlmFilter.searchWindowSize));
544553
}
554+
#else
555+
ALICEVISION_LOG_ERROR("OpenCV support is not enabled in this AliceVision build. Nlm filter processing is unavailable and will be bypassed.");
556+
#endif
545557
if (pParams.applyDcpMetadata || pParams.enableColorTempProcessing)
546558
{
547559
steps.push_back(std::make_unique<ColorTemperatureProcess>(pParams.applyDcpMetadata, pParams.useDCPColorMatrixOnly, pParams.enableColorTempProcessing, pParams.correlatedColorTemperature));

0 commit comments

Comments
 (0)