/src/tesseract/src/textord/pitsync1.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * File: pitsync1.h (Formerly pitsync.h) |
3 | | * Description: Code to find the optimum fixed pitch segmentation of some blobs. |
4 | | * Author: Ray Smith |
5 | | * Created: Thu Nov 19 11:48:05 GMT 1992 |
6 | | * |
7 | | * (C) Copyright 1992, Hewlett-Packard Ltd. |
8 | | ** Licensed under the Apache License, Version 2.0 (the "License"); |
9 | | ** you may not use this file except in compliance with the License. |
10 | | ** You may obtain a copy of the License at |
11 | | ** http://www.apache.org/licenses/LICENSE-2.0 |
12 | | ** Unless required by applicable law or agreed to in writing, software |
13 | | ** distributed under the License is distributed on an "AS IS" BASIS, |
14 | | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | | ** See the License for the specific language governing permissions and |
16 | | ** limitations under the License. |
17 | | * |
18 | | **********************************************************************/ |
19 | | |
20 | | #ifndef PITSYNC1_H |
21 | | #define PITSYNC1_H |
22 | | |
23 | | #include "blobbox.h" |
24 | | #include "clst.h" |
25 | | #include "elst.h" |
26 | | #include "params.h" |
27 | | #include "pithsync.h" |
28 | | #include "statistc.h" |
29 | | |
30 | | namespace tesseract { |
31 | | |
32 | | class FPSEGPT_LIST; |
33 | | |
34 | | class FPSEGPT : public ELIST<FPSEGPT>::LINK { |
35 | | public: |
36 | | FPSEGPT() = default; |
37 | | FPSEGPT( // constructor |
38 | | int16_t x); // position |
39 | | FPSEGPT( // constructor |
40 | | int16_t x, // position |
41 | | bool faking, // faking this one |
42 | | int16_t offset, // extra cost dist |
43 | | int16_t region_index, // segment number |
44 | | int16_t pitch, // proposed pitch |
45 | | int16_t pitch_error, // allowed tolerance |
46 | | FPSEGPT_LIST *prev_list); // previous segment |
47 | | FPSEGPT(FPCUTPT *cutpt); // build from new type |
48 | | |
49 | 777k | int32_t position() { // access func |
50 | 777k | return xpos; |
51 | 777k | } |
52 | 0 | double cost_function() { |
53 | 0 | return cost; |
54 | 0 | } |
55 | 125k | double squares() { |
56 | 125k | return sq_sum; |
57 | 125k | } |
58 | 62.7k | double sum() { |
59 | 62.7k | return mean_sum; |
60 | 62.7k | } |
61 | 0 | FPSEGPT *previous() { |
62 | 0 | return pred; |
63 | 0 | } |
64 | 62.7k | int16_t cheap_cuts() const { // no of cheap cuts |
65 | 62.7k | return mid_cuts; |
66 | 62.7k | } |
67 | | |
68 | | bool faked; // faked split point |
69 | | bool terminal; // successful end |
70 | | int16_t fake_count; // total fakes to here |
71 | | |
72 | | private: |
73 | | int16_t mid_cuts; // no of cheap cuts |
74 | | int32_t xpos; // location |
75 | | FPSEGPT *pred; // optimal previous |
76 | | double mean_sum; // mean so far |
77 | | double sq_sum; // summed distsances |
78 | | double cost; // cost function |
79 | | }; |
80 | | |
81 | | ELISTIZEH(FPSEGPT) |
82 | | CLISTIZEH(FPSEGPT_LIST) |
83 | | extern INT_VAR_H(pitsync_linear_version); |
84 | | extern double_VAR_H(pitsync_joined_edge); |
85 | | extern double_VAR_H(pitsync_offset_freecut_fraction); |
86 | | double check_pitch_sync( // find segmentation |
87 | | BLOBNBOX_IT *blob_it, // blobs to do |
88 | | int16_t blob_count, // no of blobs |
89 | | int16_t pitch, // pitch estimate |
90 | | int16_t pitch_error, // tolerance |
91 | | STATS *projection, // vertical |
92 | | FPSEGPT_LIST *seg_list // output list |
93 | | ); |
94 | | void make_illegal_segment( // find segmentation |
95 | | FPSEGPT_LIST *prev_list, // previous segments |
96 | | TBOX blob_box, // bounding box |
97 | | BLOBNBOX_IT blob_it, // iterator |
98 | | int16_t region_index, // number of segment |
99 | | int16_t pitch, // pitch estimate |
100 | | int16_t pitch_error, // tolerance |
101 | | FPSEGPT_LIST *seg_list // output list |
102 | | ); |
103 | | int16_t vertical_torow_projection( // project whole row |
104 | | TO_ROW *row, // row to do |
105 | | STATS *projection // output |
106 | | ); |
107 | | void vertical_cblob_projection( // project outlines |
108 | | C_BLOB *blob, // blob to project |
109 | | STATS *stats // output |
110 | | ); |
111 | | void vertical_coutline_projection( // project outlines |
112 | | C_OUTLINE *outline, // outline to project |
113 | | STATS *stats // output |
114 | | ); |
115 | | |
116 | | } // namespace tesseract |
117 | | |
118 | | #endif |