aboutsummaryrefslogtreecommitdiff
path: root/include/libchelleport.h
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-25 17:46:41 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-25 18:09:18 +0530
commit580439bf8dd33e00f6a668a4828eab01d24d7abf (patch)
tree2f47ce1d6abbf33dfe232a13cc31a6534ca5dd5c /include/libchelleport.h
parent4e74eeebbaa441cda3a6846c47d82516878f8f05 (diff)
downloadchelleport-580439bf8dd33e00f6a668a4828eab01d24d7abf.tar.gz
chelleport-580439bf8dd33e00f6a668a4828eab01d24d7abf.zip
Add image preprocessing before ocr
Diffstat (limited to 'include/libchelleport.h')
-rw-r--r--include/libchelleport.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/include/libchelleport.h b/include/libchelleport.h
index ef693cb..c74058d 100644
--- a/include/libchelleport.h
+++ b/include/libchelleport.h
@@ -1,3 +1,4 @@
+#include <leptonica/allheaders.h>
#include <tesseract/publictypes.h>
#include <vector>
@@ -8,11 +9,19 @@ struct OCRMatch {
const char *text;
};
+// OCR configuration
#define CONFIDENCE_THRESHOLD 25.
-#define MIN_CHARACTER_COUNT 2
-
+#define MIN_CHARACTER_COUNT 3
const tesseract::PageIteratorLevel RESULT_ITER_MODE = tesseract::RIL_WORD;
+// Preprocessing configuration
+const float contrast = 0.3;
+const float sharpness = 0.7;
+const float scaleFactor = 1;
+const float grayscaleWeightRed = 0.114;
+const float grayscaleWeightGreen = 0.587;
+const float grayscaleWeightBlue = 0.299;
+
extern "C" {
OCRMatch *findWordCoordinates(const char *image_path, /* returns */ int *size);
}
@@ -20,3 +29,5 @@ OCRMatch *findWordCoordinates(const char *image_path, /* returns */ int *size);
std::vector<OCRMatch> extractTextCoordinates(const char *imagePath);
void showMatch(const OCRMatch &match);
+
+void preprocessImage(Pix **image);