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