mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-30 23:49:05 +08:00
023e1b340e
* api: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccmain: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccstruct: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * classify: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * cutil: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * dict: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * textord: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * training: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * wordrec: Replace Tesseract data types by POSIX data types Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccutil: Replace Tesseract data types by POSIX data types Now all Tesseract data types which are no longer needed can be removed from ccutil/host.h. Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX Remove the macros which are now unused from ccutil/host.h. Remove also the obsolete history comments. Signed-off-by: Stefan Weil <sw@weilnetz.de> * Fix build error caused by ambiguous ClipToRange Error message vom Appveyor CI: C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj] C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj] c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange' C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char' C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int' Signed-off-by: Stefan Weil <sw@weilnetz.de> * unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de> * arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX Signed-off-by: Stefan Weil <sw@weilnetz.de>
166 lines
5.1 KiB
C++
166 lines
5.1 KiB
C++
/**********************************************************************
|
|
* File: ocrrow.h (Formerly row.h)
|
|
* Description: Code for the ROW class.
|
|
* 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");
|
|
** you may not use this file except in compliance with the License.
|
|
** You may obtain a copy of the License at
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
** See the License for the specific language governing permissions and
|
|
** limitations under the License.
|
|
*
|
|
**********************************************************************/
|
|
|
|
#ifndef OCRROW_H
|
|
#define OCRROW_H
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "quspline.h"
|
|
#include "werd.h"
|
|
|
|
class TO_ROW;
|
|
|
|
struct PARA;
|
|
|
|
class ROW:public ELIST_LINK
|
|
{
|
|
friend void tweak_row_baseline(ROW *, double, double);
|
|
public:
|
|
ROW() {
|
|
} //empty constructor
|
|
ROW( //constructor
|
|
int32_t spline_size, //no of segments
|
|
int32_t *xstarts, //segment boundaries
|
|
double *coeffs, //coefficients //ascender size
|
|
float x_height,
|
|
float ascenders,
|
|
float descenders, //descender size
|
|
int16_t kern, //char gap
|
|
int16_t space); //word gap
|
|
ROW( //constructor
|
|
TO_ROW *row, //textord row
|
|
int16_t kern, //char gap
|
|
int16_t space); //word gap
|
|
|
|
WERD_LIST *word_list() { //get words
|
|
return &words;
|
|
}
|
|
|
|
float base_line( //compute baseline
|
|
float xpos) const { //at the position
|
|
//get spline value
|
|
return (float) baseline.y (xpos);
|
|
}
|
|
float x_height() const { //return x height
|
|
return xheight;
|
|
}
|
|
void set_x_height(float new_xheight) { // set x height
|
|
xheight = new_xheight;
|
|
}
|
|
int32_t kern() const { //return kerning
|
|
return kerning;
|
|
}
|
|
float body_size() const { //return body size
|
|
return bodysize;
|
|
}
|
|
void set_body_size(float new_size) { // set body size
|
|
bodysize = new_size;
|
|
}
|
|
int32_t space() const { //return spacing
|
|
return spacing;
|
|
}
|
|
float ascenders() const { //return size
|
|
return ascrise;
|
|
}
|
|
float descenders() const { //return size
|
|
return descdrop;
|
|
}
|
|
TBOX bounding_box() const { //return bounding box
|
|
return bound_box;
|
|
}
|
|
// Returns the bounding box including the desired combination of upper and
|
|
// lower noise/diacritic elements.
|
|
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const;
|
|
|
|
void set_lmargin(int16_t lmargin) {
|
|
lmargin_ = lmargin;
|
|
}
|
|
void set_rmargin(int16_t rmargin) {
|
|
rmargin_ = rmargin;
|
|
}
|
|
int16_t lmargin() const {
|
|
return lmargin_;
|
|
}
|
|
int16_t rmargin() const {
|
|
return rmargin_;
|
|
}
|
|
|
|
void set_has_drop_cap(bool has) {
|
|
has_drop_cap_ = has;
|
|
}
|
|
bool has_drop_cap() const {
|
|
return has_drop_cap_;
|
|
}
|
|
|
|
void set_para(PARA *p) {
|
|
para_ = p;
|
|
}
|
|
PARA *para() const {
|
|
return para_;
|
|
}
|
|
|
|
void recalc_bounding_box(); //recalculate BB
|
|
|
|
void move( // reposition row
|
|
const ICOORD vec); // by vector
|
|
|
|
void print( //print
|
|
FILE *fp); //file to print on
|
|
|
|
#ifndef GRAPHICS_DISABLED
|
|
void plot( //draw one
|
|
ScrollView* window, //window to draw in
|
|
ScrollView::Color colour); //uniform colour
|
|
void plot( //draw one
|
|
ScrollView* window); //in rainbow colours
|
|
|
|
void plot_baseline( //draw the baseline
|
|
ScrollView* window, //window to draw in
|
|
ScrollView::Color colour) { //colour to draw
|
|
//draw it
|
|
baseline.plot (window, colour);
|
|
}
|
|
#endif // GRAPHICS_DISABLED
|
|
ROW& operator= (const ROW & source);
|
|
|
|
private:
|
|
int32_t kerning; //inter char gap
|
|
int32_t spacing; //inter word gap
|
|
TBOX bound_box; //bounding box
|
|
float xheight; //height of line
|
|
float ascrise; //size of ascenders
|
|
float descdrop; //-size of descenders
|
|
float bodysize; //CJK character size. (equals to
|
|
//xheight+ascrise by default)
|
|
WERD_LIST words; //words
|
|
QSPLINE baseline; //baseline spline
|
|
|
|
// These get set after blocks have been determined.
|
|
bool has_drop_cap_;
|
|
int16_t lmargin_; // Distance to left polyblock margin.
|
|
int16_t rmargin_; // Distance to right polyblock margin.
|
|
|
|
// This gets set during paragraph analysis.
|
|
PARA *para_; // Paragraph of which this row is part.
|
|
};
|
|
|
|
ELISTIZEH (ROW)
|
|
#endif
|