mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 11:56:52 +08:00
Fixed seg and OCR benchmark using new skip_detection property
This commit is contained in:
@@ -89,8 +89,10 @@ int main( int argc, const char** argv )
|
|||||||
{
|
{
|
||||||
Config* config = new Config(country);
|
Config* config = new Config(country);
|
||||||
config->debugOff();
|
config->debugOff();
|
||||||
|
config->skipDetection = true;
|
||||||
|
|
||||||
OCR* ocr = new OCR(config);
|
AlprImpl alpr(country);
|
||||||
|
alpr.config = config;
|
||||||
|
|
||||||
for (int i = 0; i< files.size(); i++)
|
for (int i = 0; i< files.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -98,16 +100,16 @@ int main( int argc, const char** argv )
|
|||||||
{
|
{
|
||||||
string fullpath = inDir + "/" + files[i];
|
string fullpath = inDir + "/" + files[i];
|
||||||
|
|
||||||
frame = imread( fullpath.c_str() );
|
frame = cv::imread(fullpath.c_str());
|
||||||
resize(frame, frame, Size(config->ocrImageWidthPx, config->ocrImageHeightPx));
|
|
||||||
|
|
||||||
Rect plateCoords;
|
cv::Rect roi;
|
||||||
plateCoords.x = 0;
|
roi.x = 0;
|
||||||
plateCoords.y = 0;
|
roi.y = 0;
|
||||||
plateCoords.width = frame.cols;
|
roi.width = frame.cols;
|
||||||
plateCoords.height = frame.rows;
|
roi.height = frame.rows;
|
||||||
|
vector<Rect> rois;
|
||||||
PipelineData pipeline_data(frame, plateCoords, config);
|
rois.push_back(roi);
|
||||||
|
AlprResults results = alpr.recognize(frame, rois);
|
||||||
|
|
||||||
char statecode[3];
|
char statecode[3];
|
||||||
statecode[0] = files[i][0];
|
statecode[0] = files[i][0];
|
||||||
@@ -115,28 +117,12 @@ int main( int argc, const char** argv )
|
|||||||
statecode[2] = '\0';
|
statecode[2] = '\0';
|
||||||
string statecodestr(statecode);
|
string statecodestr(statecode);
|
||||||
|
|
||||||
CharacterAnalysis charRegion(&pipeline_data);
|
if (results.plates.size() == 1)
|
||||||
|
cout << files[i] << "," << statecode << "," << results.plates[0].bestPlate.characters << endl;
|
||||||
if (pipeline_data.textLines.size() > 0 &&
|
else if (results.plates.size() == 0)
|
||||||
abs(pipeline_data.textLines[0].angle) > 4)
|
cout << files[i] << "," << statecode << "," << endl;
|
||||||
{
|
else if (results.plates.size() > 1)
|
||||||
// Rotate image:
|
cout << files[i] << "," << statecode << ",???+" << endl;
|
||||||
Mat rotated(frame.size(), frame.type());
|
|
||||||
Mat rot_mat( 2, 3, CV_32FC1 );
|
|
||||||
Point center = Point( frame.cols/2, frame.rows/2 );
|
|
||||||
|
|
||||||
rot_mat = getRotationMatrix2D( center, pipeline_data.textLines[0].angle, 1.0 );
|
|
||||||
warpAffine( frame, rotated, rot_mat, frame.size() );
|
|
||||||
|
|
||||||
rotated.copyTo(frame);
|
|
||||||
pipeline_data.crop_gray = frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterSegmenter charSegmenter(&pipeline_data);
|
|
||||||
ocr->performOCR(&pipeline_data);
|
|
||||||
ocr->postProcessor.analyze(statecode, 25);
|
|
||||||
|
|
||||||
cout << files[i] << "," << statecode << "," << ocr->postProcessor.bestChars << endl;
|
|
||||||
|
|
||||||
imshow("Current LP", frame);
|
imshow("Current LP", frame);
|
||||||
waitKey(5);
|
waitKey(5);
|
||||||
@@ -144,7 +130,6 @@ int main( int argc, const char** argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete config;
|
delete config;
|
||||||
delete ocr;
|
|
||||||
}
|
}
|
||||||
else if (benchmarkName.compare("detection") == 0)
|
else if (benchmarkName.compare("detection") == 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user