Skip to content

Commit

Permalink
Fix some compiler warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Mar 22, 2021
1 parent d72c2b1 commit 67dcbdd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/ccmain/tessedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions src/lstm/lstmrecognizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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()) {
Expand All @@ -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_) {
Expand Down
2 changes: 1 addition & 1 deletion src/lstm/lstmrecognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class TESS_API LSTMRecognizer {

// 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.
Expand Down
4 changes: 2 additions & 2 deletions unittest/lstm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion unittest/resultiterator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class ResultIteratorTest : public testing::Test {
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++;
}
Expand Down

0 comments on commit 67dcbdd

Please sign in to comment.