mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-05 02:47:00 +08:00
Merge pull request #1760 from stweil/cov
Fix several issues reported by Coverity Scan (incomplete constructors)
This commit is contained in:
commit
ab1f21768a
@ -72,10 +72,11 @@ struct Pix;
|
|||||||
ELISTIZEH (C_OUTLINE)
|
ELISTIZEH (C_OUTLINE)
|
||||||
class DLLSYM C_OUTLINE:public ELIST_LINK {
|
class DLLSYM C_OUTLINE:public ELIST_LINK {
|
||||||
public:
|
public:
|
||||||
C_OUTLINE() { //empty constructor
|
C_OUTLINE() {
|
||||||
steps = nullptr;
|
stepcount = 0;
|
||||||
offsets = nullptr;
|
steps = nullptr;
|
||||||
}
|
offsets = nullptr;
|
||||||
|
}
|
||||||
C_OUTLINE( //constructor
|
C_OUTLINE( //constructor
|
||||||
CRACKEDGE *startpt, //from edge detector
|
CRACKEDGE *startpt, //from edge detector
|
||||||
ICOORD bot_left, //bounding box //length of loop
|
ICOORD bot_left, //bounding box //length of loop
|
||||||
|
@ -555,7 +555,6 @@ void Classify::InitAdaptiveClassifier(TessdataManager* mgr) {
|
|||||||
static_classifier_ = new TessClassifier(false, this);
|
static_classifier_ = new TessClassifier(false, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
im_.Init(&classify_debug_level);
|
|
||||||
InitIntegerFX();
|
InitIntegerFX();
|
||||||
|
|
||||||
AllProtosOn = NewBitVector(MAX_NUM_PROTOS);
|
AllProtosOn = NewBitVector(MAX_NUM_PROTOS);
|
||||||
|
@ -184,6 +184,7 @@ Classify::Classify()
|
|||||||
this->params()),
|
this->params()),
|
||||||
double_MEMBER(speckle_rating_penalty, 10.0,
|
double_MEMBER(speckle_rating_penalty, 10.0,
|
||||||
"Penalty to add to worst rating for noise", this->params()),
|
"Penalty to add to worst rating for noise", this->params()),
|
||||||
|
im_(&classify_debug_level),
|
||||||
shape_table_(nullptr),
|
shape_table_(nullptr),
|
||||||
dict_(this),
|
dict_(this),
|
||||||
static_classifier_(nullptr) {
|
static_classifier_(nullptr) {
|
||||||
|
@ -667,9 +667,9 @@ int IntegerMatcher::FindBadFeatures(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IntegerMatcher::Init(tesseract::IntParam *classify_debug_level) {
|
IntegerMatcher::IntegerMatcher(tesseract::IntParam *classify_debug_level)
|
||||||
classify_debug_level_ = classify_debug_level;
|
: classify_debug_level_(classify_debug_level)
|
||||||
|
{
|
||||||
/* Initialize table for evidence to similarity lookup */
|
/* Initialize table for evidence to similarity lookup */
|
||||||
for (int i = 0; i < SE_TABLE_SIZE; i++) {
|
for (int i = 0; i < SE_TABLE_SIZE; i++) {
|
||||||
uint32_t IntSimilarity = i << (27 - SE_TABLE_BITS);
|
uint32_t IntSimilarity = i << (27 - SE_TABLE_BITS);
|
||||||
|
@ -93,9 +93,7 @@ class IntegerMatcher {
|
|||||||
// Center of Similarity Curve.
|
// Center of Similarity Curve.
|
||||||
static const float kSimilarityCenter;
|
static const float kSimilarityCenter;
|
||||||
|
|
||||||
IntegerMatcher() : classify_debug_level_(nullptr) {}
|
IntegerMatcher(tesseract::IntParam *classify_debug_level);
|
||||||
|
|
||||||
void Init(tesseract::IntParam *classify_debug_level);
|
|
||||||
|
|
||||||
void Match(INT_CLASS ClassTemplate,
|
void Match(INT_CLASS ClassTemplate,
|
||||||
BIT_VECTOR ProtoMask,
|
BIT_VECTOR ProtoMask,
|
||||||
@ -173,13 +171,12 @@ class IntegerMatcher {
|
|||||||
bool SeparateDebugWindows);
|
bool SeparateDebugWindows);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
tesseract::IntParam *classify_debug_level_;
|
||||||
uint8_t similarity_evidence_table_[SE_TABLE_SIZE];
|
uint8_t similarity_evidence_table_[SE_TABLE_SIZE];
|
||||||
uint32_t evidence_table_mask_;
|
uint32_t evidence_table_mask_;
|
||||||
uint32_t mult_trunc_shift_bits_;
|
uint32_t mult_trunc_shift_bits_;
|
||||||
uint32_t table_trunc_shift_bits_;
|
uint32_t table_trunc_shift_bits_;
|
||||||
tesseract::IntParam *classify_debug_level_;
|
|
||||||
uint32_t evidence_mult_mask_;
|
uint32_t evidence_mult_mask_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -915,11 +915,9 @@ void FPRow::FinalizeLargeChars() {
|
|||||||
|
|
||||||
class FPAnalyzer {
|
class FPAnalyzer {
|
||||||
public:
|
public:
|
||||||
FPAnalyzer(): page_tr_(), rows_() { }
|
FPAnalyzer(ICOORD page_tr, TO_BLOCK_LIST *port_blocks);
|
||||||
~FPAnalyzer() { }
|
~FPAnalyzer() { }
|
||||||
|
|
||||||
void Init(ICOORD page_tr, TO_BLOCK_LIST *port_blocks);
|
|
||||||
|
|
||||||
void Pass1Analyze() {
|
void Pass1Analyze() {
|
||||||
for (size_t i = 0; i < rows_.size(); i++) rows_[i].Pass1Analyze();
|
for (size_t i = 0; i < rows_.size(); i++) rows_[i].Pass1Analyze();
|
||||||
}
|
}
|
||||||
@ -984,11 +982,14 @@ class FPAnalyzer {
|
|||||||
unsigned max_chars_per_row_;
|
unsigned max_chars_per_row_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void FPAnalyzer::Init(ICOORD page_tr, TO_BLOCK_LIST *port_blocks) {
|
FPAnalyzer::FPAnalyzer(ICOORD page_tr, TO_BLOCK_LIST *port_blocks)
|
||||||
page_tr_ = page_tr;
|
: page_tr_(page_tr),
|
||||||
|
num_tall_rows_(0),
|
||||||
TO_BLOCK_IT block_it;
|
num_bad_rows_(0),
|
||||||
block_it.set_to_list (port_blocks);
|
num_empty_rows_(0),
|
||||||
|
max_chars_per_row_(0)
|
||||||
|
{
|
||||||
|
TO_BLOCK_IT block_it(port_blocks);
|
||||||
|
|
||||||
for (block_it.mark_cycle_pt(); !block_it.cycled_list();
|
for (block_it.mark_cycle_pt(); !block_it.cycled_list();
|
||||||
block_it.forward()) {
|
block_it.forward()) {
|
||||||
@ -999,8 +1000,6 @@ void FPAnalyzer::Init(ICOORD page_tr, TO_BLOCK_LIST *port_blocks) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
num_empty_rows_ = 0;
|
|
||||||
max_chars_per_row_ = 0;
|
|
||||||
for (block_it.mark_cycle_pt(); !block_it.cycled_list();
|
for (block_it.mark_cycle_pt(); !block_it.cycled_list();
|
||||||
block_it.forward()) {
|
block_it.forward()) {
|
||||||
TO_ROW_IT row_it = block_it.data()->get_rows();
|
TO_ROW_IT row_it = block_it.data()->get_rows();
|
||||||
@ -1060,8 +1059,7 @@ void FPAnalyzer::EstimatePitch(bool pass1) {
|
|||||||
|
|
||||||
void compute_fixed_pitch_cjk(ICOORD page_tr,
|
void compute_fixed_pitch_cjk(ICOORD page_tr,
|
||||||
TO_BLOCK_LIST *port_blocks) {
|
TO_BLOCK_LIST *port_blocks) {
|
||||||
FPAnalyzer analyzer;
|
FPAnalyzer analyzer(page_tr, port_blocks);
|
||||||
analyzer.Init(page_tr, port_blocks);
|
|
||||||
if (analyzer.num_rows() == 0) return;
|
if (analyzer.num_rows() == 0) return;
|
||||||
|
|
||||||
analyzer.Pass1Analyze();
|
analyzer.Pass1Analyze();
|
||||||
|
@ -11,13 +11,11 @@
|
|||||||
#include "statistc.h"
|
#include "statistc.h"
|
||||||
#include "gap_map.h"
|
#include "gap_map.h"
|
||||||
|
|
||||||
#define EXTERN
|
BOOL_VAR(gapmap_debug, FALSE, "Say which blocks have tables");
|
||||||
EXTERN BOOL_VAR (gapmap_debug, FALSE, "Say which blocks have tables");
|
BOOL_VAR(gapmap_use_ends, FALSE, "Use large space at start and end of rows");
|
||||||
EXTERN BOOL_VAR (gapmap_use_ends, FALSE,
|
BOOL_VAR(gapmap_no_isolated_quanta, FALSE,
|
||||||
"Use large space at start and end of rows");
|
|
||||||
EXTERN BOOL_VAR (gapmap_no_isolated_quanta, FALSE,
|
|
||||||
"Ensure gaps not less than 2quanta wide");
|
"Ensure gaps not less than 2quanta wide");
|
||||||
EXTERN double_VAR (gapmap_big_gaps, 1.75, "xht multiplier");
|
double_VAR(gapmap_big_gaps, 1.75, "xht multiplier");
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* A block gap map is a quantised histogram of whitespace regions in the
|
* A block gap map is a quantised histogram of whitespace regions in the
|
||||||
@ -74,6 +72,8 @@ GAPMAP::GAPMAP( //Constructor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((total_rows < 3) || (min_left >= max_right)) {
|
if ((total_rows < 3) || (min_left >= max_right)) {
|
||||||
|
bucket_size = 0;
|
||||||
|
map_max = 0;
|
||||||
total_rows = 0;
|
total_rows = 0;
|
||||||
min_left = max_right = 0;
|
min_left = max_right = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -22,17 +22,12 @@
|
|||||||
#include "pitsync1.h"
|
#include "pitsync1.h"
|
||||||
|
|
||||||
ELISTIZE (FPSEGPT) CLISTIZE (FPSEGPT_LIST)
|
ELISTIZE (FPSEGPT) CLISTIZE (FPSEGPT_LIST)
|
||||||
#define EXTERN
|
|
||||||
EXTERN
|
INT_VAR(pitsync_linear_version, 6, "Use new fast algorithm");
|
||||||
INT_VAR (pitsync_linear_version, 6, "Use new fast algorithm");
|
double_VAR(pitsync_joined_edge, 0.75, "Dist inside big blob for chopping");
|
||||||
EXTERN
|
double_VAR(pitsync_offset_freecut_fraction, 0.25,
|
||||||
double_VAR (pitsync_joined_edge, 0.75,
|
"Fraction of cut for free cuts");
|
||||||
"Dist inside big blob for chopping");
|
INT_VAR(pitsync_fake_depth, 1, "Max advance fake generation");
|
||||||
EXTERN
|
|
||||||
double_VAR (pitsync_offset_freecut_fraction, 0.25,
|
|
||||||
"Fraction of cut for free cuts");
|
|
||||||
EXTERN
|
|
||||||
INT_VAR (pitsync_fake_depth, 1, "Max advance fake generation");
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FPSEGPT::FPSEGPT
|
* FPSEGPT::FPSEGPT
|
||||||
@ -63,7 +58,7 @@ FPSEGPT::FPSEGPT( //constructor
|
|||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
FPSEGPT::FPSEGPT ( //constructor
|
FPSEGPT::FPSEGPT ( //constructor
|
||||||
int16_t x //position
|
int16_t x //position
|
||||||
):xpos (x) {
|
):xpos (x) {
|
||||||
pred = nullptr;
|
pred = nullptr;
|
||||||
mean_sum = 0;
|
mean_sum = 0;
|
||||||
@ -83,17 +78,22 @@ int16_t x //position
|
|||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
FPSEGPT::FPSEGPT ( //constructor
|
FPSEGPT::FPSEGPT ( //constructor
|
||||||
int16_t x, //position
|
int16_t x, //position
|
||||||
BOOL8 faking, //faking this one
|
BOOL8 faking, //faking this one
|
||||||
int16_t offset, //dist to gap
|
int16_t offset, //dist to gap
|
||||||
int16_t region_index, //segment number
|
int16_t region_index, //segment number
|
||||||
int16_t pitch, //proposed pitch
|
int16_t pitch, //proposed pitch
|
||||||
int16_t pitch_error, //allowed tolerance
|
int16_t pitch_error, //allowed tolerance
|
||||||
FPSEGPT_LIST * prev_list //previous segment
|
FPSEGPT_LIST * prev_list //previous segment
|
||||||
):xpos (x) {
|
)
|
||||||
int16_t best_fake; //on previous
|
: fake_count(0),
|
||||||
|
xpos(x),
|
||||||
|
mean_sum(0.0),
|
||||||
|
sq_sum(0.0)
|
||||||
|
{
|
||||||
|
int16_t best_fake; //on previous
|
||||||
FPSEGPT *segpt; //segment point
|
FPSEGPT *segpt; //segment point
|
||||||
int32_t dist; //from prev segment
|
int32_t dist; //from prev segment
|
||||||
double sq_dist; //squared distance
|
double sq_dist; //squared distance
|
||||||
double mean; //mean pitch
|
double mean; //mean pitch
|
||||||
double total; //total dists
|
double total; //total dists
|
||||||
@ -133,7 +133,6 @@ FPSEGPT_LIST * prev_list //previous segment
|
|||||||
pred = nullptr; //fail it
|
pred = nullptr; //fail it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* check_pitch_sync
|
* check_pitch_sync
|
||||||
*
|
*
|
||||||
@ -144,28 +143,28 @@ FPSEGPT_LIST * prev_list //previous segment
|
|||||||
|
|
||||||
double check_pitch_sync( //find segmentation
|
double check_pitch_sync( //find segmentation
|
||||||
BLOBNBOX_IT *blob_it, //blobs to do
|
BLOBNBOX_IT *blob_it, //blobs to do
|
||||||
int16_t blob_count, //no of blobs
|
int16_t blob_count, //no of blobs
|
||||||
int16_t pitch, //pitch estimate
|
int16_t pitch, //pitch estimate
|
||||||
int16_t pitch_error, //tolerance
|
int16_t pitch_error, //tolerance
|
||||||
STATS *projection, //vertical
|
STATS *projection, //vertical
|
||||||
FPSEGPT_LIST *seg_list //output list
|
FPSEGPT_LIST *seg_list //output list
|
||||||
) {
|
) {
|
||||||
int16_t x; //current coord
|
int16_t x; //current coord
|
||||||
int16_t min_index; //blob number
|
int16_t min_index; //blob number
|
||||||
int16_t max_index; //blob number
|
int16_t max_index; //blob number
|
||||||
int16_t left_edge; //of word
|
int16_t left_edge; //of word
|
||||||
int16_t right_edge; //of word
|
int16_t right_edge; //of word
|
||||||
int16_t right_max; //max allowed x
|
int16_t right_max; //max allowed x
|
||||||
int16_t min_x; //in this region
|
int16_t min_x; //in this region
|
||||||
int16_t max_x;
|
int16_t max_x;
|
||||||
int16_t region_index;
|
int16_t region_index;
|
||||||
int16_t best_region_index = 0; //for best result
|
int16_t best_region_index = 0; //for best result
|
||||||
int16_t offset; //dist to legal area
|
int16_t offset; //dist to legal area
|
||||||
int16_t left_best_x; //edge of good region
|
int16_t left_best_x; //edge of good region
|
||||||
int16_t right_best_x; //right edge
|
int16_t right_best_x; //right edge
|
||||||
TBOX min_box; //bounding box
|
TBOX min_box; //bounding box
|
||||||
TBOX max_box; //bounding box
|
TBOX max_box; //bounding box
|
||||||
TBOX next_box; //box of next blob
|
TBOX next_box; //box of next blob
|
||||||
FPSEGPT *segpt; //segment point
|
FPSEGPT *segpt; //segment point
|
||||||
FPSEGPT_LIST *segpts; //points in a segment
|
FPSEGPT_LIST *segpts; //points in a segment
|
||||||
double best_cost; //best path
|
double best_cost; //best path
|
||||||
@ -362,17 +361,17 @@ double check_pitch_sync( //find segmentation
|
|||||||
|
|
||||||
void make_illegal_segment( //find segmentation
|
void make_illegal_segment( //find segmentation
|
||||||
FPSEGPT_LIST *prev_list, //previous segments
|
FPSEGPT_LIST *prev_list, //previous segments
|
||||||
TBOX blob_box, //bounding box
|
TBOX blob_box, //bounding box
|
||||||
BLOBNBOX_IT blob_it, //iterator
|
BLOBNBOX_IT blob_it, //iterator
|
||||||
int16_t region_index, //number of segment
|
int16_t region_index, //number of segment
|
||||||
int16_t pitch, //pitch estimate
|
int16_t pitch, //pitch estimate
|
||||||
int16_t pitch_error, //tolerance
|
int16_t pitch_error, //tolerance
|
||||||
FPSEGPT_LIST *seg_list //output list
|
FPSEGPT_LIST *seg_list //output list
|
||||||
) {
|
) {
|
||||||
int16_t x; //current coord
|
int16_t x; //current coord
|
||||||
int16_t min_x = 0; //in this region
|
int16_t min_x = 0; //in this region
|
||||||
int16_t max_x = 0;
|
int16_t max_x = 0;
|
||||||
int16_t offset; //dist to edge
|
int16_t offset; //dist to edge
|
||||||
FPSEGPT *segpt; //segment point
|
FPSEGPT *segpt; //segment point
|
||||||
FPSEGPT *prevpt; //previous point
|
FPSEGPT *prevpt; //previous point
|
||||||
float best_cost; //best path
|
float best_cost; //best path
|
||||||
|
@ -134,7 +134,8 @@ Wordrec::Wordrec() :
|
|||||||
BOOL_MEMBER(save_alt_choices, true,
|
BOOL_MEMBER(save_alt_choices, true,
|
||||||
"Save alternative paths found during chopping"
|
"Save alternative paths found during chopping"
|
||||||
" and segmentation search",
|
" and segmentation search",
|
||||||
params()) {
|
params()),
|
||||||
|
pass2_ok_split(0.0f) {
|
||||||
prev_word_best_choice_ = nullptr;
|
prev_word_best_choice_ = nullptr;
|
||||||
language_model_.reset(new LanguageModel(&get_fontinfo_table(),
|
language_model_.reset(new LanguageModel(&get_fontinfo_table(),
|
||||||
&(getDict())));
|
&(getDict())));
|
||||||
|
Loading…
Reference in New Issue
Block a user