36
36
#include < algorithm>
37
37
#include < memory>
38
38
39
- const int kMinCharactersToTry = 50 ;
40
- const int kMaxCharactersToTry = 5 * kMinCharactersToTry ;
41
-
42
39
const float kSizeRatioToReject = 2.0 ;
43
40
const int kMinAcceptableBlobHeight = 10 ;
44
41
@@ -278,6 +275,8 @@ int os_detect_blobs(const GenericVector<int>* allowed_scripts,
278
275
BLOBNBOX_CLIST* blob_list, OSResults* osr,
279
276
tesseract::Tesseract* tess) {
280
277
OSResults osr_;
278
+ int minCharactersToTry = tess->min_characters_to_try ;
279
+ int maxCharactersToTry = 5 * minCharactersToTry;
281
280
if (osr == nullptr )
282
281
osr = &osr_;
283
282
@@ -286,13 +285,13 @@ int os_detect_blobs(const GenericVector<int>* allowed_scripts,
286
285
ScriptDetector s (allowed_scripts, osr, tess);
287
286
288
287
BLOBNBOX_C_IT filtered_it (blob_list);
289
- int real_max = std::min (filtered_it.length (), kMaxCharactersToTry );
288
+ int real_max = std::min (filtered_it.length (), maxCharactersToTry );
290
289
// tprintf("Total blobs found = %d\n", blobs_total);
291
290
// tprintf("Number of blobs post-filtering = %d\n", filtered_it.length());
292
291
// tprintf("Number of blobs to try = %d\n", real_max);
293
292
294
293
// If there are too few characters, skip this page entirely.
295
- if (real_max < kMinCharactersToTry / 2 ) {
294
+ if (real_max < minCharactersToTry / 2 ) {
296
295
tprintf (" Too few characters. Skipping this page\n " );
297
296
return 0 ;
298
297
}
@@ -307,7 +306,7 @@ int os_detect_blobs(const GenericVector<int>* allowed_scripts,
307
306
int num_blobs_evaluated = 0 ;
308
307
for (int i = 0 ; i < real_max; ++i) {
309
308
if (os_detect_blob (blobs[sequence.GetVal ()], &o, &s, osr, tess)
310
- && i > kMinCharactersToTry ) {
309
+ && i > minCharactersToTry ) {
311
310
break ;
312
311
}
313
312
++num_blobs_evaluated;
0 commit comments