diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e898647..1a777aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,6 +134,7 @@ add_subdirectory(tests) ENDIF() add_subdirectory(openalpr) +add_subdirectory(statedetection) add_subdirectory(video) if (WITH_BINDING_JAVA) diff --git a/src/misc_utilities/CMakeLists.txt b/src/misc_utilities/CMakeLists.txt index 969cb9d..8c904cd 100644 --- a/src/misc_utilities/CMakeLists.txt +++ b/src/misc_utilities/CMakeLists.txt @@ -23,6 +23,7 @@ ADD_EXECUTABLE(openalpr-utils-benchmark ) TARGET_LINK_LIBRARIES(openalpr-utils-benchmark ${OPENALPR_LIB} + statedetection support pthread ${OpenCV_LIBS} @@ -72,4 +73,3 @@ ENDIF() install (TARGETS openalpr-utils-prepcharsfortraining DESTINATION bin) install (TARGETS openalpr-utils-tagplates DESTINATION bin) install (TARGETS openalpr-utils-calibrate DESTINATION bin) - diff --git a/src/misc_utilities/benchmarks/benchmark.cpp b/src/misc_utilities/benchmarks/benchmark.cpp index ecde796..fa71ce2 100644 --- a/src/misc_utilities/benchmarks/benchmark.cpp +++ b/src/misc_utilities/benchmarks/benchmark.cpp @@ -167,7 +167,7 @@ int main( int argc, const char** argv ) alpr.setDetectRegion(true); Detector* plateDetector = createDetector(&config); - StateIdentifier stateIdentifier(&config); + StateDetector stateDetector(country, config.runtimeBaseDir); OCR ocr(&config); vector endToEndTimes; @@ -210,8 +210,8 @@ int main( int argc, const char** argv ) PipelineData pipeline_data(frame, regions[z].rect, &config); getTimeMonotonic(&startTime); - - stateIdentifier.recognize(&pipeline_data); + + //stateDetector.detect(&pipeline_data); getTimeMonotonic(&endTime); double stateidTime = diffclock(startTime, endTime); cout << "\tRegion " << z << ": State ID time: " << stateidTime << "ms." << endl; diff --git a/src/misc_utilities/classifychars.cpp b/src/misc_utilities/classifychars.cpp index fa0b58f..3d7e61c 100644 --- a/src/misc_utilities/classifychars.cpp +++ b/src/misc_utilities/classifychars.cpp @@ -26,7 +26,6 @@ #include "postprocess/regexrule.h" #include "licenseplatecandidate.h" -#include "stateidentifier.h" #include "utility.h" #include "support/filesystem.h" #include "ocr.h" diff --git a/src/misc_utilities/sortstate.cpp b/src/misc_utilities/sortstate.cpp index 7db2a33..d963176 100644 --- a/src/misc_utilities/sortstate.cpp +++ b/src/misc_utilities/sortstate.cpp @@ -25,7 +25,7 @@ #include #include "licenseplatecandidate.h" -#include "stateidentifier.h" +#include "../statedetection/state_detector.h" #include "utility.h" #include "support/filesystem.h" @@ -36,7 +36,7 @@ using namespace alpr; // Given a directory full of pre-cropped images, identify the state that each image belongs to. // This is used to sort our own positive image database as a first step before grabbing characters to use to train the OCR. -bool detectPlate( StateIdentifier* identifier, Mat frame); +bool detectPlate( StateDetector* identifier, Mat frame); int main( int argc, const char** argv ) { @@ -59,7 +59,7 @@ int main( int argc, const char** argv ) } Config config("us"); - StateIdentifier identifier(&config); + StateDetector identifier(config.country, config.runtimeBaseDir); if (DirectoryExists(outDir.c_str()) == false) { @@ -79,22 +79,17 @@ int main( int argc, const char** argv ) cout << fullpath << endl; frame = imread( fullpath.c_str() ); - PipelineData pipeline_data(frame, Rect(0, 0, frame.cols, frame.rows), &config); - identifier.recognize(&pipeline_data); - if (pipeline_data.region_confidence <= 20) + vector candidates = identifier.detect(frame.data, frame.elemSize(), frame.cols, frame.rows); + + if (candidates.size() > 0) { - pipeline_data.region_code = "zz"; - pipeline_data.region_confidence = 100; - } - else - { - cout << pipeline_data.region_confidence << " : " << pipeline_data.region_code; + cout << candidates[0].confidence << " : " << candidates[0].state_code; ostringstream convert; // stream used for the conversion convert << i; // insert the textual representation of 'Number' in the characters in the stream - string copyCommand = "cp \"" + fullpath + "\" " + outDir + pipeline_data.region_code + convert.str() + ".png"; + string copyCommand = "cp \"" + fullpath + "\" " + outDir + candidates[0].state_code + convert.str() + ".png"; system( copyCommand.c_str() ); waitKey(50); //while ((char) waitKey(50) != 'c') { } @@ -104,4 +99,4 @@ int main( int argc, const char** argv ) } } -bool detectPlate( StateIdentifier* identifier, Mat frame); +bool detectPlate( StateDetector* identifier, Mat frame); diff --git a/src/openalpr/CMakeLists.txt b/src/openalpr/CMakeLists.txt index 6ec14b9..e8556e6 100644 --- a/src/openalpr/CMakeLists.txt +++ b/src/openalpr/CMakeLists.txt @@ -12,8 +12,6 @@ set(lpr_source_files detection/detectormorph.cpp licenseplatecandidate.cpp utility.cpp - stateidentifier.cpp - featurematcher.cpp ocr.cpp postprocess/postprocess.cpp postprocess/regexrule.cpp @@ -51,6 +49,7 @@ set_target_properties(openalpr PROPERTIES SOVERSION ${OPENALPR_MAJOR_VERSION}) TARGET_LINK_LIBRARIES(openalpr support + statedetection ${OpenCV_LIBS} ${Tesseract_LIBRARIES} )