diff --git a/src/ccmain/applybox.cpp b/src/ccmain/applybox.cpp index 15395233fb..25bbe0c4cc 100644 --- a/src/ccmain/applybox.cpp +++ b/src/ccmain/applybox.cpp @@ -2,7 +2,6 @@ * File: applybox.cpp (Formerly applybox.c) * Description: Re segment rows according to box file data * Author: Phil Cheatle - * Created: Wed Nov 24 09:11:23 GMT 1993 * * (C) Copyright 1993, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,9 +21,6 @@ #include #include "allheaders.h" #include "boxread.h" -#ifndef DISABLED_LEGACY_ENGINE -#include "chopper.h" -#endif #include "pageres.h" #include "unichar.h" #include "unicharset.h" diff --git a/src/wordrec/Makefile.am b/src/wordrec/Makefile.am index f8c09f23cb..a3b8e94430 100644 --- a/src/wordrec/Makefile.am +++ b/src/wordrec/Makefile.am @@ -22,7 +22,6 @@ if !DISABLED_LEGACY_ENGINE noinst_HEADERS += \ associate.h \ chop.h \ - chopper.h \ drawfx.h \ findseam.h \ language_model.h \ diff --git a/src/wordrec/chopper.cpp b/src/wordrec/chopper.cpp index f7816f71c2..ce514e6710 100644 --- a/src/wordrec/chopper.cpp +++ b/src/wordrec/chopper.cpp @@ -2,13 +2,7 @@ ******************************************************************************** * * File: chopper.cpp (Formerly chopper.c) - * Description: * Author: Mark Seaman, OCR Technology - * Created: Fri Oct 16 14:37:00 1987 - * Modified: Tue Jul 30 16:18:52 1991 (Mark Seaman) marks@hpgrlt - * Language: C - * Package: N/A - * Status: Reusable Software Component * * (c) Copyright 1987, Hewlett-Packard Company. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +21,6 @@ I n c l u d e s ----------------------------------------------------------------------*/ -#include "chopper.h" #include "blamer.h" // for BlamerBundle, IRR_CORRECT #include "blobs.h" // for TPOINT, TBLOB, EDGEPT, TESSLINE, divisible_blob #include "callcpp.h" // for Red @@ -48,8 +41,6 @@ #include "tprintf.h" // for tprintf #include "wordrec.h" // for Wordrec, SegSearchPending (ptr only) -class CHAR_FRAGMENT; - template class GenericVector; // Include automatically generated configuration file if running autoconf. @@ -64,12 +55,51 @@ static const int kMaxNumChunks = 64; /*---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ + +/** + * @name check_blob + * + * @return true if blob has a non whole outline. + */ +static int check_blob(TBLOB *blob) { + TESSLINE *outline; + EDGEPT *edgept; + + for (outline = blob->outlines; outline != nullptr; outline = outline->next) { + edgept = outline->loop; + do { + if (edgept == nullptr) + break; + edgept = edgept->next; + } + while (edgept != outline->loop); + if (edgept == nullptr) + return 1; + } + return 0; +} + +/** + * @name any_shared_split_points + * + * Return true if any of the splits share a point with this one. + */ +static int any_shared_split_points(const GenericVector& seams, SEAM *seam) { + int length; + int index; + + length = seams.size(); + for (index = 0; index < length; index++) + if (seam->SharesPosition(*seams[index])) return TRUE; + return FALSE; +} + /** * @name preserve_outline_tree * * Copy the list of outlines. */ -void preserve_outline(EDGEPT *start) { +static void preserve_outline(EDGEPT *start) { EDGEPT *srcpt; if (start == nullptr) @@ -83,9 +113,7 @@ void preserve_outline(EDGEPT *start) { srcpt->flags[1] = 2; } - -/**************************************************************************/ -void preserve_outline_tree(TESSLINE *srcline) { +static void preserve_outline_tree(TESSLINE *srcline) { TESSLINE *outline; for (outline = srcline; outline != nullptr; outline = outline->next) { @@ -93,13 +121,12 @@ void preserve_outline_tree(TESSLINE *srcline) { } } - /** * @name restore_outline_tree * * Copy the list of outlines. */ -EDGEPT *restore_outline(EDGEPT *start) { +static EDGEPT *restore_outline(EDGEPT *start) { EDGEPT *srcpt; EDGEPT *real_start; @@ -123,9 +150,7 @@ EDGEPT *restore_outline(EDGEPT *start) { return real_start; } - -/******************************************************************************/ -void restore_outline_tree(TESSLINE *srcline) { +static void restore_outline_tree(TESSLINE *srcline) { TESSLINE *outline; for (outline = srcline; outline != nullptr; outline = outline->next) { @@ -134,6 +159,18 @@ void restore_outline_tree(TESSLINE *srcline) { } } +/********************************************************************** + * total_containment + * + * Check to see if one of these outlines is totally contained within + * the bounding box of the other. + **********************************************************************/ +static int16_t total_containment(TBLOB *blob1, TBLOB *blob2) { + TBOX box1 = blob1->bounding_box(); + TBOX box2 = blob2->bounding_box(); + return box1.contains(box2) || box2.contains(box1); +} + // Helper runs all the checks on a seam to make sure it is valid. // Returns the seam if OK, otherwise deletes the seam and returns nullptr. static SEAM* CheckSeam(int debug_level, int32_t blob_number, TWERD* word, @@ -164,6 +201,7 @@ static SEAM* CheckSeam(int debug_level, int32_t blob_number, TWERD* word, return seam; } +namespace tesseract { /** * @name attempt_blob_chop @@ -171,7 +209,6 @@ static SEAM* CheckSeam(int debug_level, int32_t blob_number, TWERD* word, * Try to split the this blob after this one. Check to make sure that * it was successful. */ -namespace tesseract { SEAM *Wordrec::attempt_blob_chop(TWERD *word, TBLOB *blob, int32_t blob_number, bool italic_blob, const GenericVector& seams) { @@ -276,50 +313,6 @@ SEAM *Wordrec::chop_overlapping_blob(const GenericVector& boxes, return nullptr; } -} // namespace tesseract - - -/** - * @name any_shared_split_points - * - * Return true if any of the splits share a point with this one. - */ -int any_shared_split_points(const GenericVector& seams, SEAM *seam) { - int length; - int index; - - length = seams.size(); - for (index = 0; index < length; index++) - if (seam->SharesPosition(*seams[index])) return TRUE; - return FALSE; -} - - -/** - * @name check_blob - * - * @return true if blob has a non whole outline. - */ -int check_blob(TBLOB *blob) { - TESSLINE *outline; - EDGEPT *edgept; - - for (outline = blob->outlines; outline != nullptr; outline = outline->next) { - edgept = outline->loop; - do { - if (edgept == nullptr) - break; - edgept = edgept->next; - } - while (edgept != outline->loop); - if (edgept == nullptr) - return 1; - } - return 0; -} - - -namespace tesseract { /** * @name improve_one_blob * @@ -644,18 +637,4 @@ int Wordrec::select_blob_to_split_from_fixpt(DANGERR *fixpt) { return -1; } - } // namespace tesseract - - -/********************************************************************** - * total_containment - * - * Check to see if one of these outlines is totally contained within - * the bounding box of the other. - **********************************************************************/ -int16_t total_containment(TBLOB *blob1, TBLOB *blob2) { - TBOX box1 = blob1->bounding_box(); - TBOX box2 = blob2->bounding_box(); - return box1.contains(box2) || box2.contains(box1); -} diff --git a/src/wordrec/chopper.h b/src/wordrec/chopper.h deleted file mode 100644 index f1ebe2e4d9..0000000000 --- a/src/wordrec/chopper.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*-C-*- - ******************************************************************************** - * - * File: chopper.h (Formerly chopper.h) - * Description: - * Author: Mark Seaman, SW Productivity - * Created: Fri Oct 16 14:37:00 1987 - * Modified: Wed May 15 14:24:26 1991 (Mark Seaman) marks@hpgrlt - * Language: C - * Package: N/A - * Status: Reusable Software Component - * - * (c) Copyright 1987, Hewlett-Packard Company. - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** http://www.apache.org/licenses/LICENSE-2.0 - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ** See the License for the specific language governing permissions and - ** limitations under the License. - * - *********************************************************************************/ - -#ifndef CHOPPER_H -#define CHOPPER_H - -#include "matrix.h" -#include "seam.h" -#include "stopper.h" - - -void preserve_outline(EDGEPT *start); - -void preserve_outline_tree(TESSLINE *srcline); - -EDGEPT *restore_outline(EDGEPT *start); - -void restore_outline_tree(TESSLINE *srcline); - -int any_shared_split_points(const GenericVector& seams, SEAM *seam); - -int check_blob(TBLOB *blob); - -int16_t total_containment(TBLOB *blob1, TBLOB *blob2); -#endif diff --git a/src/wordrec/tface.cpp b/src/wordrec/tface.cpp index 0b1aa5e08e..f7181d7d5e 100644 --- a/src/wordrec/tface.cpp +++ b/src/wordrec/tface.cpp @@ -2,7 +2,6 @@ * File: tface.cpp (Formerly tface.c) * Description: C side of the Tess/tessedit C/C++ interface. * Author: Ray Smith - * Created: Mon Apr 27 11:57:06 BST 1992 * * (C) Copyright 1992, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +18,6 @@ #include "callcpp.h" #include "chop.h" -#include "chopper.h" #include "globals.h" #include "pageres.h" #include "wordrec.h"