2
Copyright (c) 1993-2008, Cognitive Technologies
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
8
* ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
���� ����������� �� ��������� �����, ���� ������ ������� � �����������
11
* ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
������ ����������, ������������ ��� ���������������, ������ �����������
13
��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
����������� ����� �� ��������.
15
* �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
���� ������������ � �������� �������� ��������� �/��� �����������
17
���������, ���������� �� ���� ��, ��� ���������������� �����������
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
������������� ������, ��������� � �������������� ��� ���������� ����������
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
36
* Redistributions of source code must retain the above copyright notice,
37
this list of conditions and the following disclaimer.
38
* Redistributions in binary form must reproduce the above copyright notice,
39
this list of conditions and the following disclaimer in the documentation
40
and/or other materials provided with the distribution.
41
* Neither the name of the Cognitive Technologies nor the names of its
42
contributors may be used to endorse or promote products derived from this
43
software without specific prior written permission.
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
Copyright (c) 1993-2008, Cognitive Technologies
5
Разрешается повторное распространение и использование как в виде исходного кода,
6
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
8
* При повторном распространении исходного кода должны оставаться указанное
9
выше уведомление об авторском праве, этот список условий и последующий
11
* При повторном распространении двоичного кода в документации и/или в
12
других материалах, поставляемых при распространении, должны сохраняться
13
указанная выше информация об авторском праве, этот список условий и
14
последующий отказ от гарантий.
15
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут
16
быть использованы в качестве средства поддержки и/или продвижения
17
продуктов, основанных на этом ПО, без предварительного письменного
20
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
21
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
22
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
23
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
24
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
25
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
26
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
27
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
28
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
29
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
30
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
31
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
36
* Redistributions of source code must retain the above copyright notice,
37
this list of conditions and the following disclaimer.
38
* Redistributions in binary form must reproduce the above copyright notice,
39
this list of conditions and the following disclaimer in the documentation
40
and/or other materials provided with the distribution.
41
* Neither the name of the Cognitive Technologies nor the names of its
42
contributors may be used to endorse or promote products derived from this
43
software without specific prior written permission.
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
60
#include "recdefs.h"
63
61
#include "evndefs.h"
64
62
#include "minmax.h"
68
#define WORLD_MAX_HEIGHT 10000
69
#define WORLD_MAX_WIDTH 10000 //7000
70
#define WORLD_MAX_RESOLUTION 800
65
#define WORLD_MAX_HEIGHT 10000
66
#define WORLD_MAX_WIDTH 10000 //7000
67
#define WORLD_MAX_RESOLUTION 800
72
#define WORLD_MAX_HEIGHT 4096 // ordinary image
73
#define WORLD_MAX_WIDTH 4096
74
#define WORLD_MAX_RESOLUTION 400
69
#define WORLD_MAX_HEIGHT 4096 // ordinary image
70
#define WORLD_MAX_WIDTH 4096
71
#define WORLD_MAX_RESOLUTION 400
77
/* Moved to evndefs.h - Paul 23.09.97
78
#define RASTER_MAX_HEIGHT 63
79
#define RASTER_MAX_WIDTH 128
81
74
#define SMALL_SIZE 8
82
75
#define err_pnlet(c) ((c))->nextl=((c))->prevl=(cell*)(0xffff0000);
85
/* Moved to evndefs.h - Paul 23.09.97
86
//-------------------- conectivity component ---------------------
90
void *mnfirstbox; // address of the first box
91
Int16 mncounter; // number of living lines in the component
92
#define mnfree mnfirstbox // reference to next free main number
93
Int16 mnupper; // upper bound of component
94
Int16 mnlower; // lower bound of component
95
Int16 mnboxcnt; // number of boxes in component
96
#define usual_box_count 20 // heuristic of number of lines in a letter
97
#define great_box_count 200 // heuristic for number of boxes in a picture
98
Word8 mnlines; // number of lines in the component
99
Word8 mnbegs; // number of free line begins
100
Word8 mnends; // number of free line ends
101
Word8 mnflag; // flag byte for main number
102
#define mnpicture 1 // component is a picture
103
struct mn_struc *mnnext; // address of next dead component
105
typedef struct mn_struc MN;
109
77
//------------------- The box has a header ----------------------
113
struct box_struct *boxnext; // chain address (zero if no next box)
114
MN * boxmain; // component main number pointer
115
Word16 boxptr; // ptr to the empty place in the box
116
Int16 boxleft; // left boundary for line envelope
117
Int16 boxright; // right boundary for line envelope
118
Int16 boxey; // row of line end+1 ( if line ends within
120
Int16 boxel; // length of the last segment (if line ends
122
Int16 boxex; // coordinate of last segment end (if line
124
Word8 boxflag; // byte for box attributes flags
125
Word8 boxwf; // working flag (for picture compress)
126
Word16 boxresw; // reserved word (for *4 arround)
80
struct box_struct *boxnext; // chain address (zero if no next box)
81
MN * boxmain; // component main number pointer
82
uint16_t boxptr; // ptr to the empty place in the box
83
int16_t boxleft; // left boundary for line envelope
84
int16_t boxright; // right boundary for line envelope
85
int16_t boxey; // row of line end+1 ( if line ends within
87
int16_t boxel; // length of the last segment (if line ends
89
int16_t boxex; // coordinate of last segment end (if line
91
uchar boxflag; // byte for box attributes flags
92
uchar boxwf; // working flag (for picture compress)
93
uint16_t boxresw; // reserved word (for *4 arround)
128
95
typedef struct box_struct BOX;
130
97
// Values of boxflag:
139
106
// '00' - no information about begin/end in this box
140
107
#define BOXBEG 0x10 // line start not free
141
108
#define BOXEND 0x40 // line end not free
145
111
#define BOXHLTH (sizeof(BOX)) // the box header length
146
112
#define BOXSIZE (BOXHLTH+32*4) // the length of box
147
113
#define BOXBOUNDARY (BOXSIZE-6) // the boundary control
151
Int16 y; // y coord. of the first interval
152
Int16 l; // first interval length
153
Int16 x; // x coord. of the end of the first interval
114
struct ldescr_struct {
115
int16_t y; // y coord. of the first interval
116
int16_t l; // first interval length
117
int16_t x; // x coord. of the end of the first interval
155
119
typedef struct ldescr_struct LNSTRT;
159
Int16 l; // length of interval
160
Int16 d; // displacement of the end of the current interval relative
161
}; // to the previous
121
struct box_interval {
122
int16_t l; // length of interval
123
int16_t d; // displacement of the end of the current interval relative
124
}; // to the previous
162
125
typedef struct box_interval BOXINT;
164
127
//-------------------- component in kit --------------------------
168
Word16 size; // size of component in paragraphs >=3
169
Int16 upper; // upper boundary of component
170
Int16 left; // left boundary of component
171
Int16 h; // height of component
172
Int16 w; // width of component
173
Word8 rw; // raster width in bytes
174
Word8 type; // recognition type
130
uint16_t size; // size of component in paragraphs >=3
131
int16_t upper; // upper boundary of component
132
int16_t left; // left boundary of component
133
int16_t h; // height of component
134
int16_t w; // width of component
135
uchar rw; // raster width in bytes
136
uchar type; // recognition type
175
137
#define ch_perfect 1 // perfect type defined
176
138
#define ch_letter 2 // letter type
177
139
#define ch_dust 4 // dust type
180
142
#define ch_great 32 // great component
181
143
#define ch_merge 64 // merged components
182
144
#define ch_notltr 128 // not letter or punctuation
183
Word8 cs; // recognition case (see bellow)
184
Word8 pidx; // proportional index (ref.)
185
Int16 nvers; // number of alternative versions
186
Int16 records; // recognition records offset
187
Int16 lines; // ptr to line representation
188
Int16 nl; // number of lines
189
Word8 begs; // number of free begins
190
Word8 ends; // number of free ends
191
Word8 reasno; // proportional criteria messages
192
Word8 large; // large type
145
uchar cs; // recognition case (see bellow)
146
uchar pidx; // proportional index (ref.)
147
int16_t nvers; // number of alternative versions
148
int16_t records; // recognition records offset
149
int16_t lines; // ptr to line representation
150
int16_t nl; // number of lines
151
uchar begs; // number of free begins
152
uchar ends; // number of free ends
153
uchar reasno; // proportional criteria messages
154
uchar large; // large type
193
155
#define ch_underlined 1 // component was underlined
194
156
#define ch_taken 2 // taken to line at dust_ini
195
Word8 scale; // scale of the component
197
// Word8 stairs[4]; // bit_map for stairs_vector components
198
struct comp_struc * next;
157
uchar scale; // scale of the component
159
// uchar stairs[4]; // bit_map for stairs_vector components
160
struct comp_struc * next;
201
163
typedef struct comp_struc c_comp;
203
165
//----------------------- cell ----------------------------------
205
167
#define VERS_IN_CELL 16 // Vald. 06-04-94
207
struct vers_struct // versions with probabilities
209
Word8 let; // character
210
Word8 prob; // probability
168
struct vers_struct // versions with probabilities
170
uchar let; // character
171
uchar prob; // probability
212
173
typedef struct vers_struct version;
214
175
//-------------------- line representation ----------------------