Source code for textfeat
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.1
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0):
raise RuntimeError("Python 2.7 or later required")
import _swigTextFeatExtractor
try:
import builtins as __builtin__
except ImportError:
import __builtin__
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
def _swig_setattr_nondynamic_instance_variable(set):
def set_instance_attr(self, name, value):
if name == "thisown":
self.this.own(value)
elif name == "this":
set(self, name, value)
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
set(self, name, value)
else:
raise AttributeError("You cannot add instance attributes to %s" % self)
return set_instance_attr
def _swig_setattr_nondynamic_class_variable(set):
def set_class_attr(cls, name, value):
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
set(cls, name, value)
else:
raise AttributeError("You cannot add class attributes to %s" % cls)
return set_class_attr
def _swig_add_metaclass(metaclass):
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
def wrapper(cls):
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
return wrapper
class _SwigNonDynamicMeta(type):
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
class SwigPyIterator(object):
r"""Proxy of C++ swig::SwigPyIterator class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
__swig_destroy__ = _swigTextFeatExtractor.delete_SwigPyIterator
def value(self):
r"""value(self) -> PyObject *"""
return _swigTextFeatExtractor.SwigPyIterator_value(self)
def incr(self, n=1):
r"""
incr(self, n=1) -> SwigPyIterator
Parameters
----------
n: size_t
"""
return _swigTextFeatExtractor.SwigPyIterator_incr(self, n)
def decr(self, n=1):
r"""
decr(self, n=1) -> SwigPyIterator
Parameters
----------
n: size_t
"""
return _swigTextFeatExtractor.SwigPyIterator_decr(self, n)
def distance(self, x):
r"""
distance(self, x) -> ptrdiff_t
Parameters
----------
x: swig::SwigPyIterator const &
"""
return _swigTextFeatExtractor.SwigPyIterator_distance(self, x)
def equal(self, x):
r"""
equal(self, x) -> bool
Parameters
----------
x: swig::SwigPyIterator const &
"""
return _swigTextFeatExtractor.SwigPyIterator_equal(self, x)
def copy(self):
r"""copy(self) -> SwigPyIterator"""
return _swigTextFeatExtractor.SwigPyIterator_copy(self)
def next(self):
r"""next(self) -> PyObject *"""
return _swigTextFeatExtractor.SwigPyIterator_next(self)
def __next__(self):
r"""__next__(self) -> PyObject *"""
return _swigTextFeatExtractor.SwigPyIterator___next__(self)
def previous(self):
r"""previous(self) -> PyObject *"""
return _swigTextFeatExtractor.SwigPyIterator_previous(self)
def advance(self, n):
r"""
advance(self, n) -> SwigPyIterator
Parameters
----------
n: ptrdiff_t
"""
return _swigTextFeatExtractor.SwigPyIterator_advance(self, n)
def __eq__(self, x):
r"""
__eq__(self, x) -> bool
Parameters
----------
x: swig::SwigPyIterator const &
"""
return _swigTextFeatExtractor.SwigPyIterator___eq__(self, x)
def __ne__(self, x):
r"""
__ne__(self, x) -> bool
Parameters
----------
x: swig::SwigPyIterator const &
"""
return _swigTextFeatExtractor.SwigPyIterator___ne__(self, x)
def __iadd__(self, n):
r"""
__iadd__(self, n) -> SwigPyIterator
Parameters
----------
n: ptrdiff_t
"""
return _swigTextFeatExtractor.SwigPyIterator___iadd__(self, n)
def __isub__(self, n):
r"""
__isub__(self, n) -> SwigPyIterator
Parameters
----------
n: ptrdiff_t
"""
return _swigTextFeatExtractor.SwigPyIterator___isub__(self, n)
def __add__(self, n):
r"""
__add__(self, n) -> SwigPyIterator
Parameters
----------
n: ptrdiff_t
"""
return _swigTextFeatExtractor.SwigPyIterator___add__(self, n)
def __sub__(self, *args):
r"""
__sub__(self, n) -> SwigPyIterator
Parameters
----------
n: ptrdiff_t
__sub__(self, x) -> ptrdiff_t
Parameters
----------
x: swig::SwigPyIterator const &
"""
return _swigTextFeatExtractor.SwigPyIterator___sub__(self, *args)
def __iter__(self):
return self
# Register SwigPyIterator in _swigTextFeatExtractor:
_swigTextFeatExtractor.SwigPyIterator_swigregister(SwigPyIterator)
[docs]class ptr_float(object):
r"""Proxy of C++ ptr_float class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self):
r"""__init__(self) -> ptr_float"""
_swigTextFeatExtractor.ptr_float_swiginit(self, _swigTextFeatExtractor.new_ptr_float())
__swig_destroy__ = _swigTextFeatExtractor.delete_ptr_float
[docs] def assign(self, value):
r"""
assign(self, value)
Parameters
----------
value: float
"""
return _swigTextFeatExtractor.ptr_float_assign(self, value)
[docs] def value(self):
r"""value(self) -> float"""
return _swigTextFeatExtractor.ptr_float_value(self)
[docs] def cast(self):
r"""cast(self) -> float *"""
return _swigTextFeatExtractor.ptr_float_cast(self)
[docs] @staticmethod
def frompointer(t):
r"""
frompointer(t) -> ptr_float
Parameters
----------
t: float *
"""
return _swigTextFeatExtractor.ptr_float_frompointer(t)
# Register ptr_float in _swigTextFeatExtractor:
_swigTextFeatExtractor.ptr_float_swigregister(ptr_float)
[docs]def ptr_float_frompointer(t):
r"""
ptr_float_frompointer(t) -> ptr_float
Parameters
----------
t: float *
"""
return _swigTextFeatExtractor.ptr_float_frompointer(t)
TEXTFEAT_TYPE_DOTMATRIX = _swigTextFeatExtractor.TEXTFEAT_TYPE_DOTMATRIX
TEXTFEAT_TYPE_RAW = _swigTextFeatExtractor.TEXTFEAT_TYPE_RAW
TEXTFEAT_FORMAT_ASCII = _swigTextFeatExtractor.TEXTFEAT_FORMAT_ASCII
TEXTFEAT_FORMAT_HTK = _swigTextFeatExtractor.TEXTFEAT_FORMAT_HTK
TEXTFEAT_FORMAT_IMAGE = _swigTextFeatExtractor.TEXTFEAT_FORMAT_IMAGE
[docs]class TextFeatExtractor(object):
r"""Proxy of C++ TextFeatExtractor class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
featTypes = property(_swigTextFeatExtractor.TextFeatExtractor_featTypes_get, _swigTextFeatExtractor.TextFeatExtractor_featTypes_set, doc=r"""featTypes""")
formatNames = property(_swigTextFeatExtractor.TextFeatExtractor_formatNames_get, _swigTextFeatExtractor.TextFeatExtractor_formatNames_set, doc=r"""formatNames""")
[docs] @staticmethod
def version():
r"""version() -> char *"""
return _swigTextFeatExtractor.TextFeatExtractor_version()
def __init__(self, *args, **kwargs):
r"""
__init__(self, featype=TEXTFEAT_TYPE_RAW, format=TEXTFEAT_FORMAT_IMAGE, verbose=False, procimgs=False, stretch=True, enh=True, enh_type=ENH_SAUVOLA, enh_win=20, enh_slp=0.5, enh_prm=0.2, enh_prm_randmin=0.05, enh_prm_randmax=0.3, enh3_prm0=0.0, enh3_prm2=0.0, deslope=True, deslant=True, deslant_min=-6.0, deslant_max=48.0, deslant_step=1.0, deslant_hsteps=4, slant_rand=0.0, scale_rand=0.0, normxheight=0, normheight=64, momentnorm=True, minheight=16, maxwidth=4000, compute_fpgram=True, compute_fcontour=True, fcontour_dilate=4.0, padding=12, ypadding=0) -> TextFeatExtractor
Parameters
----------
featype: int
format: int
verbose: bool
procimgs: bool
stretch: bool
enh: bool
enh_type: int
enh_win: int
enh_slp: float
enh_prm: float
enh_prm_randmin: float
enh_prm_randmax: float
enh3_prm0: float
enh3_prm2: float
deslope: bool
deslant: bool
deslant_min: float
deslant_max: float
deslant_step: float
deslant_hsteps: int
slant_rand: float
scale_rand: float
normxheight: int
normheight: int
momentnorm: bool
minheight: int
maxwidth: int
compute_fpgram: bool
compute_fcontour: bool
fcontour_dilate: float
padding: int
ypadding: int
"""
_swigTextFeatExtractor.TextFeatExtractor_swiginit(self, _swigTextFeatExtractor.new_TextFeatExtractor(*args, **kwargs))
[docs] def printConf(self, *args, **kwargs):
r"""
printConf(self, file=stdout)
Parameters
----------
file: FILE *
"""
return _swigTextFeatExtractor.TextFeatExtractor_printConf(self, *args, **kwargs)
[docs] def preprocess(self, cvimg, _fcontour=None, randomize=False):
r"""
preprocess(self, cvimg, _fcontour=None, randomize=False)
Parameters
----------
cvimg: cv::Mat &
_fcontour: std::vector< cv::Point,std::allocator< cv::Point > > *
randomize: bool
"""
return _swigTextFeatExtractor.TextFeatExtractor_preprocess(self, cvimg, _fcontour, randomize)
[docs] def estimateAngles(self, cvimg, _slope, _slant, rotate=0.0):
r"""
estimateAngles(self, cvimg, _slope, _slant, rotate=0.0)
Parameters
----------
cvimg: cv::Mat &
_slope: float *
_slant: float *
rotate: float
"""
return _swigTextFeatExtractor.TextFeatExtractor_estimateAngles(self, cvimg, _slope, _slant, rotate)
[docs] def extractFeats(self, *args, **kwargs):
r"""
extractFeats(self, feaimg, slope=0.0, slant=0.0, xheight=0, _fpgram=None, randomize=False, rotate=0.0, direction=PAGEXML_READ_DIRECTION_LTR) -> cv::Mat
Parameters
----------
feaimg: cv::Mat &
slope: float
slant: float
xheight: int
_fpgram: std::vector< cv::Point2f,std::allocator< cv::Point2f > > *
randomize: bool
rotate: float
direction: int
"""
return _swigTextFeatExtractor.TextFeatExtractor_extractFeats(self, *args, **kwargs)
[docs] def extract(self, image, rotate=0.0, _slope=None, _slant=None, _fpgram=None, _fcontour=None):
r"""
extract(self, image, rotate=0.0, _slope=None, _slant=None, _fpgram=None, _fcontour=None) -> cv::Mat
Parameters
----------
image: cv::Mat &
rotate: float
_slope: float *
_slant: float *
_fpgram: std::vector< cv::Point2f,std::allocator< cv::Point2f > > *
_fcontour: std::vector< cv::Point,std::allocator< cv::Point > > *
"""
return _swigTextFeatExtractor.TextFeatExtractor_extract(self, image, rotate, _slope, _slant, _fpgram, _fcontour)
[docs] def isImageFormat(self):
r"""isImageFormat(self) -> bool"""
return _swigTextFeatExtractor.TextFeatExtractor_isImageFormat(self)
[docs] def write(self, *args):
r"""
write(self, feats, file=stdout)
Parameters
----------
feats: cv::Mat const &
file: FILE *
write(self, feats, fname)
Parameters
----------
feats: cv::Mat const &
fname: char const *
"""
return _swigTextFeatExtractor.TextFeatExtractor_write(self, *args)
__swig_destroy__ = _swigTextFeatExtractor.delete_TextFeatExtractor
# Register TextFeatExtractor in _swigTextFeatExtractor:
_swigTextFeatExtractor.TextFeatExtractor_swigregister(TextFeatExtractor)
cvar = _swigTextFeatExtractor.cvar
[docs]def TextFeatExtractor_version():
r"""TextFeatExtractor_version() -> char *"""
return _swigTextFeatExtractor.TextFeatExtractor_version()