diff --git a/image_analysis/MXAnalysisWithoutFPGA.cpp b/image_analysis/MXAnalysisWithoutFPGA.cpp index 4e320d96..cd09f370 100644 --- a/image_analysis/MXAnalysisWithoutFPGA.cpp +++ b/image_analysis/MXAnalysisWithoutFPGA.cpp @@ -7,6 +7,7 @@ #include "../compression/JFJochDecompress.h" #include "SpotAnalyze.h" +#include "spot_finding/ImageSpotFinderFactory.h" MXAnalysisWithoutFPGA::MXAnalysisWithoutFPGA(const DiffractionExperiment &in_experiment, const AzimuthalIntegration &in_integration, @@ -33,7 +34,7 @@ MXAnalysisWithoutFPGA::MXAnalysisWithoutFPGA(const DiffractionExperiment &in_exp for (int i = 0; i < npixels; i++) mask_1bit[i] = (in_mask.GetMask().at(i) != 0); - spotFinder = std::make_unique(experiment.GetXPixelsNum(), experiment.GetYPixelsNum()); + spotFinder = CreateImageSpotFinder(experiment.GetXPixelsNum(), experiment.GetYPixelsNum()); updated_image = spotFinder->GetHostBuffer(); } diff --git a/image_analysis/MXAnalysisWithoutFPGA.h b/image_analysis/MXAnalysisWithoutFPGA.h index 5e0a4132..4de1031c 100644 --- a/image_analysis/MXAnalysisWithoutFPGA.h +++ b/image_analysis/MXAnalysisWithoutFPGA.h @@ -11,7 +11,7 @@ #include "../common/AzimuthalIntegration.h" #include "../common/PixelMask.h" #include "../common/AzimuthalIntegrationProfile.h" -#include "spot_finding/ImageSpotFinderCPU.h" +#include "spot_finding/ImageSpotFinder.h" #include "indexing/IndexerThreadPool.h" class MXAnalysisWithoutFPGA { diff --git a/image_analysis/spot_finding/CMakeLists.txt b/image_analysis/spot_finding/CMakeLists.txt index 44bd6ca1..abec1704 100644 --- a/image_analysis/spot_finding/CMakeLists.txt +++ b/image_analysis/spot_finding/CMakeLists.txt @@ -9,6 +9,8 @@ ADD_LIBRARY(JFJochSpotFinding STATIC DetModuleSpotFinder_cpu.h ImageSpotFinder.cpp ImageSpotFinder.h + ImageSpotFinderFactory.cpp + ImageSpotFinderFactory.h ) TARGET_LINK_LIBRARIES(JFJochSpotFinding JFJochCommon) diff --git a/image_analysis/spot_finding/ImageSpotFinderFactory.cpp b/image_analysis/spot_finding/ImageSpotFinderFactory.cpp new file mode 100644 index 00000000..da7dce0e --- /dev/null +++ b/image_analysis/spot_finding/ImageSpotFinderFactory.cpp @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute +// SPDX-License-Identifier: GPL-3.0-only + +#include "ImageSpotFinderFactory.h" +#include "ImageSpotFinderCPU.h" + +#ifdef JFJOCH_USE_CUDA +#include "../../common/CUDAWrapper.h" +#include "ImageSpotFinderGPU.h" +#endif + +std::unique_ptr CreateImageSpotFinder(size_t width, size_t height) { +#ifdef JFJOCH_USE_CUDA + if (get_gpu_count() > 0) + return std::make_unique(width, height); +#endif + return std::make_unique(width, height); +} diff --git a/image_analysis/spot_finding/ImageSpotFinderFactory.h b/image_analysis/spot_finding/ImageSpotFinderFactory.h new file mode 100644 index 00000000..ef74eb5e --- /dev/null +++ b/image_analysis/spot_finding/ImageSpotFinderFactory.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute +// SPDX-License-Identifier: GPL-3.0-only + +#ifndef JFJOCH_IMAGESPOTFINDERFACTORY_H +#define JFJOCH_IMAGESPOTFINDERFACTORY_H + +#include "ImageSpotFinder.h" + +std::unique_ptr CreateImageSpotFinder(size_t width, size_t height); + +#endif //JFJOCH_IMAGESPOTFINDERFACTORY_H \ No newline at end of file