mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-15 02:15:45 +08:00
Updated state_identifier to use pipeline_data
This commit is contained in:
@@ -43,26 +43,18 @@ StateIdentifier::~StateIdentifier()
|
|||||||
delete featureMatcher;
|
delete featureMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StateIdentifier::recognize(Mat img, Rect frame, char* stateCode)
|
|
||||||
{
|
|
||||||
Mat croppedImage = Mat(img, frame);
|
|
||||||
|
|
||||||
return this->recognize(croppedImage, stateCode);
|
// Attempts to recognize the plate. Returns a confidence level. Updates the region code and confidence
|
||||||
}
|
// If region is found, returns true.
|
||||||
// Attempts to recognize the plate. Returns a confidence level. Updates teh "stateCode" variable
|
bool StateIdentifier::recognize(PipelineData* pipeline_data)
|
||||||
// with the value of the country/state
|
|
||||||
int StateIdentifier::recognize(Mat img, char* stateCode)
|
|
||||||
{
|
{
|
||||||
timespec startTime;
|
timespec startTime;
|
||||||
getTime(&startTime);
|
getTime(&startTime);
|
||||||
|
|
||||||
cvtColor(img, img, CV_BGR2GRAY);
|
Mat plateImg = Mat(pipeline_data->grayImg, pipeline_data->regionOfInterest);
|
||||||
|
|
||||||
resize(img, img, getSizeMaintainingAspect(img, config->stateIdImageWidthPx, config->stateIdimageHeightPx));
|
resize(plateImg, plateImg, getSizeMaintainingAspect(plateImg, config->stateIdImageWidthPx, config->stateIdimageHeightPx));
|
||||||
|
|
||||||
Mat plateImg(img.size(), img.type());
|
|
||||||
//plateImg = equalizeBrightness(img);
|
|
||||||
img.copyTo(plateImg);
|
|
||||||
|
|
||||||
Mat debugImg(plateImg.size(), plateImg.type());
|
Mat debugImg(plateImg.size(), plateImg.type());
|
||||||
plateImg.copyTo(debugImg);
|
plateImg.copyTo(debugImg);
|
||||||
@@ -87,7 +79,11 @@ int StateIdentifier::recognize(Mat img, char* stateCode)
|
|||||||
if (result.haswinner == false)
|
if (result.haswinner == false)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
strcpy(stateCode, result.winner.c_str());
|
pipeline_data->region_code = result.winner;
|
||||||
|
pipeline_data->region_confidence = result.confidence;
|
||||||
|
|
||||||
return result.confidence;
|
if (result.confidence >= 10)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "featurematcher.h"
|
#include "featurematcher.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "pipeline_data.h"
|
||||||
|
|
||||||
class StateIdentifier
|
class StateIdentifier
|
||||||
{
|
{
|
||||||
@@ -33,8 +34,7 @@ class StateIdentifier
|
|||||||
StateIdentifier(Config* config);
|
StateIdentifier(Config* config);
|
||||||
virtual ~StateIdentifier();
|
virtual ~StateIdentifier();
|
||||||
|
|
||||||
int recognize(cv::Mat img, cv::Rect frame, char* stateCode);
|
bool recognize(PipelineData* pipeline_data);
|
||||||
int recognize(cv::Mat img, char* stateCode);
|
|
||||||
|
|
||||||
//int confidence;
|
//int confidence;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user