mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +08:00
backport from 4.00: use ".empty()" instead of ".size() > 0"
This commit is contained in:
parent
5882261969
commit
ed0c60bc65
@ -2762,7 +2762,7 @@ void TessBaseAPI::GetFeaturesForBlob(TBLOB* blob,
|
||||
INT_FX_RESULT_STRUCT fx_info;
|
||||
tesseract_->ExtractFeatures(*blob, false, &bl_features,
|
||||
&cn_features, &fx_info, &outline_counts);
|
||||
if (cn_features.size() == 0 || cn_features.size() > MAX_NUM_INT_FEATURES) {
|
||||
if (cn_features.empty() || cn_features.size() > MAX_NUM_INT_FEATURES) {
|
||||
*num_features = 0;
|
||||
return; // Feature extraction failed.
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ void Tesseract::bigram_correction_pass(PAGE_RES *page_res) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (overrides_word1.size() >= 1) {
|
||||
if (!overrides_word1.empty()) {
|
||||
// Excellent, we have some bigram matches.
|
||||
if (EqualIgnoringCaseAndTerminalPunct(*w_prev->best_choice,
|
||||
*overrides_word1[best_idx]) &&
|
||||
|
@ -2052,7 +2052,7 @@ void ConvertHypothesizedModelRunsToParagraphs(
|
||||
bool single_line_paragraph = false;
|
||||
SetOfModels models;
|
||||
rows[start].NonNullHypotheses(&models);
|
||||
if (models.size() > 0) {
|
||||
if (!models.empty()) {
|
||||
model = models[0];
|
||||
if (rows[start].GetLineType(model) != LT_BODY)
|
||||
single_line_paragraph = true;
|
||||
@ -2190,17 +2190,17 @@ void LeftoverSegments(const GenericVector<RowScratchRegisters> &rows,
|
||||
SetOfModels models_w_crowns;
|
||||
rows[i].StrongHypotheses(&models);
|
||||
rows[i].NonNullHypotheses(&models_w_crowns);
|
||||
if (models.empty() && models_w_crowns.size() > 0) {
|
||||
if (models.empty() && !models_w_crowns.empty()) {
|
||||
// Crown paragraph. Is it followed by a modeled line?
|
||||
for (int end = i + 1; end < rows.size(); end++) {
|
||||
SetOfModels end_models;
|
||||
SetOfModels strong_end_models;
|
||||
rows[end].NonNullHypotheses(&end_models);
|
||||
rows[end].StrongHypotheses(&strong_end_models);
|
||||
if (end_models.size() == 0) {
|
||||
if (end_models.empty()) {
|
||||
needs_fixing = true;
|
||||
break;
|
||||
} else if (strong_end_models.size() > 0) {
|
||||
} else if (!strong_end_models.empty()) {
|
||||
needs_fixing = false;
|
||||
break;
|
||||
}
|
||||
@ -2485,7 +2485,7 @@ void InitializeRowInfo(bool after_recognition,
|
||||
info->ltr = ltr >= rtl;
|
||||
info->has_leaders = num_leaders > 3;
|
||||
info->num_words = werds.size();
|
||||
if (werds.size() > 0) {
|
||||
if (!werds.empty()) {
|
||||
WERD_RES *lword = werds[0], *rword = werds[werds.size() - 1];
|
||||
info->lword_text = lword->best_choice->unichar_string().string();
|
||||
info->rword_text = rword->best_choice->unichar_string().string();
|
||||
@ -2538,7 +2538,7 @@ void DetectParagraphs(int debug_level,
|
||||
|
||||
// If we're called before text recognition, we might not have
|
||||
// tight block bounding boxes, so trim by the minimum on each side.
|
||||
if (row_infos.size() > 0) {
|
||||
if (!row_infos.empty()) {
|
||||
int min_lmargin = row_infos[0].pix_ldistance;
|
||||
int min_rmargin = row_infos[0].pix_rdistance;
|
||||
for (int i = 1; i < row_infos.size(); i++) {
|
||||
|
@ -520,7 +520,7 @@ bool ExtractIntFeat(const TBLOB& blob,
|
||||
tesseract::Classify::ExtractFeatures(blob, nonlinear_norm,
|
||||
&bl_features, &cn_features, results,
|
||||
NULL);
|
||||
if (bl_features.size() == 0 || cn_features.size() == 0 ||
|
||||
if (bl_features.empty() || cn_features.empty() ||
|
||||
bl_features.size() > MAX_NUM_INT_FEATURES ||
|
||||
cn_features.size() > MAX_NUM_INT_FEATURES) {
|
||||
return false; // Feature extraction failed.
|
||||
|
@ -176,7 +176,7 @@ void ShapeClassifier::UnicharPrintResults(
|
||||
for (int i = 0; i < results.size(); ++i) {
|
||||
tprintf("%g: c_id=%d=%s", results[i].rating, results[i].unichar_id,
|
||||
GetUnicharset().id_to_unichar(results[i].unichar_id));
|
||||
if (results[i].fonts.size() != 0) {
|
||||
if (!results[i].fonts.empty()) {
|
||||
tprintf(" Font Vector:");
|
||||
for (int f = 0; f < results[i].fonts.size(); ++f) {
|
||||
tprintf(" %d", results[i].fonts[f].fontinfo_id);
|
||||
|
@ -1376,7 +1376,7 @@ void ColPartitionGrid::FindMergeCandidates(const ColPartition* part,
|
||||
// combined box to see if anything else is inappropriately overlapped.
|
||||
if (!part_box.contains(c_box) && !c_box.contains(part_box)) {
|
||||
// Search the combined rectangle to see if anything new is overlapped.
|
||||
// This is a preliminary test designed to quickly weed-out stupid
|
||||
// This is a preliminary test designed to quickly weed-out poor
|
||||
// merge candidates that would create a big list of overlapped objects
|
||||
// for the squared-order overlap analysis. Eg. vertical and horizontal
|
||||
// line-like objects that overlap real text when merged:
|
||||
@ -1619,10 +1619,10 @@ BlobRegionType ColPartitionGrid::SmoothInOneDirection(
|
||||
image_bias - htext_score >= kSmoothDecisionMargin &&
|
||||
image_bias - vtext_score >= kSmoothDecisionMargin) {
|
||||
*best_distance = dists[NPT_IMAGE][0];
|
||||
if (dists[NPT_WEAK_VTEXT].size() > 0 &&
|
||||
if (!dists[NPT_WEAK_VTEXT].empty() &&
|
||||
*best_distance > dists[NPT_WEAK_VTEXT][0])
|
||||
*best_distance = dists[NPT_WEAK_VTEXT][0];
|
||||
if (dists[NPT_WEAK_HTEXT].size() > 0 &&
|
||||
if (!dists[NPT_WEAK_HTEXT].empty() &&
|
||||
*best_distance > dists[NPT_WEAK_HTEXT][0])
|
||||
*best_distance = dists[NPT_WEAK_HTEXT][0];
|
||||
return BRT_POLYIMAGE;
|
||||
|
Loading…
Reference in New Issue
Block a user