Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
licenseplates
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
licenseplates
Commits
21c6a08e
Commit
21c6a08e
authored
Dec 02, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed a bunch of unused imports.
parent
d98cdc83
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
32 deletions
+24
-32
src/Error.py
src/Error.py
+3
-3
src/GaussianFilter.py
src/GaussianFilter.py
+8
-8
src/LetterCropper.py
src/LetterCropper.py
+4
-6
src/LicensePlate.py
src/LicensePlate.py
+6
-7
src/LocalBinaryPatternizer.py
src/LocalBinaryPatternizer.py
+0
-1
src/LocalBinaryPatternizerTest.py
src/LocalBinaryPatternizerTest.py
+1
-4
src/combined_test.py
src/combined_test.py
+2
-3
No files found.
src/Error.py
View file @
21c6a08e
import
traceback
,
os
.
path
import
traceback
class
Error
:
def
__init__
(
self
,
message
=
None
):
...
...
@@ -7,11 +7,11 @@ class Error:
where_it_went_wrong
=
stack
[
1
]
if
message
:
print
message
,
"
\
n
"
print
message
,
"
\
n
"
print
"Error in"
,
origin_of_call
[
0
],
"on line"
,
origin_of_call
[
1
]
print
" : "
,
origin_of_call
[
3
],
"
\
n
"
# Inside try function, so -2 lines as exept and Error() are 2 lines
print
"Function called in"
,
where_it_went_wrong
[
0
]
print
"around line"
,
(
where_it_went_wrong
[
1
]
-
2
),
"
\
n
"
\ No newline at end of file
print
"around line"
,
(
where_it_went_wrong
[
1
]
-
2
),
"
\
n
"
src/GaussianFilter.py
View file @
21c6a08e
from
GrayscaleImage
import
GrayscaleImage
from
scipy.ndimage
import
convolve1d
from
pylab
import
ceil
,
zeros
,
pi
,
e
,
e
xp
,
sqrt
,
array
from
pylab
import
ceil
,
zeros
,
pi
,
exp
,
sqrt
,
array
class
GaussianFilter
:
def
__init__
(
self
,
scale
):
self
.
scale
=
scale
def
gaussian
(
self
,
x
):
'''Return the value of a 1D Gaussian function for a given x and scale'''
return
exp
(
-
(
x
**
2
/
(
2
*
self
.
scale
**
2
)))
/
(
sqrt
(
2
*
pi
)
*
self
.
scale
)
...
...
@@ -15,12 +15,12 @@ class GaussianFilter:
'''Sample a one-dimensional Gaussian function of scale s'''
radius
=
int
(
ceil
(
3
*
self
.
scale
))
size
=
2
*
radius
+
1
result
=
zeros
(
size
)
# Sample the Gaussian function
# Sample the Gaussian function
result
=
array
([
self
.
gaussian
(
x
-
radius
)
for
x
in
xrange
(
size
)])
# The sum of all kernel values is equal to one
result
/=
result
.
sum
()
result
/=
result
.
sum
()
return
result
...
...
@@ -29,15 +29,15 @@ class GaussianFilter:
kernel
=
self
.
get_1d_gaussian_kernel
()
image
=
convolve1d
(
image
.
data
,
kernel
,
axis
=
0
,
mode
=
'nearest'
)
return
GrayscaleImage
(
None
,
convolve1d
(
image
,
kernel
,
axis
=
1
,
mode
=
'nearest'
))
def
filter
(
self
,
image
):
kernel
=
self
.
get_1d_gaussian_kernel
()
image
.
data
=
convolve1d
(
image
.
data
,
kernel
,
axis
=
0
,
mode
=
'nearest'
)
image
.
data
=
convolve1d
(
image
.
data
,
kernel
,
axis
=
1
,
mode
=
'nearest'
)
def
get_scale
(
self
):
return
self
.
scale
def
set_scale
(
self
,
scale
):
self
.
scale
=
float
(
scale
)
...
...
src/LetterCropper.py
View file @
21c6a08e
from
copy
import
deepcopy
from
Rectangle
import
Rectangle
from
GrayscaleImage
import
GrayscaleImage
class
LetterCropper
:
def
__init__
(
self
,
threshold
=
0.9
):
self
.
threshold
=
threshold
def
crop_to_letter
(
self
,
image
):
self
.
image
=
image
self
.
determine_letter_bounds
()
...
...
@@ -24,10 +22,10 @@ class LetterCropper:
if
y
<
min_y
:
min_y
=
y
if
x
>
max_x
:
max_x
=
x
if
y
>
max_y
:
max_y
=
y
self
.
letter_bounds
=
Rectangle
(
min_x
,
min_y
,
min_x
,
min_y
,
max_x
-
min_x
,
max_y
-
min_y
)
src/LicensePlate.py
View file @
21c6a08e
from
pylab
import
array
,
zeros
,
inv
,
dot
,
svd
,
shape
,
floor
from
pylab
import
array
,
zeros
,
inv
,
dot
,
svd
,
floor
from
xml.dom.minidom
import
parse
from
Error
import
Error
from
Point
import
Point
from
Character
import
Character
from
GrayscaleImage
import
GrayscaleImage
from
NormalizedCharacterImage
import
NormalizedCharacterImage
'''
Creates a license plate object based on an XML file. The image should be
placed in a folder 'images' the xml file in a folder 'xml'
"""
Creates a license plate object based on an XML file. The image should be
placed in a folder 'images' the xml file in a folder 'xml'
TODO: perhaps remove non required XML lookups
'''
TODO: perhaps remove non required XML lookups
"""
class
LicensePlate
:
def
__init__
(
self
,
folder_nr
,
file_nr
):
...
...
src/LocalBinaryPatternizer.py
View file @
21c6a08e
from
Histogram
import
Histogram
from
numpy
import
zeros
,
byte
from
math
import
ceil
class
LocalBinaryPatternizer
:
...
...
src/LocalBinaryPatternizerTest.py
View file @
21c6a08e
from
GrayscaleImage
import
GrayscaleImage
from
LocalBinaryPatternizer
import
LocalBinaryPatternizer
from
LetterCropper
import
LetterCropper
from
matplotlib.pyplot
import
imshow
,
subplot
,
show
,
axis
,
bar
from
numpy
import
arange
image
=
GrayscaleImage
(
"../images/test.png"
)
lbp
=
LocalBinaryPatternizer
(
image
)
histograms
=
lbp
.
create_features_vector
()
print
histograms
\ No newline at end of file
print
histograms
src/combined_test.py
View file @
21c6a08e
from
GrayscaleImage
import
GrayscaleImage
from
NormalizedCharacterImage
import
NormalizedCharacterImage
from
LetterCropper
import
LetterCropper
from
NormalizedCharacterImage
import
NormalizedCharacterImage
image
=
GrayscaleImage
(
"../images/test10.png"
)
normalized_character_image
=
NormalizedCharacterImage
(
image
)
normalized_character_image
.
show
()
\ No newline at end of file
normalized_character_image
.
show
()
Write
Preview
Markdown
is supported
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