From 683083959299f9451e7bed23e065596a1b24a829 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 24 Sep 2015 22:25:08 -0400 Subject: [PATCH] Supporting auto-invert for multiline character analysis (do the invert before finding the second line) --- .../textdetection/characteranalysis.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/openalpr/textdetection/characteranalysis.cpp b/src/openalpr/textdetection/characteranalysis.cpp index a61585f..ee3a7a9 100644 --- a/src/openalpr/textdetection/characteranalysis.cpp +++ b/src/openalpr/textdetection/characteranalysis.cpp @@ -145,6 +145,22 @@ namespace alpr displayImage(config, "Matching Contours", img_contours); } + if (config->auto_invert) + pipeline_data->plate_inverted = isPlateInverted(); + else + pipeline_data->plate_inverted = config->always_invert; + + if (config->debugGeneral) + cout << "Plate inverted: " << pipeline_data->plate_inverted << endl; + + // Invert multiline plates and redo the thresholds before finding the second line + if (config->multiline && config->auto_invert && pipeline_data->plate_inverted) + { + bitwise_not(pipeline_data->crop_gray, pipeline_data->crop_gray); + pipeline_data->thresholds = produceThresholds(pipeline_data->crop_gray, pipeline_data->config); + } + + LineFinder lf(pipeline_data); vector > linePolygons = lf.findLines(pipeline_data->crop_gray, bestContours); @@ -180,14 +196,6 @@ namespace alpr } - if (config->auto_invert) - pipeline_data->plate_inverted = isPlateInverted(); - else - pipeline_data->plate_inverted = config->always_invert; - - if (config->debugGeneral) - cout << "Plate inverted: " << pipeline_data->plate_inverted << endl; - if (pipeline_data->textLines.size() > 0) {