1 /* 2 This is a Optical-Character-Recognition program 3 Copyright (C) 2000-2010 Joerg Schulenburg 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License 7 as published by the Free Software Foundation; either version 2 8 of the License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 see README for EMAIL-address 20 21 */ 22 23 #ifndef PGM2ASC_H 24 #define PGM2ASC_H 1 25 26 #include "pnm.h" 27 #include "output.h" 28 #include "list.h" 29 /* #include "unicode.h" JS.Aug2010 reduce dependencies */ 30 31 #define pixel_at(pic, xx, yy) (pic).p[(xx)+((yy)*((pic).x))] 32 #define pixel_atp(pic, xx, yy) (pic)->p[(xx)+((yy)*((pic)->x))] 33 34 #ifndef HAVE_WCHAR_H 35 wchar_t *wcschr (const wchar_t *wcs, wchar_t wc); 36 wchar_t *wcscpy (wchar_t *dest, const wchar_t *src); 37 size_t wcslen (const wchar_t *s); 38 #endif 39 #ifndef HAVE_WCSDUP 40 wchar_t * wcsdup (const wchar_t *WS); /* its a gnu extension */ 41 #endif 42 43 /* declared in pgm2asc.c */ 44 /* set alternate chars and its weight, called from the engine 45 if a char is recognized to (weight) percent */ 46 int setas(struct box *b, char *as, int weight); /* string + xml */ 47 int setac(struct box *b, wchar_t ac, int weight); /* wchar */ 48 49 /* for qsort() call */ 50 int intcompare (const void *vr, const void *vs); 51 52 /* declared in box.c */ 53 int box_gt(struct box *box1, struct box *box2); 54 int reset_box_ac(struct box *box); /* reset and free char table */ 55 struct box *malloc_box( struct box *inibox ); /* alloc memory for a box */ 56 int free_box( struct box *box ); /* free memory of a box */ 57 int copybox( pix *p, int x0, int y0, int dx, int dy, pix *b, int len); 58 int reduce_vectors ( struct box *box1, int mode ); 59 int merge_boxes( struct box *box1, struct box *box2 ); 60 int cut_box( struct box *box1); 61 62 63 /* declared in database.c */ 64 int load_db(job_t *job); 65 wchar_t ocr_db(struct box *box1, job_t *job); 66 67 /* declared in detect.c */ 68 int detect_lines1(pix * p, int x0, int y0, int dx, int dy); 69 int detect_lines2(pix *p,int x0,int y0,int dx,int dy,int r); 70 int detect_rotation_angle(job_t *job); 71 int detect_text_lines(pix * pp, int mo); 72 int adjust_text_lines(pix * pp, int mo); 73 int detect_pictures(job_t *job); 74 75 /* declared in lines.c */ 76 void store_boxtree_lines( job_t *job, int mo ); 77 /* free memory for internal stored textlines. 78 * Needs to be called _after_ having retrieved the text. 79 * After freeing, no call to getTextLine is possible any 80 * more 81 */ 82 void free_textlines(List *linelist); 83 84 /* get result of ocr for a given line number. 85 * If the line is out of range, the function returns 0, 86 * otherwise a pointer to a complete line. 87 */ 88 const char *getTextLine(List *linelist, int line); 89 90 /* declared in remove.c */ 91 int remove_dust( job_t *job ); 92 int remove_pictures( job_t *job); 93 int remove_melted_serifs( job_t *job, pix *pp ); 94 int remove_rest_of_dust( job_t *job ); 95 int smooth_borders( job_t *job ); 96 97 /* declared in pixel.c */ 98 int marked(pix * p, int x, int y); 99 int pixel(pix *p, int x, int y); 100 void put(pix * p, int x, int y, int ia, int io); 101 102 /* start ocr on a image in job.src.p */ 103 int pgm2asc(job_t *job); 104 105 #endif 106