mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 14:41:36 +08:00
Replace tabs by blanks in source code
blobs.cpp had many tabs and was formatted with clang-format. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
c9efe5f509
commit
6d170a15ec
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: fixxht.cpp (Formerly fixxht.c)
|
||||
* Description: Improve x_ht and look out for case inconsistencies
|
||||
* Author: Phil Cheatle
|
||||
* Created: Thu Aug 5 14:11:08 BST 1993
|
||||
* Author: Phil Cheatle
|
||||
* Created: Thu Aug 5 14:11:08 BST 1993
|
||||
*
|
||||
* (C) Copyright 1992, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: tessvars.cpp (Formerly tessvars.c)
|
||||
* Description: Variables and other globals for tessedit.
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Apr 13 13:13:23 BST 1992
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Apr 13 13:13:23 BST 1992
|
||||
*
|
||||
* (C) Copyright 1992, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: tessvars.h (Formerly tessvars.h)
|
||||
* Description: Variables and other globals for tessedit.
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Apr 13 13:13:23 BST 1992
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Apr 13 13:13:23 BST 1992
|
||||
*
|
||||
* (C) Copyright 1992, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,11 +17,11 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef TESSVARS_H
|
||||
#define TESSVARS_H
|
||||
#ifndef TESSVARS_H
|
||||
#define TESSVARS_H
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
extern FILE *debug_fp; // write debug stuff here
|
||||
|
||||
#endif
|
||||
|
@ -107,16 +107,15 @@ TESSLINE* TESSLINE::BuildFromOutlineList(EDGEPT* outline) {
|
||||
if (outline->src_outline != nullptr) {
|
||||
// ASSUMPTION: This function is only ever called from ApproximateOutline
|
||||
// and therefore either all points have a src_outline or all do not.
|
||||
// Just as SetupFromPos sets the vectors from the vertices, setup the
|
||||
// step_count members to indicate the (positive) number of original
|
||||
// C_OUTLINE steps to the next vertex.
|
||||
EDGEPT* pt = outline;
|
||||
do {
|
||||
pt->step_count = pt->next->start_step - pt->start_step;
|
||||
if (pt->step_count < 0)
|
||||
pt->step_count += pt->src_outline->pathlength();
|
||||
pt = pt->next;
|
||||
} while (pt != outline);
|
||||
// Just as SetupFromPos sets the vectors from the vertices, setup the
|
||||
// step_count members to indicate the (positive) number of original
|
||||
// C_OUTLINE steps to the next vertex.
|
||||
EDGEPT* pt = outline;
|
||||
do {
|
||||
pt->step_count = pt->next->start_step - pt->start_step;
|
||||
if (pt->step_count < 0) pt->step_count += pt->src_outline->pathlength();
|
||||
pt = pt->next;
|
||||
} while (pt != outline);
|
||||
}
|
||||
result->SetupFromPos();
|
||||
return result;
|
||||
@ -151,8 +150,7 @@ void TESSLINE::CopyFrom(const TESSLINE& src) {
|
||||
|
||||
// Deletes owned data.
|
||||
void TESSLINE::Clear() {
|
||||
if (loop == nullptr)
|
||||
return;
|
||||
if (loop == nullptr) return;
|
||||
|
||||
EDGEPT* this_edge = loop;
|
||||
do {
|
||||
@ -177,10 +175,10 @@ void TESSLINE::Normalize(const DENORM& denorm) {
|
||||
void TESSLINE::Rotate(const FCOORD rot) {
|
||||
EDGEPT* pt = loop;
|
||||
do {
|
||||
int tmp = static_cast<int>(floor(pt->pos.x * rot.x() -
|
||||
pt->pos.y * rot.y() + 0.5));
|
||||
pt->pos.y = static_cast<int>(floor(pt->pos.y * rot.x() +
|
||||
pt->pos.x * rot.y() + 0.5));
|
||||
int tmp = static_cast<int>(
|
||||
floor(pt->pos.x * rot.x() - pt->pos.y * rot.y() + 0.5));
|
||||
pt->pos.y = static_cast<int>(
|
||||
floor(pt->pos.y * rot.x() + pt->pos.x * rot.y() + 0.5));
|
||||
pt->pos.x = tmp;
|
||||
pt = pt->next;
|
||||
} while (pt != loop);
|
||||
@ -233,14 +231,10 @@ void TESSLINE::ComputeBoundingBox() {
|
||||
EDGEPT* this_edge = loop;
|
||||
do {
|
||||
if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) {
|
||||
if (this_edge->pos.x < minx)
|
||||
minx = this_edge->pos.x;
|
||||
if (this_edge->pos.y < miny)
|
||||
miny = this_edge->pos.y;
|
||||
if (this_edge->pos.x > maxx)
|
||||
maxx = this_edge->pos.x;
|
||||
if (this_edge->pos.y > maxy)
|
||||
maxy = this_edge->pos.y;
|
||||
if (this_edge->pos.x < minx) minx = this_edge->pos.x;
|
||||
if (this_edge->pos.y < miny) miny = this_edge->pos.y;
|
||||
if (this_edge->pos.x > maxx) maxx = this_edge->pos.x;
|
||||
if (this_edge->pos.y > maxy) maxy = this_edge->pos.y;
|
||||
}
|
||||
this_edge = this_edge->next;
|
||||
} while (this_edge != loop);
|
||||
@ -256,8 +250,8 @@ void TESSLINE::ComputeBoundingBox() {
|
||||
// this is the left and right edge of the outline perpendicular to the
|
||||
// given direction, but to get the distance units correct, you would
|
||||
// have to divide by the modulus of vec.
|
||||
void TESSLINE::MinMaxCrossProduct(const TPOINT vec,
|
||||
int* min_xp, int* max_xp) const {
|
||||
void TESSLINE::MinMaxCrossProduct(const TPOINT vec, int* min_xp,
|
||||
int* max_xp) const {
|
||||
*min_xp = INT32_MAX;
|
||||
*max_xp = INT32_MIN;
|
||||
EDGEPT* this_edge = loop;
|
||||
@ -318,8 +312,7 @@ EDGEPT* TESSLINE::FindBestStartPt() const {
|
||||
// of the resulting list of TESSLINEs.
|
||||
static TESSLINE** ApproximateOutlineList(bool allow_detailed_fx,
|
||||
C_OUTLINE_LIST* outlines,
|
||||
bool children,
|
||||
TESSLINE** tail) {
|
||||
bool children, TESSLINE** tail) {
|
||||
C_OUTLINE_IT ol_it(outlines);
|
||||
for (ol_it.mark_cycle_pt(); !ol_it.cycled_list(); ol_it.forward()) {
|
||||
C_OUTLINE* outline = ol_it.data();
|
||||
@ -373,11 +366,12 @@ TBLOB* TBLOB::ClassifyNormalizeIfNeeded() const {
|
||||
const FCOORD& rotation = denorm_.block()->classify_rotation();
|
||||
// Move the rotated blob back to the same y-position so that we
|
||||
// can still distinguish similar glyphs with differeny y-position.
|
||||
float target_y = kBlnBaselineOffset +
|
||||
float target_y =
|
||||
kBlnBaselineOffset +
|
||||
(rotation.y() > 0 ? x_middle - box.left() : box.right() - x_middle);
|
||||
rotated_blob->Normalize(nullptr, &rotation, &denorm_, x_middle, y_middle,
|
||||
1.0f, 1.0f, 0.0f, target_y,
|
||||
denorm_.inverse(), denorm_.pix());
|
||||
1.0f, 1.0f, 0.0f, target_y, denorm_.inverse(),
|
||||
denorm_.pix());
|
||||
}
|
||||
return rotated_blob;
|
||||
}
|
||||
@ -410,13 +404,10 @@ void TBLOB::Clear() {
|
||||
// Sets up the built-in DENORM and normalizes the blob in-place.
|
||||
// For parameters see DENORM::SetupNormalization, plus the inverse flag for
|
||||
// this blob and the Pix for the full image.
|
||||
void TBLOB::Normalize(const BLOCK* block,
|
||||
const FCOORD* rotation,
|
||||
const DENORM* predecessor,
|
||||
float x_origin, float y_origin,
|
||||
float x_scale, float y_scale,
|
||||
float final_xshift, float final_yshift,
|
||||
bool inverse, Pix* pix) {
|
||||
void TBLOB::Normalize(const BLOCK* block, const FCOORD* rotation,
|
||||
const DENORM* predecessor, float x_origin, float y_origin,
|
||||
float x_scale, float y_scale, float final_xshift,
|
||||
float final_yshift, bool inverse, Pix* pix) {
|
||||
denorm_.SetupNormalization(block, rotation, predecessor, x_origin, y_origin,
|
||||
x_scale, y_scale, final_xshift, final_yshift);
|
||||
denorm_.set_inverse(inverse);
|
||||
@ -439,28 +430,32 @@ void TBLOB::Normalize(const BLOCK* block,
|
||||
|
||||
// Rotates by the given rotation in place.
|
||||
void TBLOB::Rotate(const FCOORD rotation) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr; outline = outline->next) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr;
|
||||
outline = outline->next) {
|
||||
outline->Rotate(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
// Moves by the given vec in place.
|
||||
void TBLOB::Move(const ICOORD vec) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr; outline = outline->next) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr;
|
||||
outline = outline->next) {
|
||||
outline->Move(vec);
|
||||
}
|
||||
}
|
||||
|
||||
// Scales by the given factor in place.
|
||||
void TBLOB::Scale(float factor) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr; outline = outline->next) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr;
|
||||
outline = outline->next) {
|
||||
outline->Scale(factor);
|
||||
}
|
||||
}
|
||||
|
||||
// Recomputes the bounding boxes of the outlines.
|
||||
void TBLOB::ComputeBoundingBoxes() {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr; outline = outline->next) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr;
|
||||
outline = outline->next) {
|
||||
outline->ComputeBoundingBox();
|
||||
}
|
||||
}
|
||||
@ -468,7 +463,8 @@ void TBLOB::ComputeBoundingBoxes() {
|
||||
// Returns the number of outlines.
|
||||
int TBLOB::NumOutlines() const {
|
||||
int result = 0;
|
||||
for (TESSLINE* outline = outlines; outline != nullptr; outline = outline->next)
|
||||
for (TESSLINE* outline = outlines; outline != nullptr;
|
||||
outline = outline->next)
|
||||
++result;
|
||||
return result;
|
||||
}
|
||||
@ -480,9 +476,8 @@ int TBLOB::NumOutlines() const {
|
||||
* bounding box of the union of all top-level outlines in the blob.
|
||||
**********************************************************************/
|
||||
TBOX TBLOB::bounding_box() const {
|
||||
if (outlines == nullptr)
|
||||
return TBOX(0, 0, 0, 0);
|
||||
TESSLINE *outline = outlines;
|
||||
if (outlines == nullptr) return TBOX(0, 0, 0, 0);
|
||||
TESSLINE* outline = outlines;
|
||||
TBOX box = outline->bounding_box();
|
||||
for (outline = outline->next; outline != nullptr; outline = outline->next) {
|
||||
box += outline->bounding_box();
|
||||
@ -493,7 +488,8 @@ TBOX TBLOB::bounding_box() const {
|
||||
// Finds and deletes any duplicate outlines in this blob, without deleting
|
||||
// their EDGEPTs.
|
||||
void TBLOB::EliminateDuplicateOutlines() {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr; outline = outline->next) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr;
|
||||
outline = outline->next) {
|
||||
TESSLINE* last_outline = outline;
|
||||
for (TESSLINE* other_outline = outline->next; other_outline != nullptr;
|
||||
last_outline = other_outline, other_outline = other_outline->next) {
|
||||
@ -523,7 +519,8 @@ void TBLOB::CorrectBlobOrder(TBLOB* next) {
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
void TBLOB::plot(ScrollView* window, ScrollView::Color color,
|
||||
ScrollView::Color child_color) {
|
||||
for (TESSLINE* outline = outlines; outline != nullptr; outline = outline->next)
|
||||
for (TESSLINE* outline = outlines; outline != nullptr;
|
||||
outline = outline->next)
|
||||
outline->plot(window, color, child_color);
|
||||
}
|
||||
#endif // GRAPHICS_DISABLED
|
||||
@ -575,10 +572,8 @@ void TBLOB::GetEdgeCoords(const TBOX& box,
|
||||
y_coords->init_to_size(box.width(), empty);
|
||||
CollectEdges(box, nullptr, nullptr, x_coords, y_coords);
|
||||
// Sort the output vectors.
|
||||
for (int i = 0; i < x_coords->size(); ++i)
|
||||
(*x_coords)[i].sort();
|
||||
for (int i = 0; i < y_coords->size(); ++i)
|
||||
(*y_coords)[i].sort();
|
||||
for (int i = 0; i < x_coords->size(); ++i) (*x_coords)[i].sort();
|
||||
for (int i = 0; i < y_coords->size(); ++i) (*y_coords)[i].sort();
|
||||
}
|
||||
|
||||
// Accumulates the segment between pt1 and pt2 in the LLSQ, quantizing over
|
||||
@ -610,13 +605,14 @@ static void SegmentLLSQ(const FCOORD& pt1, const FCOORD& pt2,
|
||||
// bottom-left of the bounding box, hence indices to x_coords, y_coords
|
||||
// are clipped to ([0,x_limit], [0,y_limit]).
|
||||
// See GetEdgeCoords above for a description of x_coords, y_coords.
|
||||
static void SegmentCoords(const FCOORD& pt1, const FCOORD& pt2,
|
||||
int x_limit, int y_limit,
|
||||
static void SegmentCoords(const FCOORD& pt1, const FCOORD& pt2, int x_limit,
|
||||
int y_limit,
|
||||
GenericVector<GenericVector<int> >* x_coords,
|
||||
GenericVector<GenericVector<int> >* y_coords) {
|
||||
FCOORD step(pt2);
|
||||
step -= pt1;
|
||||
int start = ClipToRange(IntCastRounded(std::min(pt1.x(), pt2.x())), 0, x_limit);
|
||||
int start =
|
||||
ClipToRange(IntCastRounded(std::min(pt1.x(), pt2.x())), 0, x_limit);
|
||||
int end = ClipToRange(IntCastRounded(std::max(pt1.x(), pt2.x())), 0, x_limit);
|
||||
for (int x = start; x < end; ++x) {
|
||||
int y = IntCastRounded(pt1.y() + step.y() * (x + 0.5 - pt1.x()) / step.x());
|
||||
@ -639,20 +635,20 @@ static void SegmentBBox(const FCOORD& pt1, const FCOORD& pt2, TBOX* bbox) {
|
||||
int x1 = IntCastRounded(std::min(pt1.x(), pt2.x()));
|
||||
int x2 = IntCastRounded(std::max(pt1.x(), pt2.x()));
|
||||
if (x2 > x1) {
|
||||
int y1 = IntCastRounded(pt1.y() + step.y() * (x1 + 0.5 - pt1.x()) /
|
||||
step.x());
|
||||
int y2 = IntCastRounded(pt1.y() + step.y() * (x2 - 0.5 - pt1.x()) /
|
||||
step.x());
|
||||
int y1 =
|
||||
IntCastRounded(pt1.y() + step.y() * (x1 + 0.5 - pt1.x()) / step.x());
|
||||
int y2 =
|
||||
IntCastRounded(pt1.y() + step.y() * (x2 - 0.5 - pt1.x()) / step.x());
|
||||
TBOX point(x1, std::min(y1, y2), x2, std::max(y1, y2));
|
||||
*bbox += point;
|
||||
}
|
||||
int y1 = IntCastRounded(std::min(pt1.y(), pt2.y()));
|
||||
int y2 = IntCastRounded(std::max(pt1.y(), pt2.y()));
|
||||
if (y2 > y1) {
|
||||
int x1 = IntCastRounded(pt1.x() + step.x() * (y1 + 0.5 - pt1.y()) /
|
||||
step.y());
|
||||
int x2 = IntCastRounded(pt1.x() + step.x() * (y2 - 0.5 - pt1.y()) /
|
||||
step.y());
|
||||
int x1 =
|
||||
IntCastRounded(pt1.x() + step.x() * (y1 + 0.5 - pt1.y()) / step.y());
|
||||
int x2 =
|
||||
IntCastRounded(pt1.x() + step.x() * (y2 - 0.5 - pt1.y()) / step.y());
|
||||
TBOX point(std::min(x1, x2), y1, std::max(x1, x2), y2);
|
||||
*bbox += point;
|
||||
}
|
||||
@ -670,10 +666,9 @@ static void SegmentBBox(const FCOORD& pt1, const FCOORD& pt2, TBOX* bbox) {
|
||||
// indices into x_coords, y_coords are offset by box.botleft().
|
||||
static void CollectEdgesOfRun(const EDGEPT* startpt, const EDGEPT* lastpt,
|
||||
const DENORM& denorm, const TBOX& box,
|
||||
TBOX* bounding_box,
|
||||
LLSQ* accumulator,
|
||||
GenericVector<GenericVector<int> > *x_coords,
|
||||
GenericVector<GenericVector<int> > *y_coords) {
|
||||
TBOX* bounding_box, LLSQ* accumulator,
|
||||
GenericVector<GenericVector<int> >* x_coords,
|
||||
GenericVector<GenericVector<int> >* y_coords) {
|
||||
const C_OUTLINE* outline = startpt->src_outline;
|
||||
int x_limit = box.width() - 1;
|
||||
int y_limit = box.height() - 1;
|
||||
@ -692,8 +687,7 @@ static void CollectEdgesOfRun(const EDGEPT* startpt, const EDGEPT* lastpt,
|
||||
// bounds of the outline steps/ due to wrap-around, so we use % step_length
|
||||
// everywhere, except for start_index.
|
||||
int end_index = lastpt->start_step + lastpt->step_count;
|
||||
if (end_index <= start_index)
|
||||
end_index += step_length;
|
||||
if (end_index <= start_index) end_index += step_length;
|
||||
// pos is the integer coordinates of the binary image steps.
|
||||
ICOORD pos = outline->position_at_index(start_index);
|
||||
FCOORD origin(box.left(), box.bottom());
|
||||
@ -716,8 +710,8 @@ static void CollectEdgesOfRun(const EDGEPT* startpt, const EDGEPT* lastpt,
|
||||
// with a greyscale image, the positioning of the edge there may be a
|
||||
// fictitious extrapolation, so previous processing has eliminated it.
|
||||
if (outline->edge_strength_at_index(index % step_length) > 0) {
|
||||
FCOORD f_pos = outline->sub_pixel_pos_at_index(pos,
|
||||
index % step_length);
|
||||
FCOORD f_pos =
|
||||
outline->sub_pixel_pos_at_index(pos, index % step_length);
|
||||
FCOORD pos_normed;
|
||||
denorm.NormTransform(root_denorm, f_pos, &pos_normed);
|
||||
pos_normed -= origin;
|
||||
@ -729,8 +723,8 @@ static void CollectEdgesOfRun(const EDGEPT* startpt, const EDGEPT* lastpt,
|
||||
SegmentLLSQ(pos_normed, prev_normed, accumulator);
|
||||
}
|
||||
if (x_coords != nullptr && y_coords != nullptr) {
|
||||
SegmentCoords(pos_normed, prev_normed, x_limit, y_limit,
|
||||
x_coords, y_coords);
|
||||
SegmentCoords(pos_normed, prev_normed, x_limit, y_limit, x_coords,
|
||||
y_coords);
|
||||
}
|
||||
prev_normed = pos_normed;
|
||||
}
|
||||
@ -762,8 +756,7 @@ static void CollectEdgesOfRun(const EDGEPT* startpt, const EDGEPT* lastpt,
|
||||
// llsq and/or the x_coords/y_coords. Both are used in different kinds of
|
||||
// normalization.
|
||||
// For a description of x_coords, y_coords, see GetEdgeCoords above.
|
||||
void TBLOB::CollectEdges(const TBOX& box,
|
||||
TBOX* bounding_box, LLSQ* llsq,
|
||||
void TBLOB::CollectEdges(const TBOX& box, TBOX* bounding_box, LLSQ* llsq,
|
||||
GenericVector<GenericVector<int> >* x_coords,
|
||||
GenericVector<GenericVector<int> >* y_coords) const {
|
||||
// Iterate the outlines.
|
||||
@ -781,8 +774,8 @@ void TBLOB::CollectEdges(const TBOX& box,
|
||||
} while (last_pt != loop_pt && !last_pt->IsHidden() &&
|
||||
last_pt->src_outline == pt->src_outline);
|
||||
last_pt = last_pt->prev;
|
||||
CollectEdgesOfRun(pt, last_pt, denorm_, box,
|
||||
bounding_box, llsq, x_coords, y_coords);
|
||||
CollectEdgesOfRun(pt, last_pt, denorm_, box, bounding_box, llsq, x_coords,
|
||||
y_coords);
|
||||
pt = last_pt;
|
||||
} while ((pt = pt->next) != loop_pt);
|
||||
}
|
||||
@ -807,8 +800,7 @@ TWERD* TWERD::PolygonalCopy(bool allow_detailed_fx, WERD* src) {
|
||||
void TWERD::BLNormalize(const BLOCK* block, const ROW* row, Pix* pix,
|
||||
bool inverse, float x_height, float baseline_shift,
|
||||
bool numeric_mode, tesseract::OcrEngineMode hint,
|
||||
const TBOX* norm_box,
|
||||
DENORM* word_denorm) {
|
||||
const TBOX* norm_box, DENORM* word_denorm) {
|
||||
TBOX word_box = bounding_box();
|
||||
if (norm_box != nullptr) word_box = *norm_box;
|
||||
float word_middle = (word_box.left() + word_box.right()) / 2.0f;
|
||||
@ -846,8 +838,8 @@ void TWERD::BLNormalize(const BLOCK* block, const ROW* row, Pix* pix,
|
||||
}
|
||||
if (word_denorm != nullptr) {
|
||||
word_denorm->SetupNormalization(block, nullptr, nullptr, word_middle,
|
||||
input_y_offset, scale, scale,
|
||||
0.0f, final_y_offset);
|
||||
input_y_offset, scale, scale, 0.0f,
|
||||
final_y_offset);
|
||||
word_denorm->set_inverse(inverse);
|
||||
word_denorm->set_pix(pix);
|
||||
}
|
||||
@ -888,7 +880,7 @@ TBOX TWERD::bounding_box() const {
|
||||
// Merges the blobs from start to end, not including end, and deletes
|
||||
// the blobs between start and end.
|
||||
void TWERD::MergeBlobs(int start, int end) {
|
||||
if (start >= blobs.size() - 1) return; // Nothing to do.
|
||||
if (start >= blobs.size() - 1) return; // Nothing to do.
|
||||
TESSLINE* outline = blobs[start]->outlines;
|
||||
for (int i = start + 1; i < end && i < blobs.size(); ++i) {
|
||||
TBLOB* next_blob = blobs[i];
|
||||
@ -897,8 +889,7 @@ void TWERD::MergeBlobs(int start, int end) {
|
||||
blobs[start]->outlines = next_blob->outlines;
|
||||
outline = blobs[start]->outlines;
|
||||
} else {
|
||||
while (outline->next != nullptr)
|
||||
outline = outline->next;
|
||||
while (outline->next != nullptr) outline = outline->next;
|
||||
outline->next = next_blob->outlines;
|
||||
next_blob->outlines = nullptr;
|
||||
}
|
||||
@ -929,34 +920,34 @@ void TWERD::plot(ScrollView* window) {
|
||||
* separated using divide_blobs. Sets the location to be used in the
|
||||
* call to divide_blobs.
|
||||
**********************************************************************/
|
||||
bool divisible_blob(TBLOB *blob, bool italic_blob, TPOINT* location) {
|
||||
bool divisible_blob(TBLOB* blob, bool italic_blob, TPOINT* location) {
|
||||
if (blob->outlines == nullptr || blob->outlines->next == nullptr)
|
||||
return false; // Need at least 2 outlines for it to be possible.
|
||||
int max_gap = 0;
|
||||
TPOINT vertical = italic_blob ? kDivisibleVerticalItalic
|
||||
: kDivisibleVerticalUpright;
|
||||
TPOINT vertical =
|
||||
italic_blob ? kDivisibleVerticalItalic : kDivisibleVerticalUpright;
|
||||
for (TESSLINE* outline1 = blob->outlines; outline1 != nullptr;
|
||||
outline1 = outline1->next) {
|
||||
if (outline1->is_hole)
|
||||
continue; // Holes do not count as separable.
|
||||
if (outline1->is_hole) continue; // Holes do not count as separable.
|
||||
TPOINT mid_pt1(
|
||||
static_cast<int16_t>((outline1->topleft.x + outline1->botright.x) / 2),
|
||||
static_cast<int16_t>((outline1->topleft.y + outline1->botright.y) / 2));
|
||||
static_cast<int16_t>((outline1->topleft.x + outline1->botright.x) / 2),
|
||||
static_cast<int16_t>((outline1->topleft.y + outline1->botright.y) / 2));
|
||||
int mid_prod1 = CROSS(mid_pt1, vertical);
|
||||
int min_prod1, max_prod1;
|
||||
outline1->MinMaxCrossProduct(vertical, &min_prod1, &max_prod1);
|
||||
for (TESSLINE* outline2 = outline1->next; outline2 != nullptr;
|
||||
outline2 = outline2->next) {
|
||||
if (outline2->is_hole)
|
||||
continue; // Holes do not count as separable.
|
||||
TPOINT mid_pt2(
|
||||
static_cast<int16_t>((outline2->topleft.x + outline2->botright.x) / 2),
|
||||
static_cast<int16_t>((outline2->topleft.y + outline2->botright.y) / 2));
|
||||
if (outline2->is_hole) continue; // Holes do not count as separable.
|
||||
TPOINT mid_pt2(static_cast<int16_t>(
|
||||
(outline2->topleft.x + outline2->botright.x) / 2),
|
||||
static_cast<int16_t>(
|
||||
(outline2->topleft.y + outline2->botright.y) / 2));
|
||||
int mid_prod2 = CROSS(mid_pt2, vertical);
|
||||
int min_prod2, max_prod2;
|
||||
outline2->MinMaxCrossProduct(vertical, &min_prod2, &max_prod2);
|
||||
int mid_gap = abs(mid_prod2 - mid_prod1);
|
||||
int overlap = std::min(max_prod1, max_prod2) - std::max(min_prod1, min_prod2);
|
||||
int overlap =
|
||||
std::min(max_prod1, max_prod2) - std::max(min_prod1, min_prod2);
|
||||
if (mid_gap - overlap / 4 > max_gap) {
|
||||
max_gap = mid_gap - overlap / 4;
|
||||
*location = mid_pt1;
|
||||
@ -978,21 +969,21 @@ bool divisible_blob(TBLOB *blob, bool italic_blob, TPOINT* location) {
|
||||
* other blob. The ones whose x location is less than that point are
|
||||
* retained in the original blob.
|
||||
**********************************************************************/
|
||||
void divide_blobs(TBLOB *blob, TBLOB *other_blob, bool italic_blob,
|
||||
void divide_blobs(TBLOB* blob, TBLOB* other_blob, bool italic_blob,
|
||||
const TPOINT& location) {
|
||||
TPOINT vertical = italic_blob ? kDivisibleVerticalItalic
|
||||
: kDivisibleVerticalUpright;
|
||||
TESSLINE *outline1 = nullptr;
|
||||
TESSLINE *outline2 = nullptr;
|
||||
TPOINT vertical =
|
||||
italic_blob ? kDivisibleVerticalItalic : kDivisibleVerticalUpright;
|
||||
TESSLINE* outline1 = nullptr;
|
||||
TESSLINE* outline2 = nullptr;
|
||||
|
||||
TESSLINE *outline = blob->outlines;
|
||||
TESSLINE* outline = blob->outlines;
|
||||
blob->outlines = nullptr;
|
||||
int location_prod = CROSS(location, vertical);
|
||||
|
||||
while (outline != nullptr) {
|
||||
TPOINT mid_pt(
|
||||
static_cast<int16_t>((outline->topleft.x + outline->botright.x) / 2),
|
||||
static_cast<int16_t>((outline->topleft.y + outline->botright.y) / 2));
|
||||
static_cast<int16_t>((outline->topleft.x + outline->botright.x) / 2),
|
||||
static_cast<int16_t>((outline->topleft.y + outline->botright.y) / 2));
|
||||
int mid_prod = CROSS(mid_pt, vertical);
|
||||
if (mid_prod < location_prod) {
|
||||
// Outline is in left blob.
|
||||
@ -1012,8 +1003,6 @@ void divide_blobs(TBLOB *blob, TBLOB *other_blob, bool italic_blob,
|
||||
outline = outline->next;
|
||||
}
|
||||
|
||||
if (outline1)
|
||||
outline1->next = nullptr;
|
||||
if (outline2)
|
||||
outline2->next = nullptr;
|
||||
if (outline1) outline1->next = nullptr;
|
||||
if (outline2) outline2->next = nullptr;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: crakedge.h (Formerly: crkedge.h)
|
||||
* File: crakedge.h (Formerly: crkedge.h)
|
||||
* Description: Structures for the Crack following edge detector.
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Mar 22 16:06:38 GMT 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Mar 22 16:06:38 GMT 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,11 +17,11 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef CRAKEDGE_H
|
||||
#define CRAKEDGE_H
|
||||
#ifndef CRAKEDGE_H
|
||||
#define CRAKEDGE_H
|
||||
|
||||
#include "points.h"
|
||||
#include "mod128.h"
|
||||
#include "points.h"
|
||||
#include "mod128.h"
|
||||
|
||||
class CRACKEDGE {
|
||||
public:
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: linlsq.cpp (Formerly llsq.c)
|
||||
* Description: Linear Least squares fitting code.
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Sep 12 08:44:51 BST 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Sep 12 08:44:51 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,10 +17,10 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "errcode.h"
|
||||
#include "linlsq.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "errcode.h"
|
||||
#include "linlsq.h"
|
||||
|
||||
const ERRCODE EMPTY_LLSQ = "Can't delete from an empty LLSQ";
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: ocrblock.h (Formerly block.h)
|
||||
* Description: Page block class definition.
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Mar 14 17:32:01 GMT 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Mar 14 17:32:01 GMT 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,12 +17,12 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef OCRBLOCK_H
|
||||
#define OCRBLOCK_H
|
||||
#ifndef OCRBLOCK_H
|
||||
#define OCRBLOCK_H
|
||||
|
||||
#include "ocrpara.h"
|
||||
#include "ocrrow.h"
|
||||
#include "pdblock.h"
|
||||
#include "ocrpara.h"
|
||||
#include "ocrrow.h"
|
||||
#include "pdblock.h"
|
||||
|
||||
class BLOCK; //forward decl
|
||||
|
||||
@ -208,7 +208,7 @@ class BLOCK:public ELIST_LINK
|
||||
FCOORD re_rotation_; //< How to transform coords back to image.
|
||||
FCOORD classify_rotation_; //< Apply this before classifying.
|
||||
FCOORD skew_; //< Direction of true horizontal.
|
||||
ICOORD median_size_; //< Median size of blobs.
|
||||
ICOORD median_size_; //< Median size of blobs.
|
||||
};
|
||||
|
||||
int decreasing_top_order(const void *row1, const void *row2);
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: ocrrow.cpp (Formerly row.c)
|
||||
* Description: Code for the ROW class.
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 15:58:04 BST 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 15:58:04 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,8 +17,8 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "ocrrow.h"
|
||||
#include "blobbox.h"
|
||||
#include "ocrrow.h"
|
||||
#include "blobbox.h"
|
||||
|
||||
// Include automatically generated configuration file if running autoconf.
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: points.cpp (Formerly coords.c)
|
||||
* Description: Member functions for coordinate classes.
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Mar 15 08:58:17 GMT 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Mar 15 08:58:17 GMT 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: polyaprx.h (Formerly polygon.h)
|
||||
* Description: Code for polygonal approximation from old edgeprog.
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Nov 25 11:42:04 GMT 1993
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Nov 25 11:42:04 GMT 1993
|
||||
*
|
||||
* (C) Copyright 1993, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,11 +17,11 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef POLYAPRX_H
|
||||
#define POLYAPRX_H
|
||||
#ifndef POLYAPRX_H
|
||||
#define POLYAPRX_H
|
||||
|
||||
#include "blobs.h"
|
||||
#include "coutln.h"
|
||||
#include "blobs.h"
|
||||
#include "coutln.h"
|
||||
|
||||
// convert a chain-coded input to the old OUTLINE approximation
|
||||
TESSLINE* ApproximateOutline(bool allow_detailed_fx, C_OUTLINE *c_outline);
|
||||
|
@ -1,8 +1,6 @@
|
||||
/**********************************************************************
|
||||
* File: polyblk.h (Formerly poly_block.h)
|
||||
* Description: Polygonal blocks
|
||||
* Author: Sheelagh Lloyd?
|
||||
* Created:
|
||||
*
|
||||
* (C) Copyright 1993, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -16,8 +14,9 @@
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
#ifndef POLYBLK_H
|
||||
#define POLYBLK_H
|
||||
|
||||
#ifndef POLYBLK_H
|
||||
#define POLYBLK_H
|
||||
|
||||
#include "publictypes.h"
|
||||
#include "elst.h"
|
||||
|
@ -278,7 +278,7 @@ enum OcrEngineMode {
|
||||
// command-line configs, or if not specified
|
||||
// in any of the above should be set to the
|
||||
// default OEM_TESSERACT_ONLY.
|
||||
OEM_COUNT // Number of OEMs
|
||||
OEM_COUNT // Number of OEMs
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: quadlsq.cpp (Formerly qlsq.c)
|
||||
* Description: Code for least squares approximation of quadratics.
|
||||
* Author: Ray Smith
|
||||
* Created: Wed Oct 6 15:14:23 BST 1993
|
||||
* Author: Ray Smith
|
||||
* Created: Wed Oct 6 15:14:23 BST 1993
|
||||
*
|
||||
* (C) Copyright 1993, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: quadlsq.h (Formerly qlsq.h)
|
||||
* Description: Code for least squares approximation of quadratics.
|
||||
* Author: Ray Smith
|
||||
* Created: Wed Oct 6 15:14:23 BST 1993
|
||||
* Author: Ray Smith
|
||||
* Created: Wed Oct 6 15:14:23 BST 1993
|
||||
*
|
||||
* (C) Copyright 1993, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,10 +17,10 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef QUADLSQ_H
|
||||
#define QUADLSQ_H
|
||||
#ifndef QUADLSQ_H
|
||||
#define QUADLSQ_H
|
||||
|
||||
#include "points.h"
|
||||
#include "points.h"
|
||||
|
||||
class QLSQ
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: quadratc.h (Formerly quadrtic.h)
|
||||
* Description: Code for the QUAD_COEFFS class.
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 17:24:40 BST 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 17:24:40 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,10 +17,10 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef QUADRATC_H
|
||||
#define QUADRATC_H
|
||||
#ifndef QUADRATC_H
|
||||
#define QUADRATC_H
|
||||
|
||||
#include "points.h"
|
||||
#include "points.h"
|
||||
|
||||
class QUAD_COEFFS
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: rejctmap.cpp (Formerly rejmap.c)
|
||||
* Description: REJ and REJMAP class functions.
|
||||
* Author: Phil Cheatle
|
||||
* Created: Thu Jun 9 13:46:38 BST 1994
|
||||
* Author: Phil Cheatle
|
||||
* Created: Thu Jun 9 13:46:38 BST 1994
|
||||
*
|
||||
* (C) Copyright 1994, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,9 +17,9 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "host.h"
|
||||
#include "rejctmap.h"
|
||||
#include "params.h"
|
||||
#include "host.h"
|
||||
#include "rejctmap.h"
|
||||
#include "params.h"
|
||||
|
||||
bool REJ::perm_rejected() { //Is char perm reject?
|
||||
return (flag (R_TESS_FAILURE) ||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: statistc.h (Formerly stats.h)
|
||||
* Description: Class description for STATS class.
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Feb 04 16:19:07 GMT 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Feb 04 16:19:07 GMT 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: stepblob.cpp (Formerly cblob.c)
|
||||
* Description: Code for C_BLOB class.
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 10:41:13 BST 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 10:41:13 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: stepblob.h (Formerly cblob.h)
|
||||
* Description: Code for C_BLOB class.
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 10:41:13 BST 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Oct 08 10:41:13 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,11 +17,11 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef STEPBLOB_H
|
||||
#define STEPBLOB_H
|
||||
#ifndef STEPBLOB_H
|
||||
#define STEPBLOB_H
|
||||
|
||||
#include "coutln.h"
|
||||
#include "rect.h"
|
||||
#include "coutln.h"
|
||||
#include "rect.h"
|
||||
|
||||
class C_BLOB;
|
||||
struct Pix;
|
||||
|
@ -41,7 +41,7 @@ struct EDGEPT;
|
||||
|
||||
#define point_diff(p,p1,p2) \
|
||||
((p).x = (p1).x - (p2).x, \
|
||||
(p).y = (p1).y - (p2).y)
|
||||
(p).y = (p1).y - (p2).y)
|
||||
|
||||
/**********************************************************************
|
||||
* CROSS
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: bits16.h (Formerly bits8.h)
|
||||
* Description: Code for 8 bit field class.
|
||||
* Author: Phil Cheatle
|
||||
* Created: Thu Oct 17 10:10:05 BST 1991
|
||||
* Author: Phil Cheatle
|
||||
* Created: Thu Oct 17 10:10:05 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,8 +17,8 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef BITS16_H
|
||||
#define BITS16_H
|
||||
#ifndef BITS16_H
|
||||
#define BITS16_H
|
||||
|
||||
#include "host.h"
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**********************************************************************
|
||||
* File: strngs.h (Formerly strings.h)
|
||||
* Description: STRING class definition.
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Feb 15 09:15:01 GMT 1991
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Feb 15 09:15:01 GMT 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,10 +1,10 @@
|
||||
/******************************************************************************
|
||||
** Filename: adaptive.h
|
||||
** Purpose: Interface to adaptive matcher.
|
||||
** Author: Dan Johnson
|
||||
** History: Fri Mar 8 10:00:49 1991, DSJ, Created.
|
||||
** Filename: adaptive.h
|
||||
** Purpose: Interface to adaptive matcher.
|
||||
** Author: Dan Johnson
|
||||
** History: Fri Mar 8 10:00:49 1991, DSJ, Created.
|
||||
**
|
||||
** (c) Copyright Hewlett-Packard Company, 1988.
|
||||
** (c) Copyright Hewlett-Packard Company, 1988.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
@ -89,22 +89,22 @@ typedef ADAPT_TEMPLATES_STRUCT *ADAPT_TEMPLATES;
|
||||
#define IsEmptyAdaptedClass(Class) ((Class)->NumPermConfigs == 0 && \
|
||||
(Class)->TempProtos == NIL_LIST)
|
||||
|
||||
#define ConfigIsPermanent(Class,ConfigId) \
|
||||
#define ConfigIsPermanent(Class,ConfigId) \
|
||||
(test_bit ((Class)->PermConfigs, ConfigId))
|
||||
|
||||
#define MakeConfigPermanent(Class,ConfigId) \
|
||||
#define MakeConfigPermanent(Class,ConfigId) \
|
||||
(SET_BIT ((Class)->PermConfigs, ConfigId))
|
||||
|
||||
#define MakeProtoPermanent(Class,ProtoId) \
|
||||
#define MakeProtoPermanent(Class,ProtoId) \
|
||||
(SET_BIT ((Class)->PermProtos, ProtoId))
|
||||
|
||||
#define TempConfigFor(Class,ConfigId) \
|
||||
#define TempConfigFor(Class,ConfigId) \
|
||||
((Class)->Config[ConfigId].Temp)
|
||||
|
||||
#define PermConfigFor(Class,ConfigId) \
|
||||
#define PermConfigFor(Class,ConfigId) \
|
||||
((Class)->Config[ConfigId].Perm)
|
||||
|
||||
#define IncreaseConfidence(TempConfig) \
|
||||
#define IncreaseConfidence(TempConfig) \
|
||||
((TempConfig)->NumTimesSeen++)
|
||||
|
||||
void AddAdaptedClass(ADAPT_TEMPLATES Templates,
|
||||
|
Loading…
Reference in New Issue
Block a user