Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christoph Wick
ocropy
Commits
69e8592d
Commit
69e8592d
authored
Nov 01, 2014
by
Tom Breuel
Browse files
Small cleanups after removing files.
parent
57a666e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
ocrolib/native.py
View file @
69e8592d
...
...
@@ -5,6 +5,7 @@
import
os
,
hashlib
from
ctypes
import
c_int
,
c_float
,
c_double
,
c_byte
from
numpy.ctypeslib
import
ndpointer
import
ctypes
import
time
import
errno
...
...
@@ -13,9 +14,9 @@ import contextlib
@
contextlib
.
contextmanager
def
lockfile
(
fname
,
delay
=
0.5
):
while
1
:
try
:
try
:
fd
=
os
.
open
(
fname
,
os
.
O_RDWR
|
os
.
O_CREAT
|
os
.
O_EXCL
)
except
OSError
as
e
:
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
EEXIST
:
raise
time
.
sleep
(
delay
)
continue
...
...
ocrolib/toplevel.py
View file @
69e8592d
...
...
@@ -4,6 +4,7 @@ import numpy
import
os
import
sys
import
warnings
from
types
import
NoneType
# FIXME from ... import wrap
### printing
...
...
@@ -150,7 +151,7 @@ class CheckWarning(CheckError):
def
checktype
(
value
,
type_
):
"""Check value against the type spec. If everything
is OK, this just returns the value itself.
is OK, this just returns the value itself.
If the types don't check out, an exception is thrown."""
# True skips any check
if
type_
is
True
:
...
...
@@ -245,7 +246,7 @@ def ANY(*checks):
pass
raise
CheckError
(
x
,
": failed all checks:"
,[
strc
(
x
)
for
x
in
checks
])
return
CHK_
@
makeargcheck
(
"value should be type book or 0/1"
)
def
BOOL
(
x
):
...
...
@@ -292,7 +293,7 @@ int_dtypes = [numpy.dtype('uint8'),numpy.dtype('int32'),numpy.dtype('int64'),num
@
makeargcheck
(
"array must contain integer values"
)
def
AINT
(
a
):
return
a
.
dtype
in
int_dtypes
return
a
.
dtype
in
int_dtypes
@
makeargcheck
(
"expected a byte (uint8) array"
)
def
ABYTE
(
a
):
...
...
@@ -408,10 +409,10 @@ def SEGMENTATION(a):
return
isinstance
(
a
,
numpy
.
ndarray
)
and
a
.
ndim
==
2
and
a
.
dtype
in
[
'int32'
,
'int64'
]
@
makeargcheck
(
"expected a segmentation with white background"
)
def
WHITESEG
(
a
):
return
numpy
.
amax
(
a
)
==
0xffffff
return
numpy
.
amax
(
a
)
==
0xffffff
@
makeargcheck
(
"expected a segmentation with black background"
)
def
BLACKSEG
(
a
):
return
numpy
.
amax
(
a
)
<
0xffffff
return
numpy
.
amax
(
a
)
<
0xffffff
@
makeargcheck
(
"all non-zero pixels in a page segmentation must have a column value >0"
)
def
PAGEEXTRA
(
a
):
u
=
numpy
.
unique
(
a
)
...
...
ocropus-visualize-results
View file @
69e8592d
...
...
@@ -2,13 +2,11 @@
import
matplotlib
matplotlib
.
use
(
"AGG"
)
import
sys
,
os
,
signal
from
scipy.ndimage
import
interpolation
import
pylab
from
pylab
import
*
import
glob
import
ocrolib
from
ocrolib
import
linerec
,
morph
from
scipy.misc
import
imsave
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment