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
b04b1a16
Commit
b04b1a16
authored
Dec 06, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed 80 character limit.
parent
81644280
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
src/LicensePlate.py
src/LicensePlate.py
+18
-18
No files found.
src/LicensePlate.py
View file @
b04b1a16
...
@@ -18,30 +18,30 @@ class LicensePlate:
...
@@ -18,30 +18,30 @@ class LicensePlate:
self
.
height
=
int
(
properties
[
'height'
])
self
.
height
=
int
(
properties
[
'height'
])
self
.
read_xml
()
self
.
read_xml
()
def
are_corners_sorted
(
corners
):
def
are_corners_sorted
(
corners
):
'''
Check if points are sorted clockwise, starting in the left-top
'''Check if points are sorted clockwise, starting in the left-top
corner.'''
corner.'''
x0
,
y0
=
corners
[
0
].
to_tuple
()
x0
,
y0
=
corners
[
0
].
to_tuple
()
x1
,
y1
=
corners
[
1
].
to_tuple
()
x1
,
y1
=
corners
[
1
].
to_tuple
()
x2
,
y2
=
corners
[
2
].
to_tuple
()
x2
,
y2
=
corners
[
2
].
to_tuple
()
x3
,
y3
=
corners
[
3
].
to_tuple
()
x3
,
y3
=
corners
[
3
].
to_tuple
()
return
x0
<
x1
and
y1
<=
y2
and
x2
>=
x3
and
y3
>
y0
return
x0
<
x1
and
y1
<=
y2
and
x2
>=
x3
and
y3
>
y0
def
sort_corners
(
corners
):
def
sort_corners
(
corners
):
'''Sort the corners clockwise, starting in the left-top corner.
'''
'''Sort the corners clockwise, starting in the left-top corner.'''
tuples
=
[]
tuples
=
[]
output
=
[]
output
=
[]
for
point
in
corners
:
for
point
in
corners
:
tuples
.
append
(
point
.
to_tuple
())
tuples
.
append
(
point
.
to_tuple
())
bot1
=
(
0
,
0
)
bot1
=
(
0
,
0
)
bot2
=
(
0
,
0
)
bot2
=
(
0
,
0
)
top1
=
None
top1
=
None
top2
=
None
top2
=
None
# Get bottom points (where the y value is the largest). The top points
# Get bottom points (where the y value is the largest). The top points
# are the points that are not a bottom point.
# are the points that are not a bottom point.
for
tup
in
tuples
:
for
tup
in
tuples
:
...
@@ -50,7 +50,7 @@ class LicensePlate:
...
@@ -50,7 +50,7 @@ class LicensePlate:
top1
=
bot2
top1
=
bot2
else
:
else
:
top2
=
bot2
top2
=
bot2
if
tup
[
1
]
>
bot1
[
1
]:
if
tup
[
1
]
>
bot1
[
1
]:
bot2
=
bot1
bot2
=
bot1
bot1
=
tup
bot1
=
tup
...
@@ -61,7 +61,7 @@ class LicensePlate:
...
@@ -61,7 +61,7 @@ class LicensePlate:
top1
=
tup
top1
=
tup
else
:
else
:
top2
=
tup
top2
=
tup
# First point is the smallest x-value top point, second is the other
# First point is the smallest x-value top point, second is the other
# top point
# top point
if
top1
[
0
]
<
top2
[
0
]:
if
top1
[
0
]
<
top2
[
0
]:
...
@@ -70,7 +70,7 @@ class LicensePlate:
...
@@ -70,7 +70,7 @@ class LicensePlate:
else
:
else
:
output
.
append
(
Point
(
top2
[
0
],
top2
[
1
]))
output
.
append
(
Point
(
top2
[
0
],
top2
[
1
]))
output
.
append
(
Point
(
top1
[
0
],
top1
[
1
]))
output
.
append
(
Point
(
top1
[
0
],
top1
[
1
]))
# Third point is the bottom point with the largest x-value, fourth is
# Third point is the bottom point with the largest x-value, fourth is
# the other bottom point
# the other bottom point
if
bot1
[
0
]
>
bot2
[
0
]:
if
bot1
[
0
]
>
bot2
[
0
]:
...
@@ -79,9 +79,9 @@ class LicensePlate:
...
@@ -79,9 +79,9 @@ class LicensePlate:
else
:
else
:
output
.
append
(
Point
(
bot2
[
0
],
bot2
[
1
]))
output
.
append
(
Point
(
bot2
[
0
],
bot2
[
1
]))
output
.
append
(
Point
(
bot1
[
0
],
bot1
[
1
]))
output
.
append
(
Point
(
bot1
[
0
],
bot1
[
1
]))
return
output
return
output
# sets the entire license plate of an image
# sets the entire license plate of an image
def
retrieve_data
(
self
,
corners
):
def
retrieve_data
(
self
,
corners
):
x0
,
y0
=
corners
[
0
].
to_tuple
()
x0
,
y0
=
corners
[
0
].
to_tuple
()
...
@@ -111,16 +111,16 @@ class LicensePlate:
...
@@ -111,16 +111,16 @@ class LicensePlate:
or_coor
=
dot
(
P
,
([[
i
],[
j
],[
1
]]))
or_coor
=
dot
(
P
,
([[
i
],[
j
],[
1
]]))
or_coor_h
=
(
or_coor
[
1
][
0
]
/
or_coor
[
2
][
0
],
or_coor_h
=
(
or_coor
[
1
][
0
]
/
or_coor
[
2
][
0
],
or_coor
[
0
][
0
]
/
or_coor
[
2
][
0
])
or_coor
[
0
][
0
]
/
or_coor
[
2
][
0
])
data
[
j
][
i
]
=
self
.
pV
(
or_coor_h
[
0
],
or_coor_h
[
1
])
data
[
j
][
i
]
=
self
.
pV
(
or_coor_h
[
0
],
or_coor_h
[
1
])
return
data
return
data
def
get_transformation_matrix
(
self
,
matrix
):
def
get_transformation_matrix
(
self
,
matrix
):
# Get the vector p and the values that are in there by taking the SVD.
# Get the vector p and the values that are in there by taking the SVD.
# Since D is diagonal with the eigenvalues sorted from large to small
on
# Since D is diagonal with the eigenvalues sorted from large to small
#
the diagonal, the optimal q in min ||Dq|| is q = [[0]..[1]]. Therefore,
#
on the diagonal, the optimal q in min ||Dq|| is q = [[0]..[1]].
# p = Vq means p is the last column in V.
#
Therefore,
p = Vq means p is the last column in V.
U
,
D
,
V
=
svd
(
matrix
)
U
,
D
,
V
=
svd
(
matrix
)
p
=
V
[
8
][:]
p
=
V
[
8
][:]
...
...
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