mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-22 09:53:03 +08:00
Merge pull request #2451 from Bharat123rox/lgtm
Some LGTM alert fixes and potential bugfixes
This commit is contained in:
commit
4bab7dd83d
@ -39,7 +39,7 @@ UNICHAR_ID UNICHARMAP::unichar_to_id(const char* const unichar_repr,
|
||||
assert(length > 0 && length <= UNICHAR_LEN);
|
||||
|
||||
int index = 0;
|
||||
if (index >= length || unichar_repr[index] == '\0') return INVALID_UNICHAR_ID;
|
||||
if (length <= 0 || unichar_repr[index] == '\0') return INVALID_UNICHAR_ID;
|
||||
do {
|
||||
if (index + 1 >= length || unichar_repr[index + 1] == '\0')
|
||||
return current_nodes[static_cast<unsigned char>(unichar_repr[index])].id;
|
||||
|
@ -56,6 +56,16 @@ class TrainingArgs(argparse.Namespace):
|
||||
self.extract_font_properties = True
|
||||
self.distort_image = False
|
||||
|
||||
def __eq__(self, other):
|
||||
return (argparse.Namespace.__eq__(self, other) and
|
||||
self.uname == other.uname and self.lang_code == other.lang_code and
|
||||
self.timestamp == other.timestamp and self.font_config_cache == other.font_config_cache and
|
||||
self.fonts_dir == other.fonts_dir and self.max_pages == other.max_pages and
|
||||
self.save_box_tiff == other.save_box_tiff and self.overwrite == other.overwrite and
|
||||
self.linedata == other.linedata and self.run_shape_clustering == other.run_shape_clustering and
|
||||
self.extract_font_properties == other.extract_font_properties and
|
||||
self.distort_image == other.distort_image)
|
||||
|
||||
|
||||
def err_exit(msg):
|
||||
log.critical(msg)
|
||||
@ -356,7 +366,7 @@ def generate_font_image(ctx, font, exposure, char_spacing):
|
||||
|
||||
|
||||
# Phase I : Generate (I)mages from training text for each font.
|
||||
def phase_I_generate_image(ctx, par_factor):
|
||||
def phase_I_generate_image(ctx, par_factor=None):
|
||||
if not par_factor or par_factor <= 0:
|
||||
par_factor = 1
|
||||
|
||||
@ -386,7 +396,7 @@ def phase_I_generate_image(ctx, par_factor):
|
||||
|
||||
with tqdm(
|
||||
total=len(ctx.fonts)
|
||||
) as pbar, concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
|
||||
) as pbar, concurrent.futures.ThreadPoolExecutor(max_workers=par_factor) as executor:
|
||||
futures = [
|
||||
executor.submit(generate_font_image, ctx, font, exposure, char_spacing)
|
||||
for font in ctx.fonts
|
||||
|
Loading…
Reference in New Issue
Block a user