mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-14 03:03:50 +08:00
Added option to reuse detectors across configs
This commit is contained in:
@@ -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");
|
||||
|
@@ -102,6 +102,8 @@ namespace alpr
|
||||
float segmentationMinCharHeightPercent;
|
||||
float segmentationMaxCharWidthvsAverage;
|
||||
|
||||
std::string detectorFile;
|
||||
|
||||
std::string ocrLanguage;
|
||||
int ocrMinFontSize;
|
||||
|
||||
|
@@ -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) {
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user