chiark / gitweb /
Much better error handling.
[ypp-sc-tools.db-live.git] / pctb / ocr.h
index 26bccbc7b83b81bb693b27995063ed7cedbecc1d..5a08b5051dc0902d325c164e5fbac0d554e877e0 100644 (file)
@@ -1,34 +1,48 @@
+/*
+ * ocr.c forms a mostly-self-contained bit
+ * so we put its declarations in this separate file
+ */
+
 #ifndef OCR_H
 #define OCR_H
 
-#include <pam.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <assert.h>
+#include "common.h"
+
 #include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <assert.h>
+#include <stdint.h>
 #include <stdlib.h>
-#include <sys/types.h>
+#include <unistd.h>
+#include <inttypes.h>
+
 #include <sys/wait.h>
 
+
 typedef uint32_t Pixcol;
 #define PSPIXCOL(priscan) priscan##32
 
 typedef struct {
   const char *s; /* valid until next call to ocr() */
   int l,r; /* column numbers */
-  int ctx; /* match context index */
+  unsigned ctxmap; /* match context index */
 } OcrResultGlyph;
 
-OcrResultGlyph *ocr(int w, int h, Pixcol cols[]);
+
+typedef const struct OcrCellTypeInfo *OcrCellType;
+extern const struct OcrCellTypeInfo ocr_celltype_text;
+extern const struct OcrCellTypeInfo ocr_celltype_number;
+const char *ocr_celltype_name(OcrCellType ct);
+
+
+typedef struct OcrReader OcrReader;
+OcrReader *ocr_init(int h);
+
+OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
   /* return value is array terminated by {0,-1,-1}
    * array is valid until next call to ocr()
    */
 
-void ocr_init(void);
-
-void debug_flush(void);
-
-#define eassert assert
-#define debug stdout
 
 #endif /*OCR_H*/