tesseract 4.1.1
Loading...
Searching...
No Matches
osdetect.cpp
Go to the documentation of this file.
1
2// File: osdetect.cpp
3// Description: Orientation and script detection.
4// Author: Samuel Charron
5// Ranjith Unnikrishnan
6//
7// (C) Copyright 2008, Google Inc.
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//
19
20#include <algorithm>
21#include <cmath> // for std::fabs
22#include <memory>
23
24#include "osdetect.h"
25
26#include "blobbox.h"
27#include "blread.h"
28#include "colfind.h"
29#include "fontinfo.h"
30#include "imagefind.h"
31#include "linefind.h"
32#include "oldlist.h"
33#include "qrsequence.h"
34#include "ratngs.h"
35#include "strngs.h"
36#include "tabvector.h"
37#include "tesseractclass.h"
38#include "textord.h"
39
40const float kSizeRatioToReject = 2.0;
42
43const float kScriptAcceptRatio = 1.3;
44
45const float kHanRatioInKorean = 0.7;
46const float kHanRatioInJapanese = 0.3;
47
48const float kNonAmbiguousMargin = 1.0;
49
50// General scripts
51static const char* han_script = "Han";
52static const char* latin_script = "Latin";
53static const char* katakana_script = "Katakana";
54static const char* hiragana_script = "Hiragana";
55static const char* hangul_script = "Hangul";
56
57// Pseudo-scripts Name
58const char* ScriptDetector::korean_script_ = "Korean";
59const char* ScriptDetector::japanese_script_ = "Japanese";
60const char* ScriptDetector::fraktur_script_ = "Fraktur";
61
63 float first = orientations[0];
64 float second = orientations[1];
66 if (orientations[0] < orientations[1]) {
67 first = orientations[1];
68 second = orientations[0];
70 }
71 for (int i = 2; i < 4; ++i) {
72 if (orientations[i] > first) {
73 second = first;
74 first = orientations[i];
76 } else if (orientations[i] > second) {
77 second = orientations[i];
78 }
79 }
80 // Store difference of top two orientation scores.
81 best_result.oconfidence = first - second;
82}
83
84void OSResults::set_best_orientation(int orientation_id) {
85 best_result.orientation_id = orientation_id;
87}
88
89void OSResults::update_best_script(int orientation) {
90 // We skip index 0 to ignore the "Common" script.
91 float first = scripts_na[orientation][1];
92 float second = scripts_na[orientation][2];
94 if (scripts_na[orientation][1] < scripts_na[orientation][2]) {
95 first = scripts_na[orientation][2];
96 second = scripts_na[orientation][1];
98 }
99 for (int i = 3; i < kMaxNumberOfScripts; ++i) {
100 if (scripts_na[orientation][i] > first) {
102 second = first;
103 first = scripts_na[orientation][i];
104 } else if (scripts_na[orientation][i] > second) {
105 second = scripts_na[orientation][i];
106 }
107 }
108 best_result.sconfidence = (second == 0.0f) ? 2.0f :
109 (first / second - 1.0) / (kScriptAcceptRatio - 1.0);
110}
111
112int OSResults::get_best_script(int orientation_id) const {
113 int max_id = -1;
114 for (int j = 0; j < kMaxNumberOfScripts; ++j) {
115 const char *script = unicharset->get_script_from_script_id(j);
116 if (strcmp(script, "Common") && strcmp(script, "NULL")) {
117 if (max_id == -1 ||
118 scripts_na[orientation_id][j] > scripts_na[orientation_id][max_id])
119 max_id = j;
120 }
121 }
122 return max_id;
123}
124
125// Print the script scores for all possible orientations.
126void OSResults::print_scores(void) const {
127 for (int i = 0; i < 4; ++i) {
128 tprintf("Orientation id #%d", i);
129 print_scores(i);
130 }
131}
132
133// Print the script scores for the given candidate orientation.
134void OSResults::print_scores(int orientation_id) const {
135 for (int j = 0; j < kMaxNumberOfScripts; ++j) {
136 if (scripts_na[orientation_id][j]) {
137 tprintf("%12s\t: %f\n", unicharset->get_script_from_script_id(j),
138 scripts_na[orientation_id][j]);
139 }
140 }
141}
142
143// Accumulate scores with given OSResults instance and update the best script.
145 for (int i = 0; i < 4; ++i) {
146 orientations[i] += osr.orientations[i];
147 for (int j = 0; j < kMaxNumberOfScripts; ++j)
148 scripts_na[i][j] += osr.scripts_na[i][j];
149 }
153}
154
155// Detect and erase horizontal/vertical lines and picture regions from the
156// image, so that non-text blobs are removed from consideration.
157static void remove_nontext_regions(tesseract::Tesseract *tess,
158 BLOCK_LIST *blocks,
159 TO_BLOCK_LIST *to_blocks) {
160 Pix *pix = tess->pix_binary();
161 ASSERT_HOST(pix != nullptr);
162 int vertical_x = 0;
163 int vertical_y = 1;
164 tesseract::TabVector_LIST v_lines;
165 tesseract::TabVector_LIST h_lines;
166 int resolution;
167 if (kMinCredibleResolution > pixGetXRes(pix)) {
168 resolution = kMinCredibleResolution;
169 tprintf("Warning. Invalid resolution %d dpi. Using %d instead.\n",
170 pixGetXRes(pix), resolution);
171 } else {
172 resolution = pixGetXRes(pix);
173 }
174
175 tesseract::LineFinder::FindAndRemoveLines(resolution, false, pix,
176 &vertical_x, &vertical_y,
177 nullptr, &v_lines, &h_lines);
178 Pix* im_pix = tesseract::ImageFind::FindImages(pix, nullptr);
179 if (im_pix != nullptr) {
180 pixSubtract(pix, pix, im_pix);
181 pixDestroy(&im_pix);
182 }
184 blocks, to_blocks);
185}
186
187// Find connected components in the page and process a subset until finished or
188// a stopping criterion is met.
189// Returns the number of blobs used in making the estimate. 0 implies failure.
191 OSResults* osr,
192 tesseract::Tesseract* tess) {
193 STRING name = filename; //truncated name
194 const char *lastdot; //of name
195 TBOX page_box;
196
197 lastdot = strrchr (name.string (), '.');
198 if (lastdot != nullptr)
199 name[lastdot-name.string()] = '\0';
200
201 ASSERT_HOST(tess->pix_binary() != nullptr);
202 int width = pixGetWidth(tess->pix_binary());
203 int height = pixGetHeight(tess->pix_binary());
204
205 BLOCK_LIST blocks;
206 if (!read_unlv_file(name, width, height, &blocks))
207 FullPageBlock(width, height, &blocks);
208
209 // Try to remove non-text regions from consideration.
210 TO_BLOCK_LIST land_blocks, port_blocks;
211 remove_nontext_regions(tess, &blocks, &port_blocks);
212
213 if (port_blocks.empty()) {
214 // page segmentation did not succeed, so we need to find_components first.
216 &blocks, &port_blocks);
217 } else {
218 page_box.set_left(0);
219 page_box.set_bottom(0);
220 page_box.set_right(width);
221 page_box.set_top(height);
222 // Filter_blobs sets up the TO_BLOCKs the same as find_components does.
223 tess->mutable_textord()->filter_blobs(page_box.topright(),
224 &port_blocks, true);
225 }
226
227 return os_detect(&port_blocks, osr, tess);
228}
229
230// Filter and sample the blobs.
231// Returns a non-zero number of blobs if the page was successfully processed, or
232// zero if the page had too few characters to be reliable
233int os_detect(TO_BLOCK_LIST* port_blocks, OSResults* osr,
234 tesseract::Tesseract* tess) {
235 int blobs_total = 0;
236 TO_BLOCK_IT block_it;
237 block_it.set_to_list(port_blocks);
238
239 BLOBNBOX_CLIST filtered_list;
240 BLOBNBOX_C_IT filtered_it(&filtered_list);
241
242 for (block_it.mark_cycle_pt(); !block_it.cycled_list();
243 block_it.forward ()) {
244 TO_BLOCK* to_block = block_it.data();
245 if (to_block->block->pdblk.poly_block() &&
246 !to_block->block->pdblk.poly_block()->IsText()) continue;
247 BLOBNBOX_IT bbox_it;
248 bbox_it.set_to_list(&to_block->blobs);
249 for (bbox_it.mark_cycle_pt (); !bbox_it.cycled_list ();
250 bbox_it.forward ()) {
251 BLOBNBOX* bbox = bbox_it.data();
252 C_BLOB* blob = bbox->cblob();
253 TBOX box = blob->bounding_box();
254 ++blobs_total;
255
256 // Catch illegal value of box width and avoid division by zero.
257 if (box.width() == 0) continue;
258 // TODO: Can height and width be negative? If not, remove fabs.
259 float y_x = std::fabs((box.height() * 1.0f) / box.width());
260 float x_y = 1.0f / y_x;
261 // Select a >= 1.0 ratio
262 float ratio = x_y > y_x ? x_y : y_x;
263 // Blob is ambiguous
264 if (ratio > kSizeRatioToReject) continue;
265 if (box.height() < kMinAcceptableBlobHeight) continue;
266 filtered_it.add_to_end(bbox);
267 }
268 }
269 return os_detect_blobs(nullptr, &filtered_list, osr, tess);
270}
271
272// Detect orientation and script from a list of blobs.
273// Returns a non-zero number of blobs if the list was successfully processed, or
274// zero if the list had too few characters to be reliable.
275// If allowed_scripts is non-null and non-empty, it is a list of scripts that
276// constrains both orientation and script detection to consider only scripts
277// from the list.
278int os_detect_blobs(const GenericVector<int>* allowed_scripts,
279 BLOBNBOX_CLIST* blob_list, OSResults* osr,
280 tesseract::Tesseract* tess) {
281 OSResults osr_;
282 int minCharactersToTry = tess->min_characters_to_try;
283 int maxCharactersToTry = 5 * minCharactersToTry;
284 if (osr == nullptr)
285 osr = &osr_;
286
287 osr->unicharset = &tess->unicharset;
288 OrientationDetector o(allowed_scripts, osr);
289 ScriptDetector s(allowed_scripts, osr, tess);
290
291 BLOBNBOX_C_IT filtered_it(blob_list);
292 int real_max = std::min(filtered_it.length(), maxCharactersToTry);
293 // tprintf("Total blobs found = %d\n", blobs_total);
294 // tprintf("Number of blobs post-filtering = %d\n", filtered_it.length());
295 // tprintf("Number of blobs to try = %d\n", real_max);
296
297 // If there are too few characters, skip this page entirely.
298 if (real_max < minCharactersToTry / 2) {
299 tprintf("Too few characters. Skipping this page\n");
300 return 0;
301 }
302
303 auto** blobs = new BLOBNBOX*[filtered_it.length()];
304 int number_of_blobs = 0;
305 for (filtered_it.mark_cycle_pt (); !filtered_it.cycled_list ();
306 filtered_it.forward ()) {
307 blobs[number_of_blobs++] = filtered_it.data();
308 }
309 QRSequenceGenerator sequence(number_of_blobs);
310 int num_blobs_evaluated = 0;
311 for (int i = 0; i < real_max; ++i) {
312 if (os_detect_blob(blobs[sequence.GetVal()], &o, &s, osr, tess)
313 && i > minCharactersToTry) {
314 break;
315 }
316 ++num_blobs_evaluated;
317 }
318 delete [] blobs;
319
320 // Make sure the best_result is up-to-date
321 int orientation = o.get_orientation();
322 osr->update_best_script(orientation);
323 return num_blobs_evaluated;
324}
325
326// Processes a single blob to estimate script and orientation.
327// Return true if estimate of orientation and script satisfies stopping
328// criteria.
330 ScriptDetector* s, OSResults* osr,
331 tesseract::Tesseract* tess) {
332 tess->tess_cn_matching.set_value(true); // turn it on
333 tess->tess_bn_matching.set_value(false);
334 C_BLOB* blob = bbox->cblob();
336 TBOX box = tblob->bounding_box();
337 FCOORD current_rotation(1.0f, 0.0f);
338 FCOORD rotation90(0.0f, 1.0f);
339 BLOB_CHOICE_LIST ratings[4];
340 // Test the 4 orientations
341 for (int i = 0; i < 4; ++i) {
342 // Normalize the blob. Set the origin to the place we want to be the
343 // bottom-middle after rotation.
344 // Scaling is to make the rotated height the x-height.
345 float scaling = static_cast<float>(kBlnXHeight) / box.height();
346 float x_origin = (box.left() + box.right()) / 2.0f;
347 float y_origin = (box.bottom() + box.top()) / 2.0f;
348 if (i == 0 || i == 2) {
349 // Rotation is 0 or 180.
350 y_origin = i == 0 ? box.bottom() : box.top();
351 } else {
352 // Rotation is 90 or 270.
353 scaling = static_cast<float>(kBlnXHeight) / box.width();
354 x_origin = i == 1 ? box.left() : box.right();
355 }
356 std::unique_ptr<TBLOB> rotated_blob(new TBLOB(*tblob));
357 rotated_blob->Normalize(nullptr, &current_rotation, nullptr,
358 x_origin, y_origin, scaling, scaling,
359 0.0f, static_cast<float>(kBlnBaselineOffset),
360 false, nullptr);
361 tess->AdaptiveClassifier(rotated_blob.get(), ratings + i);
362 current_rotation.rotate(rotation90);
363 }
364 delete tblob;
365
366 bool stop = o->detect_blob(ratings);
367 s->detect_blob(ratings);
368 int orientation = o->get_orientation();
369 stop = s->must_stop(orientation) && stop;
370 return stop;
371}
372
373
375 const GenericVector<int>* allowed_scripts, OSResults* osr) {
376 osr_ = osr;
377 allowed_scripts_ = allowed_scripts;
378}
379
380// Score the given blob and return true if it is now sure of the orientation
381// after adding this block.
382bool OrientationDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
383 float blob_o_score[4] = {0.0f, 0.0f, 0.0f, 0.0f};
384 float total_blob_o_score = 0.0f;
385
386 for (int i = 0; i < 4; ++i) {
387 BLOB_CHOICE_IT choice_it(scores + i);
388 if (!choice_it.empty()) {
389 BLOB_CHOICE* choice = nullptr;
390 if (allowed_scripts_ != nullptr && !allowed_scripts_->empty()) {
391 // Find the top choice in an allowed script.
392 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list() &&
393 choice == nullptr; choice_it.forward()) {
394 int choice_script = choice_it.data()->script_id();
395 int s = 0;
396 for (s = 0; s < allowed_scripts_->size(); ++s) {
397 if ((*allowed_scripts_)[s] == choice_script) {
398 choice = choice_it.data();
399 break;
400 }
401 }
402 }
403 } else {
404 choice = choice_it.data();
405 }
406 if (choice != nullptr) {
407 // The certainty score ranges between [-20,0]. This is converted here to
408 // [0,1], with 1 indicating best match.
409 blob_o_score[i] = 1 + 0.05 * choice->certainty();
410 total_blob_o_score += blob_o_score[i];
411 }
412 }
413 }
414 if (total_blob_o_score == 0.0) return false;
415 // Fill in any blanks with the worst score of the others. This is better than
416 // picking an arbitrary probability for it and way better than -inf.
417 float worst_score = 0.0f;
418 int num_good_scores = 0;
419 for (float f : blob_o_score) {
420 if (f > 0.0f) {
421 ++num_good_scores;
422 if (worst_score == 0.0f || f < worst_score)
423 worst_score = f;
424 }
425 }
426 if (num_good_scores == 1) {
427 // Lower worst if there is only one.
428 worst_score /= 2.0f;
429 }
430 for (float& f : blob_o_score) {
431 if (f == 0.0f) {
432 f = worst_score;
433 total_blob_o_score += worst_score;
434 }
435 }
436 // Normalize the orientation scores for the blob and use them to
437 // update the aggregated orientation score.
438 for (int i = 0; total_blob_o_score != 0 && i < 4; ++i) {
439 osr_->orientations[i] += log(blob_o_score[i] / total_blob_o_score);
440 }
441
442 // TODO(ranjith) Add an early exit test, based on min_orientation_margin,
443 // as used in pagesegmain.cpp.
444 return false;
445}
446
449 return osr_->best_result.orientation_id;
450}
451
452
454 OSResults* osr, tesseract::Tesseract* tess) {
455 osr_ = osr;
456 tess_ = tess;
457 allowed_scripts_ = allowed_scripts;
458 katakana_id_ = tess_->unicharset.add_script(katakana_script);
459 hiragana_id_ = tess_->unicharset.add_script(hiragana_script);
460 han_id_ = tess_->unicharset.add_script(han_script);
461 hangul_id_ = tess_->unicharset.add_script(hangul_script);
462 japanese_id_ = tess_->unicharset.add_script(japanese_script_);
463 korean_id_ = tess_->unicharset.add_script(korean_script_);
464 latin_id_ = tess_->unicharset.add_script(latin_script);
465 fraktur_id_ = tess_->unicharset.add_script(fraktur_script_);
466}
467
468
469// Score the given blob and return true if it is now sure of the script after
470// adding this blob.
471void ScriptDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
472 for (int i = 0; i < 4; ++i) {
473 bool done[kMaxNumberOfScripts] = { false };
474
475 BLOB_CHOICE_IT choice_it;
476 choice_it.set_to_list(scores + i);
477
478 float prev_score = -1;
479 int script_count = 0;
480 int prev_id = -1;
481 int prev_fontinfo_id = -1;
482 const char* prev_unichar = "";
483 const char* unichar = "";
484
485 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
486 choice_it.forward()) {
487 BLOB_CHOICE* choice = choice_it.data();
488 int id = choice->script_id();
489 if (allowed_scripts_ != nullptr && !allowed_scripts_->empty()) {
490 // Check that the choice is in an allowed script.
491 int s = 0;
492 for (s = 0; s < allowed_scripts_->size(); ++s) {
493 if ((*allowed_scripts_)[s] == id) break;
494 }
495 if (s == allowed_scripts_->size()) continue; // Not found in list.
496 }
497 // Script already processed before.
498 if (done[id]) continue;
499 done[id] = true;
500
501 unichar = tess_->unicharset.id_to_unichar(choice->unichar_id());
502 // Save data from the first match
503 if (prev_score < 0) {
504 prev_score = -choice->certainty();
505 script_count = 1;
506 prev_id = id;
507 prev_unichar = unichar;
508 prev_fontinfo_id = choice->fontinfo_id();
509 } else if (-choice->certainty() < prev_score + kNonAmbiguousMargin) {
510 ++script_count;
511 }
512
513 if (strlen(prev_unichar) == 1)
514 if (unichar[0] >= '0' && unichar[0] <= '9')
515 break;
516
517 // if script_count is >= 2, character is ambiguous, skip other matches
518 // since they are useless.
519 if (script_count >= 2)
520 break;
521 }
522 // Character is non ambiguous
523 if (script_count == 1) {
524 // Update the score of the winning script
525 osr_->scripts_na[i][prev_id] += 1.0;
526
527 // Workaround for Fraktur
528 if (prev_id == latin_id_) {
529 if (prev_fontinfo_id >= 0) {
530 const tesseract::FontInfo &fi =
531 tess_->get_fontinfo_table().get(prev_fontinfo_id);
532 //printf("Font: %s i:%i b:%i f:%i s:%i k:%i (%s)\n", fi.name,
533 // fi.is_italic(), fi.is_bold(), fi.is_fixed_pitch(),
534 // fi.is_serif(), fi.is_fraktur(),
535 // prev_unichar);
536 if (fi.is_fraktur()) {
537 osr_->scripts_na[i][prev_id] -= 1.0;
538 osr_->scripts_na[i][fraktur_id_] += 1.0;
539 }
540 }
541 }
542
543 // Update Japanese / Korean pseudo-scripts
544 if (prev_id == katakana_id_)
545 osr_->scripts_na[i][japanese_id_] += 1.0;
546 if (prev_id == hiragana_id_)
547 osr_->scripts_na[i][japanese_id_] += 1.0;
548 if (prev_id == hangul_id_)
549 osr_->scripts_na[i][korean_id_] += 1.0;
550 if (prev_id == han_id_) {
551 osr_->scripts_na[i][korean_id_] += kHanRatioInKorean;
552 osr_->scripts_na[i][japanese_id_] += kHanRatioInJapanese;
553 }
554 }
555 } // iterate over each orientation
556}
557
558bool ScriptDetector::must_stop(int orientation) {
559 osr_->update_best_script(orientation);
560 return osr_->best_result.sconfidence > 1;
561}
562
563// Helper method to convert an orientation index to its value in degrees.
564// The value represents the amount of clockwise rotation in degrees that must be
565// applied for the text to be upright (readable).
566int OrientationIdToValue(const int& id) {
567 switch (id) {
568 case 0:
569 return 0;
570 case 1:
571 return 270;
572 case 2:
573 return 180;
574 case 3:
575 return 90;
576 default:
577 return -1;
578 }
579}
const float kNonAmbiguousMargin
Definition: osdetect.cpp:48
int OrientationIdToValue(const int &id)
Definition: osdetect.cpp:566
bool os_detect_blob(BLOBNBOX *bbox, OrientationDetector *o, ScriptDetector *s, OSResults *osr, tesseract::Tesseract *tess)
Definition: osdetect.cpp:329
const float kScriptAcceptRatio
Definition: osdetect.cpp:43
int os_detect(TO_BLOCK_LIST *port_blocks, OSResults *osr, tesseract::Tesseract *tess)
Definition: osdetect.cpp:233
const float kHanRatioInJapanese
Definition: osdetect.cpp:46
const int kMinAcceptableBlobHeight
Definition: osdetect.cpp:41
const float kSizeRatioToReject
Definition: osdetect.cpp:40
int os_detect_blobs(const GenericVector< int > *allowed_scripts, BLOBNBOX_CLIST *blob_list, OSResults *osr, tesseract::Tesseract *tess)
Definition: osdetect.cpp:278
const float kHanRatioInKorean
Definition: osdetect.cpp:45
int orientation_and_script_detection(STRING &filename, OSResults *osr, tesseract::Tesseract *tess)
Definition: osdetect.cpp:190
const int kMaxNumberOfScripts
Definition: osdetect.h:38
void FullPageBlock(int width, int height, BLOCK_LIST *blocks)
Definition: blread.cpp:64
bool read_unlv_file(STRING name, int32_t xsize, int32_t ysize, BLOCK_LIST *blocks)
Definition: blread.cpp:32
const int kBlnBaselineOffset
Definition: normalis.h:25
const int kBlnXHeight
Definition: normalis.h:24
constexpr int kMinCredibleResolution
Definition: publictypes.h:38
#define ASSERT_HOST(x)
Definition: errcode.h:88
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:35
bool empty() const
Definition: genericvector.h:91
int size() const
Definition: genericvector.h:72
int script_id
Definition: osdetect.h:44
float oconfidence
Definition: osdetect.h:46
int orientation_id
Definition: osdetect.h:43
float sconfidence
Definition: osdetect.h:45
void accumulate(const OSResults &osr)
Definition: osdetect.cpp:144
OSBestResult best_result
Definition: osdetect.h:81
float orientations[4]
Definition: osdetect.h:76
UNICHARSET * unicharset
Definition: osdetect.h:80
void set_best_orientation(int orientation_id)
Definition: osdetect.cpp:84
void update_best_script(int orientation_id)
Definition: osdetect.cpp:89
TESS_API int get_best_script(int orientation_id) const
Definition: osdetect.cpp:112
void print_scores(void) const
Definition: osdetect.cpp:126
float scripts_na[4][kMaxNumberOfScripts]
Definition: osdetect.h:78
void update_best_orientation()
Definition: osdetect.cpp:62
bool detect_blob(BLOB_CHOICE_LIST *scores)
Definition: osdetect.cpp:382
OrientationDetector(const GenericVector< int > *allowed_scripts, OSResults *results)
Definition: osdetect.cpp:374
ScriptDetector(const GenericVector< int > *allowed_scripts, OSResults *osr, tesseract::Tesseract *tess)
Definition: osdetect.cpp:453
bool must_stop(int orientation)
Definition: osdetect.cpp:558
void detect_blob(BLOB_CHOICE_LIST *scores)
Definition: osdetect.cpp:471
Pix * pix_binary() const
Textord * mutable_textord()
C_BLOB * cblob() const
Definition: blobbox.h:268
BLOCK * block
Definition: blobbox.h:777
BLOBNBOX_LIST blobs
Definition: blobbox.h:772
Definition: blobs.h:284
TBOX bounding_box() const
Definition: blobs.cpp:468
static TBLOB * PolygonalCopy(bool allow_detailed_fx, C_BLOB *src)
Definition: blobs.cpp:327
bool is_fraktur() const
Definition: fontinfo.h:115
PDBLK pdblk
Page Description Block.
Definition: ocrblock.h:190
POLY_BLOCK * poly_block() const
Definition: pdblock.h:55
Definition: points.h:189
void rotate(const FCOORD vec)
Definition: points.h:763
bool IsText() const
Definition: polyblk.h:49
float certainty() const
Definition: ratngs.h:83
int script_id() const
Definition: ratngs.h:114
int16_t fontinfo_id() const
Definition: ratngs.h:86
UNICHAR_ID unichar_id() const
Definition: ratngs.h:77
Definition: rect.h:34
void set_right(int x)
Definition: rect.h:82
int16_t top() const
Definition: rect.h:58
void set_bottom(int y)
Definition: rect.h:68
int16_t width() const
Definition: rect.h:115
int16_t height() const
Definition: rect.h:108
void set_top(int y)
Definition: rect.h:61
int16_t left() const
Definition: rect.h:72
int16_t bottom() const
Definition: rect.h:65
const ICOORD & topright() const
Definition: rect.h:104
void set_left(int x)
Definition: rect.h:75
int16_t right() const
Definition: rect.h:79
TBOX bounding_box() const
Definition: stepblob.cpp:253
UNICHARSET unicharset
Definition: ccutil.h:73
Definition: strngs.h:45
const char * string() const
Definition: strngs.cpp:194
int add_script(const char *script)
const char * get_script_from_script_id(int id) const
Definition: unicharset.h:854
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:291
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
Definition: adaptmatch.cpp:191
UnicityTable< FontInfo > & get_fontinfo_table()
Definition: classify.h:386
static Pix * FindImages(Pix *pix, DebugPixa *pixa_debug)
Definition: imagefind.cpp:62
static void FindAndRemoveLines(int resolution, bool debug, Pix *pix, int *vertical_x, int *vertical_y, Pix **pix_music_mask, TabVector_LIST *v_lines, TabVector_LIST *h_lines)
Definition: linefind.cpp:243
void filter_blobs(ICOORD page_tr, TO_BLOCK_LIST *blocks, bool testing_on)
Definition: tordmain.cpp:250
void find_components(Pix *pix, BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
Definition: tordmain.cpp:219