aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-28 14:38:55 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-28 14:48:23 +0530
commit397c0a613e66487fead7afb4b89b783d887389f3 (patch)
treee0c24e6de5964a845f3704916ef64f8869fd81ac /include
parent9a5453aa190834b01e78cd971c445f1f0e34ee41 (diff)
downloadchelleport-397c0a613e66487fead7afb4b89b783d887389f3.tar.gz
chelleport-397c0a613e66487fead7afb4b89b783d887389f3.zip
Create a sorted list of ocr matches by position on screen
Diffstat (limited to 'include')
-rw-r--r--include/libchelleport.h14
1 files changed, 12 insertions, 2 deletions
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<OCRMatch> 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<OCRMatch>
+typedef std::set<OCRMatch, ScreenPositionComparator> OCRMatchSet;
+
+OCRMatchSet extractTextMatches(const char *imagePath);
+
+OCRMatchSet
runRecognizers(std::vector<std::unique_ptr<Recognizer>> &recognizers,
Pix *image);