From 6e204e925bb8e48f00b0c8d9c0736497cbcf23e9 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Thu, 16 Apr 2015 17:13:22 +0200 Subject: [PATCH 1/3] Bugfix: Private member has not been initialized, use parameter instead. Fixes #103 --- src/openalpr/pipeline_data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openalpr/pipeline_data.cpp b/src/openalpr/pipeline_data.cpp index 8936ff4..cabf3f1 100644 --- a/src/openalpr/pipeline_data.cpp +++ b/src/openalpr/pipeline_data.cpp @@ -11,7 +11,7 @@ namespace alpr Mat grayImg; if (colorImage.channels() > 2) { - cvtColor(this->colorImg, grayImg, CV_BGR2GRAY); + cvtColor(colorImage, grayImg, CV_BGR2GRAY); } else { From b491f61f0101d8287159d8a2e70c55321fd07a1e Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Thu, 16 Apr 2015 17:40:11 +0200 Subject: [PATCH 2/3] Bugfix: Skip processing if opencv cannot load image. --- src/misc_utilities/classifychars.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/misc_utilities/classifychars.cpp b/src/misc_utilities/classifychars.cpp index 42d950f..5148ad6 100644 --- a/src/misc_utilities/classifychars.cpp +++ b/src/misc_utilities/classifychars.cpp @@ -123,6 +123,11 @@ int main( int argc, const char** argv ) string fullpath = inDir + "/" + files[i]; cout << fullpath << endl; frame = imread( fullpath.c_str() ); + if(frame.data == NULL) + { + cout << "Unable to read license plate: " << fullpath << endl; + continue; + } resize(frame, frame, Size(config.ocrImageWidthPx, config.ocrImageHeightPx)); imshow ("Original", frame); From 5f7628c82c9e4834446fed36a84ee18b930aa3aa Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Thu, 16 Apr 2015 18:42:22 +0200 Subject: [PATCH 3/3] c++03 does not support delegating constructors, fallback to init pattern --- src/openalpr/pipeline_data.cpp | 29 +++++++++++++++-------------- src/openalpr/pipeline_data.h | 1 + 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/openalpr/pipeline_data.cpp b/src/openalpr/pipeline_data.cpp index cabf3f1..7d328c2 100644 --- a/src/openalpr/pipeline_data.cpp +++ b/src/openalpr/pipeline_data.cpp @@ -8,30 +8,23 @@ namespace alpr PipelineData::PipelineData(Mat colorImage, Rect regionOfInterest, Config* config) { - Mat grayImg; + Mat grayImage; + if (colorImage.channels() > 2) { - cvtColor(colorImage, grayImg, CV_BGR2GRAY); + cvtColor(colorImage, grayImage, CV_BGR2GRAY); } else { - grayImg = colorImage; + grayImage = colorImage; } - - PipelineData(colorImage, grayImg, regionOfInterest, config); + + this->init(colorImage, grayImage, regionOfInterest, config); } PipelineData::PipelineData(Mat colorImage, Mat grayImg, Rect regionOfInterest, Config* config) { - this->colorImg = colorImage; - this->grayImg = grayImg; - - this->regionOfInterest = regionOfInterest; - this->config = config; - - this->region_confidence = 0; - - plate_inverted = false; + this->init(colorImage, grayImg, regionOfInterest, config); } PipelineData::~PipelineData() @@ -48,4 +41,12 @@ namespace alpr thresholds.clear(); } + void PipelineData::init(cv::Mat colorImage, cv::Mat grayImage, cv::Rect regionOfInterest, Config *config) { + this->colorImg = colorImage; + this->grayImg = grayImage; + this->regionOfInterest = regionOfInterest; + this->config = config; + this->region_confidence = 0; + this->plate_inverted = false; + } } diff --git a/src/openalpr/pipeline_data.h b/src/openalpr/pipeline_data.h index 1396630..f8ca04a 100644 --- a/src/openalpr/pipeline_data.h +++ b/src/openalpr/pipeline_data.h @@ -18,6 +18,7 @@ namespace alpr PipelineData(cv::Mat colorImage, cv::Mat grayImage, cv::Rect regionOfInterest, Config* config); virtual ~PipelineData(); + void init(cv::Mat colorImage, cv::Mat grayImage, cv::Rect regionOfInterest, Config* config); void clearThresholds(); // Inputs