diff --git a/distros/debian/rules b/distros/debian/rules index 50d77ea..534655b 100755 --- a/distros/debian/rules +++ b/distros/debian/rules @@ -35,6 +35,7 @@ override_dh_auto_configure: dh_auto_configure -- \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_SYSCONFDIR=/etc \ + -DCOMPILE_GPU=1 \ -DCMAKE_VERBOSE_MAKEFILE=OFF \ -DCMAKE_COLOR_MAKEFILE=ON diff --git a/src/openalpr/CMakeLists.txt b/src/openalpr/CMakeLists.txt index d9f3f8c..61cbbc6 100644 --- a/src/openalpr/CMakeLists.txt +++ b/src/openalpr/CMakeLists.txt @@ -57,5 +57,8 @@ install (FILES alpr.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include) install (TARGETS openalpr-static DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) install (TARGETS openalpr DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) +# Compile GPU detector +#add_definitions(-DCOMPILE_GPU=1) + # Add definition for default config file add_definitions(-DDEFAULT_CONFIG_FILE="${CMAKE_INSTALL_SYSCONFDIR}/openalpr/openalpr.conf") diff --git a/src/openalpr/constants.h b/src/openalpr/constants.h index cf1e3bb..6c07c40 100644 --- a/src/openalpr/constants.h +++ b/src/openalpr/constants.h @@ -31,6 +31,10 @@ #define DEFAULT_CONFIG_FILE "/etc/openalpr/openalpr.conf" #endif +#ifndef COMPILE_GPU + #define COMPILE_GPU 0 +#endif + #define ENV_VARIABLE_CONFIG_FILE "OPENALPR_CONFIG_FILE" #endif // OPENALPR_CONSTANTS_H \ No newline at end of file diff --git a/src/openalpr/detection/detectorcuda.cpp b/src/openalpr/detection/detectorcuda.cpp index 64c9a7b..8c3e617 100644 --- a/src/openalpr/detection/detectorcuda.cpp +++ b/src/openalpr/detection/detectorcuda.cpp @@ -20,6 +20,7 @@ #include "detectorcuda.h" +#if COMPILE_GPU using namespace cv; using namespace std; @@ -137,4 +138,6 @@ namespace alpr } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/openalpr/detection/detectorcuda.h b/src/openalpr/detection/detectorcuda.h index 927e046..4890f98 100644 --- a/src/openalpr/detection/detectorcuda.h +++ b/src/openalpr/detection/detectorcuda.h @@ -20,6 +20,8 @@ #ifndef OPENALPR_DETECTORCUDA_H #define OPENALPR_DETECTORCUDA_H +#if COMPILE_GPU + #include #include #include @@ -50,6 +52,8 @@ namespace alpr }; } - + +#endif + #endif /* OPENALPR_DETECTORCUDA_H */ diff --git a/src/openalpr/detection/detectorfactory.cpp b/src/openalpr/detection/detectorfactory.cpp index 07d7e94..cab0427 100644 --- a/src/openalpr/detection/detectorfactory.cpp +++ b/src/openalpr/detection/detectorfactory.cpp @@ -11,7 +11,13 @@ namespace alpr } else if (config->gpu_mode == 1) { + #if COMPILE_GPU return new DetectorCUDA(config); + #else + std::cerr << "Error: GPU detector requested, but GPU extensions are not compiled. " << + "Add COMPILE_GPU=1 to the compiler definitions to enable GPU compilation." << + std::endl; + #endif } }