Merge pull request #3203 from stweil/std-vector

Replace more GenericVector by std::vector and clean include statements
This commit is contained in:
Egor Pugin 2020-12-30 13:28:55 +03:00 committed by GitHub
commit 3b83b061e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 23 additions and 42 deletions

View File

@ -18,12 +18,11 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config_auto.h" #include "config_auto.h"
#endif #endif
#include "serialis.h" // Serialize
#include <cstring> #include <cstring>
#include <memory> // std::unique_ptr #include <memory> // std::unique_ptr
#include <string> // std::string #include <string> // std::string
#include <tesseract/baseapi.h> #include <tesseract/baseapi.h>
#include "genericvector.h"
#include <tesseract/renderer.h> #include <tesseract/renderer.h>
namespace tesseract { namespace tesseract {

View File

@ -1006,7 +1006,7 @@ void Tesseract::AssignDiacriticsToOverlappingBlobs(
PAGE_RES_IT* pr_it, GenericVector<bool>* word_wanted, PAGE_RES_IT* pr_it, GenericVector<bool>* word_wanted,
GenericVector<bool>* overlapped_any_blob, GenericVector<bool>* overlapped_any_blob,
GenericVector<C_BLOB*>* target_blobs) { GenericVector<C_BLOB*>* target_blobs) {
GenericVector<bool> blob_wanted; std::vector<bool> blob_wanted;
word_wanted->resize(outlines.size(), false); word_wanted->resize(outlines.size(), false);
overlapped_any_blob->resize(outlines.size(), false); overlapped_any_blob->resize(outlines.size(), false);
target_blobs->resize(outlines.size(), nullptr); target_blobs->resize(outlines.size(), nullptr);
@ -1058,7 +1058,7 @@ void Tesseract::AssignDiacriticsToNewBlobs(
const GenericVector<C_OUTLINE*>& outlines, int pass, WERD* real_word, const GenericVector<C_OUTLINE*>& outlines, int pass, WERD* real_word,
PAGE_RES_IT* pr_it, GenericVector<bool>* word_wanted, PAGE_RES_IT* pr_it, GenericVector<bool>* word_wanted,
GenericVector<C_BLOB*>* target_blobs) { GenericVector<C_BLOB*>* target_blobs) {
GenericVector<bool> blob_wanted; std::vector<bool> blob_wanted;
word_wanted->resize(outlines.size(), false); word_wanted->resize(outlines.size(), false);
target_blobs->resize(outlines.size(), nullptr); target_blobs->resize(outlines.size(), nullptr);
// Check for outlines that need to be turned into stand-alone blobs. // Check for outlines that need to be turned into stand-alone blobs.
@ -1133,7 +1133,7 @@ void Tesseract::AssignDiacriticsToNewBlobs(
bool Tesseract::SelectGoodDiacriticOutlines( bool Tesseract::SelectGoodDiacriticOutlines(
int pass, float certainty_threshold, PAGE_RES_IT* pr_it, C_BLOB* blob, int pass, float certainty_threshold, PAGE_RES_IT* pr_it, C_BLOB* blob,
const GenericVector<C_OUTLINE*>& outlines, int num_outlines, const GenericVector<C_OUTLINE*>& outlines, int num_outlines,
GenericVector<bool>* ok_outlines) { std::vector<bool>* ok_outlines) {
STRING best_str; STRING best_str;
float target_cert = certainty_threshold; float target_cert = certainty_threshold;
if (blob != nullptr) { if (blob != nullptr) {
@ -1146,10 +1146,10 @@ bool Tesseract::SelectGoodDiacriticOutlines(
} }
target_cert -= (target_cert - certainty_threshold) * noise_cert_factor; target_cert -= (target_cert - certainty_threshold) * noise_cert_factor;
} }
GenericVector<bool> test_outlines = *ok_outlines; std::vector<bool> test_outlines = *ok_outlines;
// Start with all the outlines in. // Start with all the outlines in.
STRING all_str; STRING all_str;
GenericVector<bool> best_outlines = *ok_outlines; std::vector<bool> best_outlines = *ok_outlines;
float best_cert = ClassifyBlobPlusOutlines(test_outlines, outlines, pass, float best_cert = ClassifyBlobPlusOutlines(test_outlines, outlines, pass,
pr_it, blob, &all_str); pr_it, blob, &all_str);
if (debug_noise_removal) { if (debug_noise_removal) {
@ -1217,7 +1217,7 @@ bool Tesseract::SelectGoodDiacriticOutlines(
// Classifies the given blob plus the outlines flagged by ok_outlines, undoes // Classifies the given blob plus the outlines flagged by ok_outlines, undoes
// the inclusion of the outlines, and returns the certainty of the raw choice. // the inclusion of the outlines, and returns the certainty of the raw choice.
float Tesseract::ClassifyBlobPlusOutlines( float Tesseract::ClassifyBlobPlusOutlines(
const GenericVector<bool>& ok_outlines, const std::vector<bool>& ok_outlines,
const GenericVector<C_OUTLINE*>& outlines, int pass_n, PAGE_RES_IT* pr_it, const GenericVector<C_OUTLINE*>& outlines, int pass_n, PAGE_RES_IT* pr_it,
C_BLOB* blob, STRING* best_str) { C_BLOB* blob, STRING* best_str) {
C_OUTLINE_IT ol_it; C_OUTLINE_IT ol_it;

View File

@ -428,10 +428,10 @@ class Tesseract : public Wordrec {
PAGE_RES_IT* pr_it, C_BLOB* blob, PAGE_RES_IT* pr_it, C_BLOB* blob,
const GenericVector<C_OUTLINE*>& outlines, const GenericVector<C_OUTLINE*>& outlines,
int num_outlines, int num_outlines,
GenericVector<bool>* ok_outlines); std::vector<bool>* ok_outlines);
// Classifies the given blob plus the outlines flagged by ok_outlines, undoes // Classifies the given blob plus the outlines flagged by ok_outlines, undoes
// the inclusion of the outlines, and returns the certainty of the raw choice. // the inclusion of the outlines, and returns the certainty of the raw choice.
float ClassifyBlobPlusOutlines(const GenericVector<bool>& ok_outlines, float ClassifyBlobPlusOutlines(const std::vector<bool>& ok_outlines,
const GenericVector<C_OUTLINE*>& outlines, const GenericVector<C_OUTLINE*>& outlines,
int pass_n, PAGE_RES_IT* pr_it, C_BLOB* blob, int pass_n, PAGE_RES_IT* pr_it, C_BLOB* blob,
STRING* best_str); STRING* best_str);

View File

@ -19,8 +19,8 @@
#ifndef TESSERACT_CCUTIL_GENERICVECTOR_H_ #ifndef TESSERACT_CCUTIL_GENERICVECTOR_H_
#define TESSERACT_CCUTIL_GENERICVECTOR_H_ #define TESSERACT_CCUTIL_GENERICVECTOR_H_
#include <tesseract/helpers.h>
#include "serialis.h" #include "serialis.h"
#include <tesseract/helpers.h>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>

View File

@ -21,8 +21,6 @@
#include "host.h" // tesseract/platform.h, windows.h for MAX_PATH #include "host.h" // tesseract/platform.h, windows.h for MAX_PATH
#include "tprintf.h" #include "tprintf.h"
#include "genericvector.h"
#include <climits> // for INT_MIN, INT_MAX #include <climits> // for INT_MIN, INT_MAX
#include <cmath> // for NAN, std::isnan #include <cmath> // for NAN, std::isnan
#include <cstdio> #include <cstdio>

View File

@ -16,10 +16,9 @@
// //
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
#include <tesseract/unichar.h>
#include "errcode.h" #include "errcode.h"
#include "genericvector.h"
#include "tprintf.h" #include "tprintf.h"
#include <tesseract/unichar.h>
#define UNI_MAX_LEGAL_UTF32 0x0010FFFF #define UNI_MAX_LEGAL_UTF32 0x0010FFFF

View File

@ -60,9 +60,9 @@
#include "unicity_table.h" // for UnicityTable #include "unicity_table.h" // for UnicityTable
#include "genericvector.h" // for GenericVector #include "genericvector.h" // for GenericVector
#include <tesseract/helpers.h> // for IntCastRounded, ClipToRange
#include "serialis.h" // for TFile #include "serialis.h" // for TFile
#include "strngs.h" // for STRING #include "strngs.h" // for STRING
#include <tesseract/helpers.h> // for IntCastRounded, ClipToRange
#include <tesseract/unichar.h> // for UNICHAR_ID, INVALID_UNICHAR_ID #include <tesseract/unichar.h> // for UNICHAR_ID, INVALID_UNICHAR_ID
#include <algorithm> // for max, min #include <algorithm> // for max, min

View File

@ -36,7 +36,6 @@
#include "shapetable.h" #include "shapetable.h"
#include "svmnode.h" #include "svmnode.h"
#include "genericvector.h"
#include <tesseract/helpers.h> #include <tesseract/helpers.h>
#include <algorithm> #include <algorithm>

View File

@ -2,7 +2,6 @@
** Filename: intproto.h ** Filename: intproto.h
** Purpose: Definition of data structures for integer protos. ** Purpose: Definition of data structures for integer protos.
** Author: Dan Johnson ** Author: Dan Johnson
** History: Thu Feb 7 12:58:45 1991, DSJ, Created.
** **
** (c) Copyright Hewlett-Packard Company, 1988. ** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -28,8 +27,6 @@
#include "scrollview.h" #include "scrollview.h"
#include "unicharset.h" #include "unicharset.h"
#include "genericvector.h"
namespace tesseract { namespace tesseract {
class FCOORD; class FCOORD;

View File

@ -20,7 +20,6 @@
#ifndef TESSERACT_LSTM_CONVOLVE_H_ #ifndef TESSERACT_LSTM_CONVOLVE_H_
#define TESSERACT_LSTM_CONVOLVE_H_ #define TESSERACT_LSTM_CONVOLVE_H_
#include "genericvector.h"
#include "matrix.h" #include "matrix.h"
#include "network.h" #include "network.h"

View File

@ -20,12 +20,10 @@
#include "matrix.h" #include "matrix.h"
#include "networkio.h" #include "networkio.h"
#include "static_shape.h"
#include "tprintf.h"
#include "serialis.h" #include "serialis.h"
#include "static_shape.h"
#include "strngs.h" // for STRING #include "strngs.h" // for STRING
#include "genericvector.h" #include "tprintf.h"
#include <tesseract/helpers.h> #include <tesseract/helpers.h>
#include <cstdio> #include <cstdio>

View File

@ -19,7 +19,6 @@
#ifndef TESSERACT_LSTM_RECONFIG_H_ #ifndef TESSERACT_LSTM_RECONFIG_H_
#define TESSERACT_LSTM_RECONFIG_H_ #define TESSERACT_LSTM_RECONFIG_H_
#include "genericvector.h"
#include "matrix.h" #include "matrix.h"
#include "network.h" #include "network.h"

View File

@ -21,17 +21,16 @@
#include "boxchar.h" #include "boxchar.h"
#include <cstddef>
#include <algorithm>
#include <vector>
#include "fileio.h" #include "fileio.h"
#include "genericvector.h"
#include "normstrngs.h" #include "normstrngs.h"
#include "tprintf.h" #include "tprintf.h"
#include "unicharset.h" #include "unicharset.h"
#include "unicode/uchar.h" // from libicu #include "unicode/uchar.h" // from libicu
#include <algorithm>
#include <cstddef>
#include <vector>
// Absolute Ratio of dx:dy or dy:dx to be a newline. // Absolute Ratio of dx:dy or dy:dx to be a newline.
const int kMinNewlineRatio = 5; const int kMinNewlineRatio = 5;

View File

@ -15,12 +15,11 @@
#ifndef TESSERACT_TRAINING_LANG_MODEL_HELPERS_H_ #ifndef TESSERACT_TRAINING_LANG_MODEL_HELPERS_H_
#define TESSERACT_TRAINING_LANG_MODEL_HELPERS_H_ #define TESSERACT_TRAINING_LANG_MODEL_HELPERS_H_
#include <string>
#include "genericvector.h"
#include "serialis.h" #include "serialis.h"
#include "strngs.h" #include "strngs.h"
#include "tessdatamanager.h" #include "tessdatamanager.h"
#include "unicharset.h" #include "unicharset.h"
#include <string>
namespace tesseract { namespace tesseract {

View File

@ -18,10 +18,10 @@
#ifndef TESSERACT_TRAINING_LSTMTESTER_H_ #ifndef TESSERACT_TRAINING_LSTMTESTER_H_
#define TESSERACT_TRAINING_LSTMTESTER_H_ #define TESSERACT_TRAINING_LSTMTESTER_H_
#include <mutex>
#include "genericvector.h"
#include "lstmtrainer.h" #include "lstmtrainer.h"
#include "strngs.h" #include "strngs.h"
#include <mutex>
#include <vector>
namespace tesseract { namespace tesseract {

View File

@ -36,7 +36,6 @@
#include "commontraining.h" #include "commontraining.h"
#include "featdefs.h" #include "featdefs.h"
#include "fontinfo.h" #include "fontinfo.h"
#include "genericvector.h"
#include "indexmapbidi.h" #include "indexmapbidi.h"
#include "intproto.h" #include "intproto.h"
#include "mastertrainer.h" #include "mastertrainer.h"

View File

@ -20,16 +20,15 @@
// normalizes the text according to command-line options and generates // normalizes the text according to command-line options and generates
// a unicharset. // a unicharset.
#include <cstdlib>
#include "boxread.h" #include "boxread.h"
#include "commandlineflags.h" #include "commandlineflags.h"
#include "commontraining.h" // CheckSharedLibraryVersion #include "commontraining.h" // CheckSharedLibraryVersion
#include "genericvector.h"
#include "lang_model_helpers.h" #include "lang_model_helpers.h"
#include "normstrngs.h" #include "normstrngs.h"
#include "strngs.h" #include "strngs.h"
#include "unicharset.h" #include "unicharset.h"
#include "unicharset_training_utils.h" #include "unicharset_training_utils.h"
#include <cstdlib>
using namespace tesseract; using namespace tesseract;

View File

@ -23,13 +23,12 @@
#include "associate.h" // for AssociateStats #include "associate.h" // for AssociateStats
#include "dawg.h" // for DawgPositionVector #include "dawg.h" // for DawgPositionVector
#include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK #include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK
#include "genericvector.h" // for PointerVector
#include "lm_consistency.h" // for LMConsistencyInfo #include "lm_consistency.h" // for LMConsistencyInfo
#include "ratngs.h" // for BLOB_CHOICE, PermuterType #include "ratngs.h" // for BLOB_CHOICE, PermuterType
#include "stopper.h" // for DANGERR #include "stopper.h" // for DANGERR
#include "strngs.h" // for STRING #include "strngs.h" // for STRING
#include <tesseract/unichar.h> // for UNICHAR_ID
#include "unicharset.h" // for UNICHARSET #include "unicharset.h" // for UNICHARSET
#include <tesseract/unichar.h> // for UNICHAR_ID
namespace tesseract { namespace tesseract {

View File

@ -15,7 +15,6 @@
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
#include "matrix.h" #include "matrix.h"
#include "genericvector.h"
#include "include_gunit.h" #include "include_gunit.h"
namespace tesseract { namespace tesseract {

View File

@ -9,7 +9,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "genericvector.h"
#include "kdpair.h" #include "kdpair.h"
#include "include_gunit.h" #include "include_gunit.h"