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
1019d0cb
Commit
1019d0cb
authored
Dec 21, 2011
by
Jayke Meijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:taddeus/licenseplates
parents
3b3618f1
00a20f6d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
37 deletions
+57
-37
src/Histogram.py
src/Histogram.py
+6
-4
src/Interpolation_USELESS.py
src/Interpolation_USELESS.py
+0
-30
src/LocalBinaryPatternizer.py
src/LocalBinaryPatternizer.py
+10
-0
src/find_svm_params.py
src/find_svm_params.py
+4
-3
src/test_performance.py
src/test_performance.py
+37
-0
No files found.
src/Histogram.py
View file @
1019d0cb
...
...
@@ -6,12 +6,14 @@ class Histogram:
self
.
max
=
max
def
add
(
self
,
number
):
bin_index
=
self
.
get_bin_index
(
number
)
self
.
bins
[
bin_index
]
+=
1
#bin_index = self.get_bin_index(number)
#self.bins[bin_index] += 1
self
.
bins
[
number
]
+=
1
def
remove
(
self
,
number
):
bin_index
=
self
.
get_bin_index
(
number
)
self
.
bins
[
bin_index
]
-=
1
#bin_index = self.get_bin_index(number)
#self.bins[bin_index] -= 1
self
.
bins
[
number
]
-=
1
def
get_bin_index
(
self
,
number
):
return
(
number
-
self
.
min
)
/
((
self
.
max
-
self
.
min
)
/
len
(
self
.
bins
))
...
...
src/Interpolation_USELESS.py
deleted
100644 → 0
View file @
3b3618f1
from
pylab
import
floor
def
pV
(
image
,
x
,
y
):
'''Get the value of a point x,y in the given image, where x and y are not
necessary integers, so the value is interpolated from its neighbouring
pixels.'''
if
inImage
(
image
,
x
,
y
):
x_low
=
floor
(
x
)
x_high
=
floor
(
x
+
1
)
y_low
=
floor
(
y
)
y_high
=
floor
(
y
+
1
)
x_y
=
(
x_high
-
x_low
)
*
(
y_high
-
y_low
)
interpolatedValue
=
image
[
x_low
,
y_low
]
/
x_y
*
(
x_high
-
x
)
*
\
(
y_high
-
y
)
\
+
image
[
x_high
][
y_low
]
/
x_y
*
(
x
-
x_low
)
*
\
(
y_high
-
y
)
\
+
image
[
x_low
][
y_high
]
/
x_y
*
(
x_high
-
x
)
*
\
(
y
-
y_low
)
\
+
image
[
x_high
][
y_high
]
/
x_y
*
(
x
-
x_low
)
*
\
(
y
-
y_low
)
return
interpolatedValue
else
:
constantValue
=
0
return
constantValue
def
inImage
(
image
,
x
,
y
):
'''Return if the pixels is within the image bounds.'''
return
(
x
>
0
and
x
<
image
.
get_height
()
-
1
\
and
y
>
0
and
y
<
image
.
get_width
()
-
1
)
src/LocalBinaryPatternizer.py
View file @
1019d0cb
...
...
@@ -32,6 +32,16 @@ class LocalBinaryPatternizer:
|
(
self
.
is_pixel_darker
(
y
+
1
,
x
-
1
,
value
)
<<
1
)
\
|
(
self
.
is_pixel_darker
(
y
,
x
-
1
,
value
))
def
pattern_5x5_hybrid
(
self
,
y
,
x
,
value
):
return
(
self
.
is_pixel_darker
(
y
-
2
,
x
-
2
,
value
)
<<
7
)
\
|
(
self
.
is_pixel_darker
(
y
-
2
,
x
,
value
)
<<
6
)
\
|
(
self
.
is_pixel_darker
(
y
-
2
,
x
+
2
,
value
)
<<
5
)
\
|
(
self
.
is_pixel_darker
(
y
,
x
+
2
,
value
)
<<
4
)
\
|
(
self
.
is_pixel_darker
(
y
+
2
,
x
+
2
,
value
)
<<
3
)
\
|
(
self
.
is_pixel_darker
(
y
+
2
,
x
,
value
)
<<
2
)
\
|
(
self
.
is_pixel_darker
(
y
+
2
,
x
-
2
,
value
)
<<
1
)
\
|
(
self
.
is_pixel_darker
(
y
,
x
-
2
,
value
))
def
pattern_5x5
(
self
,
y
,
x
,
value
):
return
(
self
.
is_pixel_darker
(
y
-
1
,
x
-
2
,
value
)
<<
11
)
\
|
(
self
.
is_pixel_darker
(
y
,
x
-
2
,
value
)
<<
10
)
\
...
...
src/find_svm_params.py
View file @
1019d0cb
...
...
@@ -102,7 +102,7 @@ i = 0
s
=
' c
\
y
'
for y in Y:
s += '
|
%
f' % y
s += '
|
%
f' % y
s += '
\
n
'
...
...
@@ -110,12 +110,13 @@ for c in C:
s += '
%
7
s
' % c
for y in Y:
s += '
|
%
8
d
' % int(round(results[i] * 100))
s += '
|
%
8
d
' % int(round(results[i] * 100))
i += 1
s += '
\
n
'
s += '
\
nBest
result
:
%
.
3
f
%%
for
C
=
%
f
and
gamma
=
%
f' % best[:3]
s += '
\
nBest
result
:
%
.
3
f
%%
for
C
=
%
f
and
gamma
=
%
f'
\
% ((best[0] * 100,) + best[1:3])
print '
Saving
results
...
'
f = open(results_file, '
w
+
')
...
...
src/test_performance.py
0 → 100755
View file @
1019d0cb
#!/usr/bin/python
from
cPickle
import
load
from
sys
import
argv
,
exit
from
time
import
time
from
Classifier
import
Classifier
if
len
(
argv
)
<
4
:
print
'Usage: python %s NEIGHBOURS BLUR_SCALE COUNT'
%
argv
[
0
]
exit
(
1
)
neighbours
=
int
(
argv
[
1
])
blur_scale
=
float
(
argv
[
2
])
count
=
int
(
argv
[
3
])
suffix
=
'_%s_%s'
%
(
blur_scale
,
neighbours
)
chars_file
=
'characters%s.dat'
%
suffix
classifier_file
=
'classifier%s.dat'
%
suffix
print
'Loading characters...'
chars
=
load
(
open
(
chars_file
,
'r'
))[:
count
]
count
=
len
(
chars
)
print
'Read %d characters'
%
count
print
'Loading classifier...'
classifier
=
Classifier
(
filename
=
classifier_file
)
start
=
time
()
for
char
in
chars
:
classifier
.
classify
(
char
)
elapsed
=
time
()
-
start
individual
=
elapsed
/
count
print
'Took %fs to classify %d caracters (%fms per character)'
\
%
(
elapsed
,
count
,
individual
*
1000
)
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