mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
Merge pull request #4174 from stweil/warnings
Fix some compiler warnings and avoid unnecessary conversions from std::string to char pointer
This commit is contained in:
commit
637be531f6
@ -76,7 +76,7 @@ FILE *OpenBoxFile(const char *fname) {
|
||||
bool ReadAllBoxes(int target_page, bool skip_blanks, const char *filename, std::vector<TBOX> *boxes,
|
||||
std::vector<std::string> *texts, std::vector<std::string> *box_texts,
|
||||
std::vector<int> *pages) {
|
||||
std::ifstream input(BoxFileName(filename).c_str(), std::ios::in | std::ios::binary);
|
||||
std::ifstream input(BoxFileName(filename), std::ios::in | std::ios::binary);
|
||||
if (input.fail()) {
|
||||
tprintf("Cannot read box data from '%s'.\n", BoxFileName(filename).c_str());
|
||||
tprintf("Does it exists?\n");
|
||||
|
@ -316,9 +316,7 @@ double check_pitch_sync2( // find segmentation
|
||||
TBOX this_box; // bounding box
|
||||
TBOX next_box; // box of next blob
|
||||
FPSEGPT *segpt; // segment point
|
||||
double best_cost; // best path
|
||||
double mean_sum; // computes result
|
||||
FPCUTPT *best_end; // end of best path
|
||||
int16_t best_fake; // best fake level
|
||||
int16_t best_count; // no of cuts
|
||||
BLOBNBOX_IT this_it; // copy iterator
|
||||
@ -371,8 +369,6 @@ double check_pitch_sync2( // find segmentation
|
||||
}
|
||||
|
||||
this_it = *blob_it;
|
||||
best_cost = FLT_MAX;
|
||||
best_end = nullptr;
|
||||
this_box = box_next(&this_it); // first box
|
||||
next_box = box_next(&this_it); // second box
|
||||
blob_index = 1;
|
||||
@ -411,7 +407,8 @@ double check_pitch_sync2( // find segmentation
|
||||
}
|
||||
|
||||
best_fake = INT16_MAX;
|
||||
best_cost = INT32_MAX;
|
||||
// best path
|
||||
double best_cost = INT32_MAX;
|
||||
best_count = INT16_MAX;
|
||||
while (x < right_edge + pitch) {
|
||||
offset = x < right_edge ? right_edge - x : 0;
|
||||
@ -438,7 +435,8 @@ double check_pitch_sync2( // find segmentation
|
||||
}
|
||||
ASSERT_HOST(best_fake < INT16_MAX);
|
||||
|
||||
best_end = &cutpts[(best_left_x + best_right_x) / 2 - array_origin];
|
||||
// end of best path
|
||||
FPCUTPT *best_end = &cutpts[(best_left_x + best_right_x) / 2 - array_origin];
|
||||
if (this_box.right() == textord_test_x && this_box.top() == textord_test_y) {
|
||||
for (x = left_edge - pitch; x < right_edge + pitch; x++) {
|
||||
tprintf("x=%d, C=%g, s=%g, sq=%g, prev=%d\n", x, cutpts[x - array_origin].cost_function(),
|
||||
@ -509,9 +507,7 @@ double check_pitch_sync3( // find segmentation
|
||||
FPSEGPT *segpt; // segment point
|
||||
int minindex; // next input position
|
||||
int test_index; // index to mins
|
||||
double best_cost; // best path
|
||||
double mean_sum; // computes result
|
||||
FPCUTPT *best_end; // end of best path
|
||||
int16_t best_fake; // best fake level
|
||||
int16_t best_count; // no of cuts
|
||||
FPSEGPT_IT seg_it = seg_list; // output iterator
|
||||
@ -549,8 +545,6 @@ double check_pitch_sync3( // find segmentation
|
||||
offset);
|
||||
}
|
||||
|
||||
best_cost = FLT_MAX;
|
||||
best_end = nullptr;
|
||||
for (offset = -pitch_error, minindex = 0; offset < pitch_error; offset++, minindex++) {
|
||||
mins[minindex] = projection->local_min(x + offset);
|
||||
}
|
||||
@ -629,7 +623,8 @@ double check_pitch_sync3( // find segmentation
|
||||
}
|
||||
|
||||
best_fake = INT16_MAX;
|
||||
best_cost = INT32_MAX;
|
||||
// best path
|
||||
double best_cost = INT32_MAX;
|
||||
best_count = INT16_MAX;
|
||||
while (x < right_edge + pitch) {
|
||||
offset = x < right_edge ? right_edge - x : 0;
|
||||
@ -656,7 +651,8 @@ double check_pitch_sync3( // find segmentation
|
||||
}
|
||||
ASSERT_HOST(best_fake < INT16_MAX);
|
||||
|
||||
best_end = &cutpts[(best_left_x + best_right_x) / 2 - array_origin];
|
||||
// end of best path
|
||||
FPCUTPT *best_end = &cutpts[(best_left_x + best_right_x) / 2 - array_origin];
|
||||
// for (x=left_edge-pitch;x<right_edge+pitch;x++)
|
||||
// {
|
||||
// tprintf("x=%d, C=%g, s=%g, sq=%g, prev=%d\n",
|
||||
|
@ -283,10 +283,8 @@ void Textord::row_spacing_stats(TO_ROW *row, GAPMAP *gapmap, int16_t block_idx,
|
||||
int16_t gap_width;
|
||||
int16_t real_space_threshold = 0;
|
||||
int16_t max = 0;
|
||||
int16_t index;
|
||||
int16_t large_gap_count = 0;
|
||||
bool suspected_table;
|
||||
int32_t max_max_nonspace; // upper bound
|
||||
bool good_block_space_estimate = block_space_gap_width > 0;
|
||||
int32_t end_of_row;
|
||||
int32_t row_length = 0;
|
||||
@ -479,11 +477,12 @@ number of samples can be taken as certain kerns.
|
||||
below the threshold.
|
||||
*/
|
||||
|
||||
max_max_nonspace = int32_t((row->space_threshold + row->kern_size) / 2);
|
||||
// upper bound
|
||||
int32_t max_max_nonspace = int32_t((row->space_threshold + row->kern_size) / 2);
|
||||
|
||||
// default
|
||||
row->max_nonspace = max_max_nonspace;
|
||||
for (index = 0; index <= max_max_nonspace; index++) {
|
||||
for (int32_t index = 0; index <= max_max_nonspace; index++) {
|
||||
if (all_gap_stats.pile_count(index) > max) {
|
||||
max = all_gap_stats.pile_count(index);
|
||||
}
|
||||
|
@ -211,13 +211,11 @@ void vertical_cunderline_projection( // project outlines
|
||||
ICOORD pos; // current point
|
||||
ICOORD step; // edge step
|
||||
int16_t lower_y, upper_y; // region limits
|
||||
int32_t length; // of outline
|
||||
int16_t stepindex; // current step
|
||||
C_OUTLINE_IT out_it = outline->child();
|
||||
|
||||
pos = outline->start_pos();
|
||||
length = outline->pathlength();
|
||||
for (stepindex = 0; stepindex < length; stepindex++) {
|
||||
int16_t length = outline->pathlength();
|
||||
for (int16_t stepindex = 0; stepindex < length; stepindex++) {
|
||||
step = outline->step(stepindex);
|
||||
if (step.x() > 0) {
|
||||
lower_y = static_cast<int16_t>(floor(baseline->y(pos.x()) + baseline_offset + 0.5));
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
// Check write permissions.
|
||||
std::string test_file = FLAGS_model_output.c_str();
|
||||
std::string test_file = FLAGS_model_output;
|
||||
test_file += "_wtest";
|
||||
FILE *f = fopen(test_file.c_str(), "wb");
|
||||
if (f != nullptr) {
|
||||
@ -107,10 +107,10 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
// Setup the trainer.
|
||||
std::string checkpoint_file = FLAGS_model_output.c_str();
|
||||
std::string checkpoint_file = FLAGS_model_output;
|
||||
checkpoint_file += "_checkpoint";
|
||||
std::string checkpoint_bak = checkpoint_file + ".bak";
|
||||
tesseract::LSTMTrainer trainer(FLAGS_model_output.c_str(), checkpoint_file.c_str(),
|
||||
tesseract::LSTMTrainer trainer(FLAGS_model_output, checkpoint_file,
|
||||
FLAGS_debug_interval,
|
||||
static_cast<int64_t>(FLAGS_max_image_MB) * 1048576);
|
||||
if (!trainer.InitCharSet(FLAGS_traineddata.c_str())) {
|
||||
|
@ -80,7 +80,7 @@ LSTMTrainer::LSTMTrainer()
|
||||
debug_interval_ = 0;
|
||||
}
|
||||
|
||||
LSTMTrainer::LSTMTrainer(const char *model_base, const char *checkpoint_name,
|
||||
LSTMTrainer::LSTMTrainer(const std::string &model_base, const std::string &checkpoint_name,
|
||||
int debug_interval, int64_t max_memory)
|
||||
: randomly_rotate_(false),
|
||||
training_data_(max_memory),
|
||||
|
@ -84,7 +84,8 @@ using TestCallback = std::function<std::string(int, const double *,
|
||||
class TESS_UNICHARSET_TRAINING_API LSTMTrainer : public LSTMRecognizer {
|
||||
public:
|
||||
LSTMTrainer();
|
||||
LSTMTrainer(const char *model_base, const char *checkpoint_name,
|
||||
LSTMTrainer(const std::string &model_base,
|
||||
const std::string &checkpoint_name,
|
||||
int debug_interval, int64_t max_memory);
|
||||
virtual ~LSTMTrainer();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user