Lazy load StateIdentifier.

This commit is contained in:
twelve17
2015-01-08 15:57:40 +00:00
parent 54cdf280b9
commit 3684402d8b

View File

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