Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/src/wordrec/wordclass.cpp @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /****************************************************************************** | |
| 2 * | |
| 3 * File: wordclass.cpp (Formerly wordclass.c) | |
| 4 * Description: Word classifier | |
| 5 * Author: Mark Seaman, OCR Technology | |
| 6 * | |
| 7 * (c) Copyright 1990, Hewlett-Packard Company. | |
| 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 I N C L U D E S | |
| 21 ----------------------------------------------------------------------*/ | |
| 22 | |
| 23 #include "blamer.h" // for blamer_bundle | |
| 24 #include "params.h" // for BoolParam | |
| 25 #include "render.h" // for display_blob, blob_window, wordrec_blob_pause | |
| 26 #include "wordrec.h" // for Wordrec | |
| 27 | |
| 28 struct TBLOB; | |
| 29 | |
| 30 // Include automatically generated configuration file if running autoconf. | |
| 31 #ifdef HAVE_CONFIG_H | |
| 32 # include "config_auto.h" | |
| 33 #endif | |
| 34 | |
| 35 /*---------------------------------------------------------------------- | |
| 36 F u n c t i o n s | |
| 37 ----------------------------------------------------------------------*/ | |
| 38 namespace tesseract { | |
| 39 /** | |
| 40 * @name classify_blob | |
| 41 * | |
| 42 * Classify the this blob if it is not already recorded in the match | |
| 43 * table. Attempt to recognize this blob as a character. The recognition | |
| 44 * rating for this blob will be stored as a part of the blob. This value | |
| 45 * will also be returned to the caller. | |
| 46 * @param blob Current blob | |
| 47 * @param string The string to display in ScrollView | |
| 48 * @param color The colour to use when displayed with ScrollView | |
| 49 */ | |
| 50 BLOB_CHOICE_LIST *Wordrec::classify_blob(TBLOB *blob, const char *string, ScrollView::Color color, | |
| 51 BlamerBundle *blamer_bundle) { | |
| 52 #ifndef GRAPHICS_DISABLED | |
| 53 if (wordrec_display_all_blobs) { | |
| 54 display_blob(blob, color); | |
| 55 } | |
| 56 #endif | |
| 57 // TODO(rays) collapse with call_matcher and move all to wordrec.cpp. | |
| 58 BLOB_CHOICE_LIST *choices = call_matcher(blob); | |
| 59 // If a blob with the same bounding box as one of the truth character | |
| 60 // bounding boxes is not classified as the corresponding truth character | |
| 61 // blame character classifier for incorrect answer. | |
| 62 if (blamer_bundle != nullptr) { | |
| 63 blamer_bundle->BlameClassifier(getDict().getUnicharset(), blob->bounding_box(), *choices, | |
| 64 wordrec_debug_blamer); | |
| 65 } | |
| 66 #ifndef GRAPHICS_DISABLED | |
| 67 if (classify_debug_level && string) { | |
| 68 print_ratings_list(string, choices, getDict().getUnicharset()); | |
| 69 } | |
| 70 | |
| 71 if (wordrec_blob_pause) { | |
| 72 blob_window->Wait(); | |
| 73 } | |
| 74 #endif | |
| 75 | |
| 76 return choices; | |
| 77 } | |
| 78 | |
| 79 } // namespace tesseract |
