mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-11 23:19:04 +08:00
Fix some of vector<bool> cases for msvc.
This commit is contained in:
parent
6b22972bc2
commit
c8b8d266d6
@ -309,6 +309,13 @@ class GenericVector : public std::vector<T> {
|
||||
std::function<bool(const T&, const T&)> compare_cb_;
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// msvc does not have ::data() in vector<bool>,
|
||||
// so we add custom specialization
|
||||
template <>
|
||||
class GenericVector<bool> : public std::vector<bool> {};
|
||||
#endif
|
||||
|
||||
// The default FileReader loads the whole file into the vector of char,
|
||||
// returning false on error.
|
||||
inline bool LoadDataFromFile(const char* filename, GenericVector<char>* data) {
|
||||
|
@ -1007,9 +1007,9 @@ void Tesseract::AssignDiacriticsToOverlappingBlobs(
|
||||
GenericVector<bool>* overlapped_any_blob,
|
||||
GenericVector<C_BLOB*>* target_blobs) {
|
||||
GenericVector<bool> blob_wanted;
|
||||
word_wanted->init_to_size(outlines.size(), false);
|
||||
overlapped_any_blob->init_to_size(outlines.size(), false);
|
||||
target_blobs->init_to_size(outlines.size(), nullptr);
|
||||
word_wanted->resize(outlines.size(), false);
|
||||
overlapped_any_blob->resize(outlines.size(), false);
|
||||
target_blobs->resize(outlines.size(), nullptr);
|
||||
// For each real blob, find the outlines that seriously overlap it.
|
||||
// A single blob could be several merged characters, so there can be quite
|
||||
// a few outlines overlapping, and the full engine needs to be used to chop
|
||||
@ -1018,7 +1018,7 @@ void Tesseract::AssignDiacriticsToOverlappingBlobs(
|
||||
for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
|
||||
C_BLOB* blob = blob_it.data();
|
||||
const TBOX blob_box = blob->bounding_box();
|
||||
blob_wanted.init_to_size(outlines.size(), false);
|
||||
blob_wanted.resize(outlines.size(), false);
|
||||
int num_blob_outlines = 0;
|
||||
for (int i = 0; i < outlines.size(); ++i) {
|
||||
if (blob_box.major_x_overlap(outlines[i]->bounding_box()) &&
|
||||
@ -1059,13 +1059,13 @@ void Tesseract::AssignDiacriticsToNewBlobs(
|
||||
PAGE_RES_IT* pr_it, GenericVector<bool>* word_wanted,
|
||||
GenericVector<C_BLOB*>* target_blobs) {
|
||||
GenericVector<bool> blob_wanted;
|
||||
word_wanted->init_to_size(outlines.size(), false);
|
||||
target_blobs->init_to_size(outlines.size(), nullptr);
|
||||
word_wanted->resize(outlines.size(), false);
|
||||
target_blobs->resize(outlines.size(), nullptr);
|
||||
// Check for outlines that need to be turned into stand-alone blobs.
|
||||
for (int i = 0; i < outlines.size(); ++i) {
|
||||
if (outlines[i] == nullptr) continue;
|
||||
// Get a set of adjacent outlines that don't overlap any existing blob.
|
||||
blob_wanted.init_to_size(outlines.size(), false);
|
||||
blob_wanted.resize(outlines.size(), false);
|
||||
int num_blob_outlines = 0;
|
||||
TBOX total_ol_box(outlines[i]->bounding_box());
|
||||
while (i < outlines.size() && outlines[i] != nullptr) {
|
||||
|
@ -372,7 +372,7 @@ void UnicharCompress::ComputeCodeRange() {
|
||||
// Initializes the decoding hash_map from the encoding array.
|
||||
void UnicharCompress::SetupDecoder() {
|
||||
Cleanup();
|
||||
is_valid_start_.init_to_size(code_range_, false);
|
||||
is_valid_start_.resize(code_range_, false);
|
||||
for (int c = 0; c < encoder_.size(); ++c) {
|
||||
const RecodedCharID& code = encoder_[c];
|
||||
decoder_[code] = c;
|
||||
|
Loading…
Reference in New Issue
Block a user