diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-25 22:33:03 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-25 22:42:27 +0530 |
| commit | 83e2570d3c8da9920d66a00c4bdf5650fe1b3336 (patch) | |
| tree | 5755d561acdb86422e2ce3621e217a9c05dfb640 /include/libchelleport.h | |
| parent | fb24e589290f7ffbee04972eed35fca37facdf1c (diff) | |
| download | chelleport-83e2570d3c8da9920d66a00c4bdf5650fe1b3336.tar.gz chelleport-83e2570d3c8da9920d66a00c4bdf5650fe1b3336.zip | |
Parallel ocr evaluation for sections of screen + many refactorings
Diffstat (limited to 'include/libchelleport.h')
| -rw-r--r-- | include/libchelleport.h | 52 |
1 files changed, 14 insertions, 38 deletions
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 <chrono> +#include <iostream> #include <leptonica/allheaders.h> +#include <memory> #include <tesseract/baseapi.h> #include <vector> -// 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<OCRMatch> 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<std::chrono::microseconds>(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<OCRMatch> extractTextMatches(const char *imagePath); + +std::vector<OCRMatch> +runRecognizers(std::vector<std::unique_ptr<Recognizer>> &recognizers, + Pix *image); |
