From c7853e29f3a1a9b96d9d776863a1c46536eebd4b Mon Sep 17 00:00:00 2001 From: Kristians Vebers Date: Wed, 19 Feb 2014 09:50:05 +0200 Subject: [PATCH 1/4] Fixed access for non existing array index in case if arraySize=0 --- src/openalpr/utility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openalpr/utility.cpp b/src/openalpr/utility.cpp index 4953e2c..1478b42 100644 --- a/src/openalpr/utility.cpp +++ b/src/openalpr/utility.cpp @@ -178,7 +178,7 @@ vector produceThresholds(const Mat img_gray, Config* config) double median(int array[], int arraySize) { std::sort(&array[0], &array[arraySize]); - return arraySize % 2 ? array[arraySize / 2] : (array[arraySize / 2 - 1] + array[arraySize / 2]) / 2; + return arraySize % 2 ? array[arraySize / 2] : (array[max(0, arraySize / 2 - 1)] + array[arraySize / 2]) / 2; } From f2f2939c313dedee1ddc5062880ed960ea34309e Mon Sep 17 00:00:00 2001 From: Kristians Vebers Date: Wed, 19 Feb 2014 09:51:31 +0200 Subject: [PATCH 2/4] Added missing header --- src/openalpr/colorfilter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openalpr/colorfilter.h b/src/openalpr/colorfilter.h index d4075ac..2f4a19a 100644 --- a/src/openalpr/colorfilter.h +++ b/src/openalpr/colorfilter.h @@ -21,6 +21,7 @@ #ifndef COLORFILTER_H #define COLORFILTER_H +#include #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" From 16274cb5a8089821a3f273c1a19fea1e9ed4487b Mon Sep 17 00:00:00 2001 From: Kristians Vebers Date: Wed, 19 Feb 2014 09:54:05 +0200 Subject: [PATCH 3/4] Modified to relative OpenCV include path --- src/openalpr/binarize_wolf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openalpr/binarize_wolf.h b/src/openalpr/binarize_wolf.h index 93604f4..92f02f0 100644 --- a/src/openalpr/binarize_wolf.h +++ b/src/openalpr/binarize_wolf.h @@ -25,8 +25,8 @@ #include #include -#include -#include +#include "opencv2/opencv.hpp" +#include "opencv2/highgui/highgui.hpp" using namespace std; using namespace cv; From fee77e9aea5973490031ee1f83b05b52ab2d895f Mon Sep 17 00:00:00 2001 From: Kristians Vebers Date: Wed, 19 Feb 2014 10:09:38 +0200 Subject: [PATCH 4/4] Reversed segfault fix as it was already fixed --- src/openalpr/utility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openalpr/utility.cpp b/src/openalpr/utility.cpp index f8cbb35..8b30359 100644 --- a/src/openalpr/utility.cpp +++ b/src/openalpr/utility.cpp @@ -177,7 +177,7 @@ double median(int array[], int arraySize) } std::sort(&array[0], &array[arraySize]); - return arraySize % 2 ? array[arraySize / 2] : (array[max(0, arraySize / 2 - 1)] + array[arraySize / 2]) / 2; + return arraySize % 2 ? array[arraySize / 2] : (array[arraySize / 2 - 1] + array[arraySize / 2]) / 2; }