mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 15:47:01 +08:00
Updated code to use state ID library
This commit is contained in:
@@ -36,7 +36,7 @@ namespace alpr
|
|||||||
config = new Config(country, configFile, runtimeDir);
|
config = new Config(country, configFile, runtimeDir);
|
||||||
|
|
||||||
plateDetector = ALPR_NULL_PTR;
|
plateDetector = ALPR_NULL_PTR;
|
||||||
stateIdentifier = ALPR_NULL_PTR;
|
stateDetector = ALPR_NULL_PTR;
|
||||||
ocr = ALPR_NULL_PTR;
|
ocr = ALPR_NULL_PTR;
|
||||||
prewarp = ALPR_NULL_PTR;
|
prewarp = ALPR_NULL_PTR;
|
||||||
|
|
||||||
@@ -69,8 +69,8 @@ namespace alpr
|
|||||||
if (plateDetector != ALPR_NULL_PTR)
|
if (plateDetector != ALPR_NULL_PTR)
|
||||||
delete plateDetector;
|
delete plateDetector;
|
||||||
|
|
||||||
if (stateIdentifier != ALPR_NULL_PTR)
|
if (stateDetector != ALPR_NULL_PTR)
|
||||||
delete stateIdentifier;
|
delete stateDetector;
|
||||||
|
|
||||||
if (ocr != ALPR_NULL_PTR)
|
if (ocr != ALPR_NULL_PTR)
|
||||||
delete ocr;
|
delete ocr;
|
||||||
@@ -152,6 +152,7 @@ namespace alpr
|
|||||||
plateQueue.pop();
|
plateQueue.pop();
|
||||||
|
|
||||||
PipelineData pipeline_data(img, grayImg, plateRegion.rect, config);
|
PipelineData pipeline_data(img, grayImg, plateRegion.rect, config);
|
||||||
|
pipeline_data.prewarp = prewarp;
|
||||||
|
|
||||||
timespec platestarttime;
|
timespec platestarttime;
|
||||||
getTimeMonotonic(&platestarttime);
|
getTimeMonotonic(&platestarttime);
|
||||||
@@ -180,11 +181,15 @@ namespace alpr
|
|||||||
|
|
||||||
if (detectRegion)
|
if (detectRegion)
|
||||||
{
|
{
|
||||||
stateIdentifier->recognize(&pipeline_data);
|
std::vector<StateCandidate> state_candidates = stateDetector->detect(pipeline_data.color_deskewed.data,
|
||||||
if (pipeline_data.region_confidence > 0)
|
pipeline_data.color_deskewed.elemSize(),
|
||||||
|
pipeline_data.color_deskewed.cols,
|
||||||
|
pipeline_data.color_deskewed.rows);
|
||||||
|
|
||||||
|
if (state_candidates.size() > 0)
|
||||||
{
|
{
|
||||||
plateResult.region = pipeline_data.region_code;
|
plateResult.region = state_candidates[0].state_code;
|
||||||
plateResult.regionConfidence = (int) pipeline_data.region_confidence;
|
plateResult.regionConfidence = (int) state_candidates[0].confidence;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,12 +585,12 @@ namespace alpr
|
|||||||
{
|
{
|
||||||
|
|
||||||
this->detectRegion = detectRegion;
|
this->detectRegion = detectRegion;
|
||||||
if (detectRegion && this->stateIdentifier == NULL)
|
if (detectRegion && this->stateDetector == NULL)
|
||||||
{
|
{
|
||||||
timespec startTime;
|
timespec startTime;
|
||||||
getTimeMonotonic(&startTime);
|
getTimeMonotonic(&startTime);
|
||||||
|
|
||||||
this->stateIdentifier = new StateIdentifier(this->config);
|
this->stateDetector = new StateDetector(this->config->country, this->config->runtimeBaseDir);
|
||||||
|
|
||||||
timespec endTime;
|
timespec endTime;
|
||||||
getTimeMonotonic(&endTime);
|
getTimeMonotonic(&endTime);
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
#include "prewarp.h"
|
#include "prewarp.h"
|
||||||
|
|
||||||
#include "licenseplatecandidate.h"
|
#include "licenseplatecandidate.h"
|
||||||
#include "stateidentifier.h"
|
#include "../statedetection/state_detector.h"
|
||||||
#include "segmentation/charactersegmenter.h"
|
#include "segmentation/charactersegmenter.h"
|
||||||
#include "ocr.h"
|
#include "ocr.h"
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ namespace alpr
|
|||||||
AlprFullDetails recognizeFullDetails(cv::Mat img, std::vector<cv::Rect> regionsOfInterest);
|
AlprFullDetails recognizeFullDetails(cv::Mat img, std::vector<cv::Rect> regionsOfInterest);
|
||||||
|
|
||||||
AlprResults recognize( std::vector<char> imageBytes );
|
AlprResults recognize( std::vector<char> imageBytes );
|
||||||
AlprResults recognize( std::vector<char> imageBytes, std::vector<AlprRegionOfInterest> regionsOfInterest );
|
AlprResults recognize( std::vector<char> imageBytes, std::vector<AlprRegionOfInterest> regionsOfInterest );
|
||||||
AlprResults recognize( unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector<AlprRegionOfInterest> regionsOfInterest );
|
AlprResults recognize( unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector<AlprRegionOfInterest> regionsOfInterest );
|
||||||
AlprResults recognize( cv::Mat img );
|
AlprResults recognize( cv::Mat img );
|
||||||
AlprResults recognize( cv::Mat img, std::vector<cv::Rect> regionsOfInterest );
|
AlprResults recognize( cv::Mat img, std::vector<cv::Rect> regionsOfInterest );
|
||||||
@@ -100,7 +100,7 @@ namespace alpr
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
Detector* plateDetector;
|
Detector* plateDetector;
|
||||||
StateIdentifier* stateIdentifier;
|
StateDetector* stateDetector;
|
||||||
OCR* ocr;
|
OCR* ocr;
|
||||||
PreWarp* prewarp;
|
PreWarp* prewarp;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user