mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +08:00
Fix some compiler warnings
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
d72c2b14a5
commit
67dcbdda2f
@ -131,7 +131,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0, const std::str
|
||||
// Set params specified in vars_vec (done after setting params from config
|
||||
// files, so that params in vars_vec can override those from files).
|
||||
if (vars_vec != nullptr && vars_values != nullptr) {
|
||||
for (int i = 0; i < vars_vec->size(); ++i) {
|
||||
for (unsigned i = 0; i < vars_vec->size(); ++i) {
|
||||
if (!ParamUtils::SetParam((*vars_vec)[i].c_str(), (*vars_values)[i].c_str(),
|
||||
set_params_constraint, this->params())) {
|
||||
tprintf("Warning: The parameter '%s' was not found.\n", (*vars_vec)[i].c_str());
|
||||
@ -296,7 +296,7 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba
|
||||
// Add any languages that this language requires
|
||||
bool loaded_primary = false;
|
||||
// Load the rest into sub_langs_.
|
||||
for (int lang_index = 0; lang_index < langs_to_load.size(); ++lang_index) {
|
||||
for (unsigned lang_index = 0; lang_index < langs_to_load.size(); ++lang_index) {
|
||||
if (!IsStrInList(langs_to_load[lang_index], langs_not_to_load)) {
|
||||
const char *lang_str = langs_to_load[lang_index].c_str();
|
||||
Tesseract *tess_to_init;
|
||||
|
@ -268,7 +268,7 @@ void LSTMRecognizer::RecognizeLine(const ImageData &image_data, bool invert, boo
|
||||
search_->extractSymbolChoices(&GetUnicharset());
|
||||
}
|
||||
search_->segmentTimestepsByCharacters();
|
||||
int char_it = 0;
|
||||
unsigned char_it = 0;
|
||||
for (int i = 0; i < words->size(); ++i) {
|
||||
for (int j = 0; j < words->at(i)->end; ++j) {
|
||||
if (char_it < search_->ctc_choices.size()) {
|
||||
@ -386,8 +386,8 @@ bool LSTMRecognizer::RecognizeLine(const ImageData &image_data, bool invert, boo
|
||||
// augmented with character boundaries.
|
||||
std::string LSTMRecognizer::DecodeLabels(const std::vector<int> &labels) {
|
||||
std::string result;
|
||||
int end = 1;
|
||||
for (int start = 0; start < labels.size(); start = end) {
|
||||
unsigned end = 1;
|
||||
for (unsigned start = 0; start < labels.size(); start = end) {
|
||||
if (labels[start] == null_char_) {
|
||||
end = start + 1;
|
||||
} else {
|
||||
@ -417,8 +417,8 @@ void LSTMRecognizer::DisplayLSTMOutput(const std::vector<int> &labels,
|
||||
ScrollView *window) {
|
||||
int x_scale = network_->XScaleFactor();
|
||||
window->TextAttributes("Arial", height / 4, false, false, false);
|
||||
int end = 1;
|
||||
for (int start = 0; start < labels.size(); start = end) {
|
||||
unsigned end = 1;
|
||||
for (unsigned start = 0; start < labels.size(); start = end) {
|
||||
int xpos = xcoords[start] * x_scale;
|
||||
if (labels[start] == null_char_) {
|
||||
end = start + 1;
|
||||
@ -446,8 +446,8 @@ void LSTMRecognizer::DebugActivationPath(const NetworkIO &outputs, const std::ve
|
||||
if (xcoords[0] > 0) {
|
||||
DebugActivationRange(outputs, "<null>", null_char_, 0, xcoords[0]);
|
||||
}
|
||||
int end = 1;
|
||||
for (int start = 0; start < labels.size(); start = end) {
|
||||
unsigned end = 1;
|
||||
for (unsigned start = 0; start < labels.size(); start = end) {
|
||||
if (labels[start] == null_char_) {
|
||||
end = start + 1;
|
||||
DebugActivationRange(outputs, "<null>", null_char_, xcoords[start], xcoords[end]);
|
||||
@ -456,7 +456,7 @@ void LSTMRecognizer::DebugActivationPath(const NetworkIO &outputs, const std::ve
|
||||
int decoded;
|
||||
const char *label = DecodeLabel(labels, start, &end, &decoded);
|
||||
DebugActivationRange(outputs, label, labels[start], xcoords[start], xcoords[start + 1]);
|
||||
for (int i = start + 1; i < end; ++i) {
|
||||
for (unsigned i = start + 1; i < end; ++i) {
|
||||
DebugActivationRange(outputs, DecodeSingleLabel(labels[i]), labels[i], xcoords[i],
|
||||
xcoords[i + 1]);
|
||||
}
|
||||
@ -550,7 +550,7 @@ void LSTMRecognizer::LabelsViaSimpleText(const NetworkIO &output, std::vector<in
|
||||
|
||||
// Returns a string corresponding to the label starting at start. Sets *end
|
||||
// to the next start and if non-null, *decoded to the unichar id.
|
||||
const char *LSTMRecognizer::DecodeLabel(const std::vector<int> &labels, int start, int *end,
|
||||
const char *LSTMRecognizer::DecodeLabel(const std::vector<int> &labels, unsigned start, unsigned *end,
|
||||
int *decoded) {
|
||||
*end = start + 1;
|
||||
if (IsRecoding()) {
|
||||
@ -563,7 +563,7 @@ const char *LSTMRecognizer::DecodeLabel(const std::vector<int> &labels, int star
|
||||
}
|
||||
return "<null>";
|
||||
}
|
||||
int index = start;
|
||||
unsigned index = start;
|
||||
while (index < labels.size() && code.length() < RecodedCharID::kMaxCodeLen) {
|
||||
code.Set(code.length(), labels[index++]);
|
||||
while (index < labels.size() && labels[index] == null_char_) {
|
||||
|
@ -297,7 +297,7 @@ protected:
|
||||
|
||||
// Returns a string corresponding to the label starting at start. Sets *end
|
||||
// to the next start and if non-null, *decoded to the unichar id.
|
||||
const char *DecodeLabel(const std::vector<int> &labels, int start, int *end, int *decoded);
|
||||
const char *DecodeLabel(const std::vector<int> &labels, unsigned start, unsigned *end, int *decoded);
|
||||
|
||||
// Returns a string corresponding to a given single label id, falling back to
|
||||
// a default of ".." for part of a multi-label unichar-id.
|
||||
|
@ -187,7 +187,7 @@ TEST_F(LSTMTrainerTest, TestLayerAccess) {
|
||||
// A 2-layer LSTM with a Squashed feature-extracting LSTM on the bottom.
|
||||
SetupTrainerEng("[1,32,0,1 Ct5,5,16 Mp2,2 Lfys32 Lbx128 O1c1]", "SQU-lstm", false, false);
|
||||
// Number of layers.
|
||||
const int kNumLayers = 8;
|
||||
const size_t kNumLayers = 8;
|
||||
// Expected layer names.
|
||||
const char *kLayerIds[kNumLayers] = {":0", ":1:0", ":1:1", ":2", ":3:0", ":4:0", ":4:1:0", ":5"};
|
||||
const char *kLayerNames[kNumLayers] = {"Input", "Convolve", "ConvNL", "Maxpool",
|
||||
@ -204,7 +204,7 @@ TEST_F(LSTMTrainerTest, TestLayerAccess) {
|
||||
|
||||
auto layers = trainer_->EnumerateLayers();
|
||||
EXPECT_EQ(kNumLayers, layers.size());
|
||||
for (int i = 0; i < kNumLayers && i < layers.size(); ++i) {
|
||||
for (unsigned i = 0; i < kNumLayers && i < layers.size(); ++i) {
|
||||
EXPECT_STREQ(kLayerIds[i], layers[i].c_str());
|
||||
EXPECT_STREQ(kLayerNames[i], trainer_->GetLayer(layers[i])->name().c_str());
|
||||
EXPECT_EQ(kNumWeights[i], trainer_->GetLayer(layers[i])->num_weights());
|
||||
|
@ -185,7 +185,7 @@ protected:
|
||||
std::vector<int> output_copy(output);
|
||||
std::sort(output_copy.begin(), output_copy.end());
|
||||
bool sane = true;
|
||||
int j = 0;
|
||||
unsigned j = 0;
|
||||
while (j < output_copy.size() && output_copy[j] < 0) {
|
||||
j++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user