Merge pull request #77 from twelve17/state_identifier

Lazy load StateIdentifier
This commit is contained in:
Matthew Hill
2015-01-08 23:17:20 -05:00

View File

@@ -40,13 +40,12 @@ namespace alpr
} }
plateDetector = createDetector(config); plateDetector = createDetector(config);
stateIdentifier = new StateIdentifier(config);
ocr = new OCR(config); ocr = new OCR(config);
setNumThreads(0); setNumThreads(0);
this->detectRegion = DEFAULT_DETECT_REGION; setDetectRegion(DEFAULT_DETECT_REGION);
this->topN = DEFAULT_TOPN; this->topN = DEFAULT_TOPN;
this->defaultRegion = ""; setDefaultRegion("");
} }
AlprImpl::~AlprImpl() AlprImpl::~AlprImpl()
@@ -498,6 +497,11 @@ namespace alpr
void AlprImpl::setDetectRegion(bool detectRegion) void AlprImpl::setDetectRegion(bool detectRegion)
{ {
this->detectRegion = detectRegion; this->detectRegion = detectRegion;
if (detectRegion && this->stateIdentifier == NULL)
{
this->stateIdentifier = new StateIdentifier(this->config);
}
} }
void AlprImpl::setTopN(int topn) void AlprImpl::setTopN(int topn)
{ {
@@ -506,6 +510,10 @@ namespace alpr
void AlprImpl::setDefaultRegion(string region) void AlprImpl::setDefaultRegion(string region)
{ {
this->defaultRegion = region; this->defaultRegion = region;
if (!region.empty() && this->stateIdentifier == NULL)
{
this->stateIdentifier = new StateIdentifier(this->config);
}
} }
std::string AlprImpl::getVersion() std::string AlprImpl::getVersion()