From 83e2570d3c8da9920d66a00c4bdf5650fe1b3336 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 25 Dec 2024 22:33:03 +0530 Subject: Parallel ocr evaluation for sections of screen + many refactorings --- include/libchelleport.h | 52 +++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 38 deletions(-) (limited to 'include/libchelleport.h') diff --git a/include/libchelleport.h b/include/libchelleport.h index e6a074d..b69466e 100644 --- a/include/libchelleport.h +++ b/include/libchelleport.h @@ -1,46 +1,12 @@ +#pragma once #include +#include #include +#include #include #include -// NOTE: Remember to update size and alignment in ocr hs module on change -struct OCRMatch { - int startX, startY; - int endX, endY; - const char *text; -}; - -// OCR configuration -#define CONFIDENCE_THRESHOLD 25. -#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); -} - -tesseract::TessBaseAPI *initializeTesseract(); - -Pix *loadImage(const char *imagePath); - -std::vector extractTextCoordinates(const char *imagePath); - -void printMatch(const OCRMatch &match); - -void preprocessImage(Pix **image); - -#define INLINE_IMAGE_PROC(process) \ - temp = process; \ - pixDestroy(image); \ - *image = temp; +#include "./recognizer.h" #define MEASURE(label, stmts) \ auto start = std::chrono::high_resolution_clock::now(); \ @@ -49,3 +15,13 @@ void preprocessImage(Pix **image); auto duration = \ std::chrono::duration_cast(end - start); \ std::cout << label << ": " << duration.count() / 1000.0 << " ms" << std::endl; + +extern "C" { +OCRMatch *findWordCoordinates(const char *image_path, /* returns */ int *size); +} + +std::vector extractTextMatches(const char *imagePath); + +std::vector +runRecognizers(std::vector> &recognizers, + Pix *image); -- cgit v1.3.1