Skip to content

Commit

Permalink
Squash some warnings in MSVC build.
Browse files Browse the repository at this point in the history
In particular, "defined but not used" (caused by GRAPHICS_DISABLED),
double constants being truncated to floats, and implicit casts.
  • Loading branch information
robinwatts committed Jul 16, 2020
1 parent 7fa200b commit 150e2e5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/ccmain/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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; "
Expand Down
4 changes: 2 additions & 2 deletions src/ccstruct/points.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -95,7 +95,7 @@ class ICOORD

///find angle
float angle() const {
return std::atan2(ycoord, xcoord);
return (float)std::atan2(ycoord, xcoord);
}

///test equality
Expand Down
2 changes: 1 addition & 1 deletion src/ccstruct/ratngs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/textord/cjkpitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/textord/oldbasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 5 additions & 5 deletions src/textord/topitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 {
Expand Down

0 comments on commit 150e2e5

Please sign in to comment.