diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-25 19:49:10 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-25 19:49:16 +0530 |
| commit | fb24e589290f7ffbee04972eed35fca37facdf1c (patch) | |
| tree | 49a467cf35f9ac3469164a6134d0a0a3b5b3074a /include/libchelleport.h | |
| parent | 580439bf8dd33e00f6a668a4828eab01d24d7abf (diff) | |
| download | chelleport-fb24e589290f7ffbee04972eed35fca37facdf1c.tar.gz chelleport-fb24e589290f7ffbee04972eed35fca37facdf1c.zip | |
Minor tesseract optimizations
Diffstat (limited to '')
| -rw-r--r-- | include/libchelleport.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/include/libchelleport.h b/include/libchelleport.h index c74058d..e6a074d 100644 --- a/include/libchelleport.h +++ b/include/libchelleport.h @@ -1,5 +1,6 @@ +#include <chrono> #include <leptonica/allheaders.h> -#include <tesseract/publictypes.h> +#include <tesseract/baseapi.h> #include <vector> // NOTE: Remember to update size and alignment in ocr hs module on change @@ -26,8 +27,25 @@ 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 showMatch(const OCRMatch &match); +void printMatch(const OCRMatch &match); void preprocessImage(Pix **image); + +#define INLINE_IMAGE_PROC(process) \ + temp = process; \ + pixDestroy(image); \ + *image = temp; + +#define MEASURE(label, stmts) \ + auto start = std::chrono::high_resolution_clock::now(); \ + stmts; \ + auto end = std::chrono::high_resolution_clock::now(); \ + auto duration = \ + std::chrono::duration_cast<std::chrono::microseconds>(end - start); \ + std::cout << label << ": " << duration.count() / 1000.0 << " ms" << std::endl; |
