From 397c0a613e66487fead7afb4b89b783d887389f3 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 28 Dec 2024 14:38:55 +0530 Subject: Create a sorted list of ocr matches by position on screen --- include/libchelleport.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'include/libchelleport.h') diff --git a/include/libchelleport.h b/include/libchelleport.h index c022975..d4e202f 100644 --- a/include/libchelleport.h +++ b/include/libchelleport.h @@ -19,8 +19,18 @@ extern "C" OCRMatch *findWordCoordinates(const char *image_path, /* returns */ int *size); -std::vector extractTextMatches(const char *imagePath); +struct ScreenPositionComparator { + bool operator()(const OCRMatch &a, const OCRMatch &b) const { + if (abs(a.startY - b.startY) < 5) + return a.startX < b.startX; + return a.startY < b.startY; + } +}; -std::vector +typedef std::set OCRMatchSet; + +OCRMatchSet extractTextMatches(const char *imagePath); + +OCRMatchSet runRecognizers(std::vector> &recognizers, Pix *image); -- cgit v1.3.1