2007-03-08 04:03:40 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2019-03-12 01:56:55 +08:00
|
|
|
* File: blkocc.h (Formerly blockocc.h)
|
2007-03-08 04:03:40 +08:00
|
|
|
* Description: Block Occupancy routines
|
|
|
|
* Author: Chris Newton
|
|
|
|
*
|
|
|
|
* (c) Copyright 1991, Hewlett-Packard Company.
|
|
|
|
** 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 BLKOCC_H
|
|
|
|
#define BLKOCC_H
|
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
#include "params.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
#include "elst.h"
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
CLASS REGION_OCC
|
|
|
|
|
|
|
|
The class REGION_OCC defines a section of outline which exists entirely
|
|
|
|
within a single region. The only data held is the min and max x limits of
|
|
|
|
the outline within the region.
|
|
|
|
|
|
|
|
REGION_OCCs are held on lists, one list for each region. The lists are
|
|
|
|
built in sorted order of min x. Overlapping REGION_OCCs are not permitted on
|
|
|
|
a single list. An overlapping region to be added causes the existing region
|
|
|
|
to be extended. This extension may result in the following REGION_OCC on the
|
2015-11-04 16:53:38 +08:00
|
|
|
list overlapping the amended one. In this case the amended REGION_OCC is
|
2007-03-08 04:03:40 +08:00
|
|
|
further extended to include the range of the following one, so that the
|
|
|
|
following one can be deleted.
|
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
class REGION_OCC:public ELIST_LINK
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
float min_x; //Lowest x in region
|
|
|
|
float max_x; //Highest x in region
|
Use POSIX data types and macros (#878)
* 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>
2018-03-14 04:36:30 +08:00
|
|
|
int16_t region_type; //Type of crossing
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2018-05-21 07:36:56 +08:00
|
|
|
REGION_OCC() = default; // constructor used
|
2016-12-07 05:45:49 +08:00
|
|
|
// only in COPIER etc
|
2007-03-08 04:03:40 +08:00
|
|
|
REGION_OCC( //constructor
|
|
|
|
float min,
|
|
|
|
float max,
|
Use POSIX data types and macros (#878)
* 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>
2018-03-14 04:36:30 +08:00
|
|
|
int16_t region) {
|
2007-03-08 04:03:40 +08:00
|
|
|
min_x = min;
|
|
|
|
max_x = max;
|
|
|
|
region_type = region;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ELISTIZEH (REGION_OCC)
|
2018-09-29 14:21:14 +08:00
|
|
|
#define RANGE_IN_BAND(band_max, band_min, range_max, range_min) \
|
|
|
|
(((range_min) >= (band_min)) && ((range_max) < (band_max)))
|
2007-03-08 04:03:40 +08:00
|
|
|
/************************************************************************
|
|
|
|
Adapted from the following procedure so that it can be used in the bands
|
|
|
|
class in an include file...
|
|
|
|
|
2016-11-08 02:46:33 +08:00
|
|
|
BOOL8 range_in_band[
|
2007-03-08 04:03:40 +08:00
|
|
|
range within band?
|
Use POSIX data types and macros (#878)
* 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>
2018-03-14 04:36:30 +08:00
|
|
|
int16_t band_max,
|
|
|
|
int16_t band_min,
|
|
|
|
int16_t range_max,
|
|
|
|
int16_t range_min]
|
2007-03-08 04:03:40 +08:00
|
|
|
{
|
2018-09-29 14:12:33 +08:00
|
|
|
if ((range_min >= band_min) && (range_max < band_max))
|
2007-03-08 04:03:40 +08:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
***********************************************************************/
|
2018-09-29 14:21:14 +08:00
|
|
|
#define RANGE_OVERLAPS_BAND(band_max, band_min, range_max, range_min) \
|
|
|
|
(((range_max) >= (band_min)) && ((range_min) < (band_max)))
|
2007-03-08 04:03:40 +08:00
|
|
|
/************************************************************************
|
|
|
|
Adapted from the following procedure so that it can be used in the bands
|
|
|
|
class in an include file...
|
|
|
|
|
2016-11-08 02:46:33 +08:00
|
|
|
BOOL8 range_overlaps_band[
|
2007-03-08 04:03:40 +08:00
|
|
|
range crosses band?
|
Use POSIX data types and macros (#878)
* 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>
2018-03-14 04:36:30 +08:00
|
|
|
int16_t band_max,
|
|
|
|
int16_t band_min,
|
|
|
|
int16_t range_max,
|
|
|
|
int16_t range_min]
|
2007-03-08 04:03:40 +08:00
|
|
|
{
|
2018-09-29 14:12:33 +08:00
|
|
|
if ((range_max >= band_min) && (range_min < band_max))
|
2007-03-08 04:03:40 +08:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
***********************************************************************/
|
|
|
|
/**********************************************************************
|
|
|
|
Bands
|
|
|
|
-----
|
|
|
|
|
|
|
|
BAND 4
|
|
|
|
--------------------------------
|
|
|
|
BAND 3
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
BAND 2
|
|
|
|
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
BAND 1
|
|
|
|
|
|
|
|
Band 0 is the dot band
|
|
|
|
|
|
|
|
Each band has an error margin above and below. An outline is not considered to
|
|
|
|
have significantly changed bands until it has moved out of the error margin.
|
|
|
|
*************************************************************************/
|
|
|
|
class BAND
|
|
|
|
{
|
|
|
|
public:
|
Use POSIX data types and macros (#878)
* 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>
2018-03-14 04:36:30 +08:00
|
|
|
int16_t max_max; //upper max
|
|
|
|
int16_t max; //nominal max
|
|
|
|
int16_t min_max; //lower max
|
|
|
|
int16_t max_min; //upper min
|
|
|
|
int16_t min; //nominal min
|
|
|
|
int16_t min_min; //lower min
|
2008-04-22 08:34:11 +08:00
|
|
|
|
2018-05-21 07:36:56 +08:00
|
|
|
BAND() = default; // constructor
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
void set( // initialise a band
|
Use POSIX data types and macros (#878)
* 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>
2018-03-14 04:36:30 +08:00
|
|
|
int16_t new_max_max, // upper max
|
|
|
|
int16_t new_max, // new nominal max
|
|
|
|
int16_t new_min_max, // new lower max
|
|
|
|
int16_t new_max_min, // new upper min
|
|
|
|
int16_t new_min, // new nominal min
|
|
|
|
int16_t new_min_min) { // new lower min
|
2007-03-08 04:03:40 +08:00
|
|
|
max_max = new_max_max;
|
|
|
|
max = new_max;
|
|
|
|
min_max = new_min_max;
|
|
|
|
max_min = new_max_min;
|
|
|
|
min = new_min;
|
|
|
|
min_min = new_min_min;
|
|
|
|
}
|
|
|
|
|
2018-05-21 03:46:46 +08:00
|
|
|
bool in_minimal( //in minimal limits?
|
|
|
|
float y) { //y value
|
|
|
|
return (y >= max_min) && (y < min_max);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
2018-05-21 03:46:46 +08:00
|
|
|
bool in_nominal( //in nominal limits?
|
|
|
|
float y) { //y value
|
|
|
|
return (y >= min) && (y < max);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
2018-05-21 03:46:46 +08:00
|
|
|
bool in_maximal( //in maximal limits?
|
|
|
|
float y) { //y value
|
|
|
|
return (y >= min_min) && (y < max_max);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//overlaps min limits?
|
2018-05-21 03:46:46 +08:00
|
|
|
bool range_overlaps_minimal(float y1, //one range limit
|
|
|
|
float y2) { //other range limit
|
2007-03-08 04:03:40 +08:00
|
|
|
if (y1 > y2)
|
|
|
|
return RANGE_OVERLAPS_BAND (min_max, max_min, y1, y2);
|
|
|
|
else
|
|
|
|
return RANGE_OVERLAPS_BAND (min_max, max_min, y2, y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//overlaps nom limits?
|
2018-05-21 03:46:46 +08:00
|
|
|
bool range_overlaps_nominal(float y1, //one range limit
|
|
|
|
float y2) { //other range limit
|
2007-03-08 04:03:40 +08:00
|
|
|
if (y1 > y2)
|
|
|
|
return RANGE_OVERLAPS_BAND (max, min, y1, y2);
|
|
|
|
else
|
|
|
|
return RANGE_OVERLAPS_BAND (max, min, y2, y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//overlaps max limits?
|
2018-05-21 03:46:46 +08:00
|
|
|
bool range_overlaps_maximal(float y1, //one range limit
|
|
|
|
float y2) { //other range limit
|
2007-03-08 04:03:40 +08:00
|
|
|
if (y1 > y2)
|
|
|
|
return RANGE_OVERLAPS_BAND (max_max, min_min, y1, y2);
|
|
|
|
else
|
|
|
|
return RANGE_OVERLAPS_BAND (max_max, min_min, y2, y1);
|
|
|
|
}
|
|
|
|
|
2018-05-21 03:46:46 +08:00
|
|
|
bool range_in_minimal( //within min limits?
|
|
|
|
float y1, //one range limit
|
|
|
|
float y2) { //other range limit
|
2007-03-08 04:03:40 +08:00
|
|
|
if (y1 > y2)
|
|
|
|
return RANGE_IN_BAND (min_max, max_min, y1, y2);
|
|
|
|
else
|
|
|
|
return RANGE_IN_BAND (min_max, max_min, y2, y1);
|
|
|
|
}
|
|
|
|
|
2018-05-21 03:46:46 +08:00
|
|
|
bool range_in_nominal( //within nom limits?
|
|
|
|
float y1, //one range limit
|
|
|
|
float y2) { //other range limit
|
2007-03-08 04:03:40 +08:00
|
|
|
if (y1 > y2)
|
|
|
|
return RANGE_IN_BAND (max, min, y1, y2);
|
|
|
|
else
|
|
|
|
return RANGE_IN_BAND (max, min, y2, y1);
|
|
|
|
}
|
|
|
|
|
2018-05-21 03:46:46 +08:00
|
|
|
bool range_in_maximal( //within max limits?
|
|
|
|
float y1, //one range limit
|
|
|
|
float y2) { //other range limit
|
2007-03-08 04:03:40 +08:00
|
|
|
if (y1 > y2)
|
|
|
|
return RANGE_IN_BAND (max_max, min_min, y1, y2);
|
|
|
|
else
|
|
|
|
return RANGE_IN_BAND (max_max, min_min, y2, y1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Standard positions */
|
|
|
|
|
|
|
|
#define MAX_NUM_BANDS 5
|
|
|
|
#define UNDEFINED_BAND 99
|
|
|
|
#define NO_LOWER_LIMIT -9999
|
|
|
|
#define NO_UPPER_LIMIT 9999
|
|
|
|
|
|
|
|
#define DOT_BAND 0
|
|
|
|
|
|
|
|
/* Special occupancy code emitted for the 0 region at the end of a word */
|
|
|
|
|
|
|
|
#define END_OF_WERD_CODE 255
|
|
|
|
|
|
|
|
extern BOOL_VAR_H (blockocc_show_result, FALSE, "Show intermediate results");
|
|
|
|
extern INT_VAR_H (blockocc_desc_height, 0,
|
|
|
|
"Descender height after normalisation");
|
|
|
|
extern INT_VAR_H (blockocc_asc_height, 255,
|
|
|
|
"Ascender height after normalisation");
|
|
|
|
extern INT_VAR_H (blockocc_band_count, 4, "Number of bands used");
|
|
|
|
extern double_VAR_H (textord_underline_threshold, 0.9,
|
|
|
|
"Fraction of width occupied");
|
2011-03-19 05:54:32 +08:00
|
|
|
|
2018-05-21 03:46:46 +08:00
|
|
|
bool test_underline( //look for underlines
|
|
|
|
bool testing_on, //drawing blob
|
|
|
|
C_BLOB* blob, //blob to test
|
|
|
|
int16_t baseline, //coords of baseline
|
|
|
|
int16_t xheight //height of line
|
|
|
|
);
|
2010-07-25 23:23:03 +08:00
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
#endif
|