Added option to reuse detectors across configs

This commit is contained in:
Matt Hill
2015-10-09 17:46:48 -04:00
parent 6362c66920
commit d4a625b635
11 changed files with 24 additions and 1644 deletions

View File

@@ -278,6 +278,8 @@ namespace alpr
plateLinesSensitivityVertical = getFloat(ini, "", "plateline_sensitivity_vertical", 0);
plateLinesSensitivityHorizontal = getFloat(ini, "", "plateline_sensitivity_horizontal", 0);
detectorFile = getString(ini, "", "detector_file", "");
ocrLanguage = getString(ini, "", "ocr_language", "none");
postProcessRegexLetters = getString(ini, "", "postprocess_regex_letters", "\\pL");

View File

@@ -102,6 +102,8 @@ namespace alpr
float segmentationMinCharHeightPercent;
float segmentationMaxCharWidthvsAverage;
std::string detectorFile;
std::string ocrLanguage;
int ocrMinFontSize;

View File

@@ -54,6 +54,14 @@ namespace alpr
std::vector<PlateRegion> rois;
return rois;
}
std::string Detector::get_detector_file() {
if (config->detectorFile.length() == 0)
return config->getCascadeRuntimeDir() + config->country + ".xml";
return config->getCascadeRuntimeDir() + config->detectorFile;
}
float Detector::computeScaleFactor(int width, int height) {

View File

@@ -54,6 +54,8 @@ namespace alpr
bool loaded;
std::string get_detector_file();
float computeScaleFactor(int width, int height);
std::vector<PlateRegion> aggregateRegions(std::vector<cv::Rect> regions);

View File

@@ -30,14 +30,14 @@ namespace alpr
if( this->plate_cascade.load( config->getCascadeRuntimeDir() + config->country + ".xml" ) )
if( this->plate_cascade.load( get_detector_file() ) )
{
this->loaded = true;
}
else
{
this->loaded = false;
printf("--(!)Error loading CPU classifier\n");
printf("--(!)Error loading CPU classifier %s\n", get_detector_file().c_str());
}
}

View File

@@ -33,7 +33,7 @@ namespace alpr
if( this->cuda_cascade.load( config->getCascadeRuntimeDir() + config->country + ".xml" ) )
if( this->cuda_cascade.load( get_detector_file() ) )
{
this->loaded = true;
printf("--(!)Loaded CUDA classifier\n");
@@ -41,7 +41,7 @@ namespace alpr
else
{
this->loaded = false;
printf("--(!)Error loading CUDA classifier\n");
printf("--(!)Error loading CPU classifier %s\n", get_detector_file().c_str());
}
}

View File

@@ -83,14 +83,14 @@ namespace alpr
this->loaded = false;
cerr << "OpenCL not detected" << endl;
}
else if( this->plate_cascade.load( config->getCascadeRuntimeDir() + config->country + ".xml" ) )
else if( this->plate_cascade.load( get_detector_file() ) )
{
this->loaded = true;
}
else
{
this->loaded = false;
cout << "--(!)Error loading cascade " << config->country << ".xml\n" << endl;
cerr << "--(!)Error loading cascade " << get_detector_file() << "\n" << endl;
}
}