From 150e2e54fe6800a0ff86c732df894a3f4b1bc7cb Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 15 Jul 2020 20:02:33 +0100 Subject: [PATCH] Squash some warnings in MSVC build. In particular, "defined but not used" (caused by GRAPHICS_DISABLED), double constants being truncated to floats, and implicit casts. --- src/ccmain/control.cpp | 5 ++--- src/ccstruct/points.h | 4 ++-- src/ccstruct/ratngs.cpp | 2 +- src/textord/cjkpitch.cpp | 6 +++--- src/textord/oldbasel.cpp | 2 +- src/textord/topitch.cpp | 10 +++++----- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/ccmain/control.cpp b/src/ccmain/control.cpp index bbc01a02..52e4be14 100644 --- a/src/ccmain/control.cpp +++ b/src/ccmain/control.cpp @@ -74,9 +74,6 @@ void Tesseract::recog_pseudo_word(PAGE_RES* page_res, * @param pr_it the page results iterator */ bool Tesseract::recog_interactive(PAGE_RES_IT* pr_it) { - int16_t char_qual; - int16_t good_char_qual; - WordData word_data(*pr_it); SetupWordPassN(2, &word_data); // LSTM doesn't run on pass2, but we want to run pass2 for tesseract. @@ -89,6 +86,8 @@ bool Tesseract::recog_interactive(PAGE_RES_IT* pr_it) { } #ifndef DISABLED_LEGACY_ENGINE if (tessedit_debug_quality_metrics) { + int16_t char_qual; + int16_t good_char_qual; WERD_RES* word_res = pr_it->word(); word_char_quality(word_res, &char_qual, &good_char_qual); tprintf("\n%d chars; word_blob_quality: %d; outline_errs: %d; " diff --git a/src/ccstruct/points.h b/src/ccstruct/points.h index 28cc8461..a6da5a31 100644 --- a/src/ccstruct/points.h +++ b/src/ccstruct/points.h @@ -71,7 +71,7 @@ class ICOORD ///find sq length float sqlength() const { - return xcoord * xcoord + ycoord * ycoord; + return (float)(xcoord * xcoord + ycoord * ycoord); } ///find length @@ -95,7 +95,7 @@ class ICOORD ///find angle float angle() const { - return std::atan2(ycoord, xcoord); + return (float)std::atan2(ycoord, xcoord); } ///test equality diff --git a/src/ccstruct/ratngs.cpp b/src/ccstruct/ratngs.cpp index ca1fafaa..5c2bf252 100644 --- a/src/ccstruct/ratngs.cpp +++ b/src/ccstruct/ratngs.cpp @@ -456,7 +456,7 @@ void WERD_CHOICE::string_and_lengths(STRING *word_str, const char *ch = unicharset_->id_to_unichar_ext(unichar_ids_[i]); *word_str += ch; if (word_lengths_str != nullptr) { - *word_lengths_str += strlen(ch); + *word_lengths_str += (char)strlen(ch); } } } diff --git a/src/textord/cjkpitch.cpp b/src/textord/cjkpitch.cpp index 69c2ca2f..0691c0ad 100644 --- a/src/textord/cjkpitch.cpp +++ b/src/textord/cjkpitch.cpp @@ -32,11 +32,11 @@ static BOOL_VAR(textord_space_size_is_variable, false, namespace { // Allow +/-10% error for character pitch / body size. -static const float kFPTolerance = 0.1; +static const float kFPTolerance = 0.1f; // Minimum ratio of "good" character pitch for a row to be considered // to be fixed-pitch. -static const float kFixedPitchThreshold = 0.35; +static const float kFixedPitchThreshold = 0.35f; // rank statistics for a small collection of float values. class SimpleStats { @@ -1020,7 +1020,7 @@ void FPAnalyzer::EstimatePitch(bool pass1) { } else if (row.num_chars() > 1) { float estimated_pitch = pitch_height_stats.EstimateYFor(row.height() + row.gap(), - 0.1); + 0.1f); // CJK characters are more likely to be fragmented than poorly // chopped. So trust the page-level estimation of character // pitch only if it's larger than row-level estimation or diff --git a/src/textord/oldbasel.cpp b/src/textord/oldbasel.cpp index 833a0ab9..6e014e04 100644 --- a/src/textord/oldbasel.cpp +++ b/src/textord/oldbasel.cpp @@ -583,7 +583,7 @@ float jumplimit /*guess half descenders */ } } - jumplimit *= 1.2; + jumplimit *= 1.2f; /*must be wavy */ if (maxmax - minmin > jumplimit) { ycount = segment; /*no of segments */ diff --git a/src/textord/topitch.cpp b/src/textord/topitch.cpp index e8eaacb9..aeae4045 100644 --- a/src/textord/topitch.cpp +++ b/src/textord/topitch.cpp @@ -417,10 +417,8 @@ bool try_doc_fixed( //determine pitch int16_t projection_right; int16_t row_left; //edges of row int16_t row_right; - ICOORDELT_LIST *master_cells; //cells for page float master_y; //uniform shifts float shift_factor; //page skew correction - float row_shift; //shift for row float final_pitch; //output pitch float row_y; //baseline STATS projection; //entire page @@ -512,13 +510,15 @@ bool try_doc_fixed( //determine pitch #ifndef GRAPHICS_DISABLED if (textord_show_page_cuts && to_win != nullptr) { + float row_shift; //shift for row + ICOORDELT_LIST *master_cells; //cells for page master_cells = &row->char_cells; for (block_it.mark_cycle_pt (); !block_it.cycled_list (); block_it.forward ()) { block = block_it.data (); row_it.set_to_list (block->get_rows ()); for (row_it.mark_cycle_pt (); !row_it.cycled_list (); - row_it.forward ()) { + row_it.forward ()) { row = row_it.data (); row_y = row->baseline.y (master_x); row_shift = shift_factor * (master_y - row_y); @@ -871,7 +871,7 @@ bool find_row_pitch( //find lines if (!count_pitch_stats (row, &gap_stats, &pitch_stats, initial_pitch, min_space, true, false, dm_gap)) { - dm_gap_iqr = 0.0001; + dm_gap_iqr = 0.0001f; dm_pitch_iqr = maxwidth * 2.0f; dm_pitch = initial_pitch; } @@ -884,7 +884,7 @@ bool find_row_pitch( //find lines pitch_stats.clear (); if (!count_pitch_stats (row, &gap_stats, &pitch_stats, initial_pitch, min_space, true, false, 0)) { - gap_iqr = 0.0001; + gap_iqr = 0.0001f; pitch_iqr = maxwidth * 3.0f; } else {