mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-05 18:36:51 +08:00
Removed unused confidence values and replaced with a disqualify boolean
The disqualify reason is purely for debugging. This should help make it obvious why a plate candidate was rejected
This commit is contained in:
@@ -224,7 +224,7 @@ int main( int argc, const char** argv )
|
||||
double analysisTime = diffclock(startTime, endTime);
|
||||
cout << "\tRegion " << z << ": Analysis time: " << analysisTime << "ms." << endl;
|
||||
|
||||
if (pipeline_data.plate_area_confidence > 10)
|
||||
if (!pipeline_data.disqualified)
|
||||
{
|
||||
lpAnalysisPositiveTimes.push_back(analysisTime);
|
||||
|
||||
|
@@ -152,7 +152,7 @@ namespace alpr
|
||||
lp.recognize();
|
||||
|
||||
bool plateDetected = false;
|
||||
if (pipeline_data.plate_area_confidence > 10)
|
||||
if (!pipeline_data.disqualified)
|
||||
{
|
||||
AlprPlateResult plateResult;
|
||||
plateResult.region = defaultRegion;
|
||||
|
@@ -31,7 +31,6 @@ namespace alpr
|
||||
this->pipeline_data = pipeline_data;
|
||||
|
||||
// First re-crop the area from the original picture knowing the text position
|
||||
this->confidence = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -128,7 +127,6 @@ namespace alpr
|
||||
PlateCorners cornerFinder(newCrop, &plateLines, pipeline_data, newLines);
|
||||
vector<Point> smallPlateCorners = cornerFinder.findPlateCorners();
|
||||
|
||||
confidence = cornerFinder.confidence;
|
||||
|
||||
// Transform the best corner points back to the original image
|
||||
std::vector<Point2f> imgArea;
|
||||
|
@@ -36,7 +36,6 @@ namespace alpr
|
||||
|
||||
std::vector<cv::Point2f> findEdgeCorners();
|
||||
|
||||
float confidence;
|
||||
|
||||
private:
|
||||
PipelineData* pipeline_data;
|
||||
|
@@ -103,11 +103,16 @@ namespace alpr
|
||||
|
||||
// Check if a left/right edge has been established.
|
||||
if (bestLeft.p1.x == 0 && bestLeft.p1.y == 0 && bestLeft.p2.x == 0 && bestLeft.p2.y == 0)
|
||||
confidence = 0;
|
||||
{
|
||||
pipelineData->disqualified = true;
|
||||
pipelineData->disqualify_reason = "platecorners did not find a left/right edge";
|
||||
}
|
||||
else if (bestTop.p1.x == 0 && bestTop.p1.y == 0 && bestTop.p2.x == 0 && bestTop.p2.y == 0)
|
||||
confidence = 0;
|
||||
else
|
||||
confidence = 100;
|
||||
{
|
||||
pipelineData->disqualified = true;
|
||||
pipelineData->disqualify_reason = "platecorners did not find a top/bottom edge";
|
||||
}
|
||||
|
||||
|
||||
vector<Point> corners;
|
||||
corners.push_back(bestTop.intersection(bestLeft));
|
||||
|
@@ -53,8 +53,6 @@ namespace alpr
|
||||
|
||||
std::vector<cv::Point> findPlateCorners();
|
||||
|
||||
float confidence;
|
||||
|
||||
private:
|
||||
|
||||
PipelineData* pipelineData;
|
||||
|
@@ -46,7 +46,6 @@ namespace alpr
|
||||
{
|
||||
charSegmenter = NULL;
|
||||
|
||||
pipeline_data->plate_area_confidence = 0;
|
||||
pipeline_data->isMultiline = config->multiline;
|
||||
|
||||
|
||||
@@ -58,14 +57,14 @@ namespace alpr
|
||||
|
||||
CharacterAnalysis textAnalysis(pipeline_data);
|
||||
|
||||
if (textAnalysis.confidence > 10)
|
||||
if (!pipeline_data->disqualified)
|
||||
{
|
||||
|
||||
EdgeFinder edgeFinder(pipeline_data);
|
||||
|
||||
pipeline_data->plate_corners = edgeFinder.findEdgeCorners();
|
||||
|
||||
if (edgeFinder.confidence > 0)
|
||||
if (!pipeline_data->disqualified)
|
||||
{
|
||||
|
||||
timespec startTime;
|
||||
@@ -120,7 +119,6 @@ namespace alpr
|
||||
charSegmenter = new CharacterSegmenter(pipeline_data);
|
||||
|
||||
|
||||
pipeline_data->plate_area_confidence = 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -48,5 +48,7 @@ namespace alpr
|
||||
this->config = config;
|
||||
this->region_confidence = 0;
|
||||
this->plate_inverted = false;
|
||||
this->disqualified = false;
|
||||
this->disqualify_reason = "";
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include "utility.h"
|
||||
#include "config.h"
|
||||
#include "textdetection/textline.h"
|
||||
#include "edges/scorekeeper.h"
|
||||
|
||||
namespace alpr
|
||||
{
|
||||
@@ -47,8 +48,10 @@ namespace alpr
|
||||
std::string region_code;
|
||||
float region_confidence;
|
||||
|
||||
bool disqualified;
|
||||
std::string disqualify_reason;
|
||||
|
||||
float plate_area_confidence;
|
||||
ScoreKeeper confidence_weights;
|
||||
|
||||
std::vector<cv::Rect> charRegions;
|
||||
|
||||
|
@@ -35,8 +35,6 @@ namespace alpr
|
||||
this->pipeline_data = pipeline_data;
|
||||
this->config = pipeline_data->config;
|
||||
|
||||
this->confidence = 0;
|
||||
|
||||
if (this->config->debugCharAnalysis)
|
||||
cout << "Starting CharacterAnalysis identification" << endl;
|
||||
|
||||
@@ -129,7 +127,11 @@ namespace alpr
|
||||
cout << "Best fit score: " << bestFitScore << " Index: " << bestFitIndex << endl;
|
||||
|
||||
if (bestFitScore <= 1)
|
||||
{
|
||||
pipeline_data->disqualified = true;
|
||||
pipeline_data->disqualify_reason = "Low best fit score in characteranalysis";
|
||||
return;
|
||||
}
|
||||
|
||||
//getColorMask(img, allContours, allHierarchy, charSegments);
|
||||
|
||||
@@ -202,10 +204,21 @@ namespace alpr
|
||||
confidenceDrainers += 95;
|
||||
}
|
||||
|
||||
if (confidenceDrainers >= 100)
|
||||
this->confidence=1;
|
||||
if (confidenceDrainers >= 90)
|
||||
{
|
||||
pipeline_data->disqualified = true;
|
||||
pipeline_data->disqualify_reason = "Low confidence in characteranalysis";
|
||||
}
|
||||
else
|
||||
this->confidence = 100 - confidenceDrainers;
|
||||
{
|
||||
float confidence = 100 - confidenceDrainers;
|
||||
pipeline_data->confidence_weights.setScore("CHARACTER_ANALYSIS_SCORE", confidence, 1.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pipeline_data->disqualified = true;
|
||||
pipeline_data->disqualify_reason = "No text lines found in characteranalysis";
|
||||
}
|
||||
|
||||
if (config->debugTiming)
|
||||
|
@@ -39,8 +39,6 @@ namespace alpr
|
||||
CharacterAnalysis(PipelineData* pipeline_data);
|
||||
virtual ~CharacterAnalysis();
|
||||
|
||||
int confidence;
|
||||
|
||||
cv::Mat bestThreshold;
|
||||
|
||||
TextContours bestContours;
|
||||
|
Reference in New Issue
Block a user