From 7fc6978fc907d52f485a8c8b57b16a9cfdc3c3ad Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 25 Feb 2016 22:14:51 -0500 Subject: [PATCH] Added compile toggle for statedetection library --- src/CMakeLists.txt | 13 +++++++++++-- src/misc_utilities/benchmarks/benchmark.cpp | 1 - src/misc_utilities/sortstate.cpp | 5 +++++ src/openalpr/alpr_impl.cpp | 7 +++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 95d4e18..afe07f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,10 @@ IF ( NOT DEFINED WITH_DAEMON ) SET(WITH_DAEMON ON) ENDIF() +IF ( NOT DEFINED WITH_STATEDETECTION ) + SET(WITH_STATEDETECTION ON) +ENDIF() + if ( NOT DEFINED WITH_GPU_DETECTOR ) SET(WITH_GPU_DETECTOR OFF) ENDIF() @@ -127,7 +131,13 @@ ELSE() SET(OPENALPR_LIB openalpr) ENDIF() -SET(STATE_DETECTION_LIB statedetection) +IF (WITH_STATEDETECTION) + SET(STATE_DETECTION_LIB statedetection) + add_subdirectory(statedetection) +ELSE() + SET(STATE_DETECTION_LIB "") + add_definitions( -DSKIP_STATE_DETECTION=1 ) +ENDIF() if (NOT IOS) TARGET_LINK_LIBRARIES(alpr @@ -170,7 +180,6 @@ add_subdirectory(tests) ENDIF() add_subdirectory(openalpr) -add_subdirectory(statedetection) add_subdirectory(video) if (WITH_BINDING_JAVA) diff --git a/src/misc_utilities/benchmarks/benchmark.cpp b/src/misc_utilities/benchmarks/benchmark.cpp index e33ed5d..0130e30 100644 --- a/src/misc_utilities/benchmarks/benchmark.cpp +++ b/src/misc_utilities/benchmarks/benchmark.cpp @@ -167,7 +167,6 @@ int main( int argc, const char** argv ) alpr.setDetectRegion(true); Detector* plateDetector = createDetector(&config); - StateDetector stateDetector(country, config.config_file_path, config.runtimeBaseDir); OCR ocr(&config); vector endToEndTimes; diff --git a/src/misc_utilities/sortstate.cpp b/src/misc_utilities/sortstate.cpp index 19da685..290677e 100644 --- a/src/misc_utilities/sortstate.cpp +++ b/src/misc_utilities/sortstate.cpp @@ -40,6 +40,8 @@ bool detectPlate( StateDetector* identifier, Mat frame); int main( int argc, const char** argv ) { + #ifndef SKIP_STATE_DETECTION + string inDir; string outDir; Mat frame; @@ -97,6 +99,9 @@ int main( int argc, const char** argv ) } } } + #endif + + return 1; } bool detectPlate( StateDetector* identifier, Mat frame); diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index 69a9c50..62c34b9 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -279,6 +279,8 @@ namespace alpr plateResult.plate_points[pointidx].y = (int) cornerPoints[pointidx].y; } + + #ifndef SKIP_STATE_DETECTION if (detectRegion && country_recognizers.stateDetector->isLoaded()) { std::vector state_candidates = country_recognizers.stateDetector->detect(pipeline_data.color_deskewed.data, @@ -292,6 +294,7 @@ namespace alpr plateResult.regionConfidence = (int) state_candidates[0].confidence; } } + #endif if (plateResult.region.length() > 0 && country_recognizers.ocr->postProcessor.regionIsValid(plateResult.region) == false) { @@ -705,7 +708,11 @@ namespace alpr recognizer.plateDetector = createDetector(config); recognizer.ocr = new OCR(config); + #ifndef SKIP_STATE_DETECTION recognizer.stateDetector = new StateDetector(this->config->country, this->config->config_file_path, this->config->runtimeBaseDir); + #else + recognizer.stateDetector = NULL; + #endif recognizers[config->country] = recognizer; }