Skip to content
Snippets Groups Projects
Commit 957cba5c authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Renamed 'LearningSet' folder to 'characters'.

parent 9e6af877
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ from cPickle import load, dump ...@@ -3,7 +3,7 @@ from cPickle import load, dump
DATA_FOLDER = 'data/' DATA_FOLDER = 'data/'
IMAGES_FOLDER = '../images/LearningSet/' IMAGES_FOLDER = '../images/characters/'
RESULTS_FOLDER = 'results/' RESULTS_FOLDER = 'results/'
......
...@@ -6,6 +6,8 @@ from Character import Character ...@@ -6,6 +6,8 @@ from Character import Character
from GrayscaleImage import GrayscaleImage from GrayscaleImage import GrayscaleImage
from NormalizedCharacterImage import NormalizedCharacterImage from NormalizedCharacterImage import NormalizedCharacterImage
from LicensePlate import LicensePlate from LicensePlate import LicensePlate
from data import IMAGES_FOLDER
# Gets the character data from a picture with a license plate # Gets the character data from a picture with a license plate
def retrieve_data(plate, corners): def retrieve_data(plate, corners):
...@@ -38,6 +40,7 @@ def retrieve_data(plate, corners): ...@@ -38,6 +40,7 @@ def retrieve_data(plate, corners):
return data return data
def get_transformation_matrix(matrix): def get_transformation_matrix(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 # Since D is diagonal with the eigenvalues sorted from large to small
...@@ -48,6 +51,7 @@ def get_transformation_matrix(matrix): ...@@ -48,6 +51,7 @@ def get_transformation_matrix(matrix):
return inv(array([[p[0],p[1],p[2]], [p[3],p[4],p[5]], [p[6],p[7],p[8]]])) return inv(array([[p[0],p[1],p[2]], [p[3],p[4],p[5]], [p[6],p[7],p[8]]]))
def pV(image, x, y): def pV(image, x, y):
#Get the value of a point (interpolated x, y) in the given image #Get the value of a point (interpolated x, y) in the given image
if not image.in_bounds(x, y): if not image.in_bounds(x, y):
...@@ -67,6 +71,7 @@ def pV(image, x, y): ...@@ -67,6 +71,7 @@ def pV(image, x, y):
+ image[x_low , y_high] / x_y * a * d \ + image[x_low , y_high] / x_y * a * d \
+ image[x_high, y_high] / x_y * c * d + image[x_high, y_high] / x_y * c * d
def xml_to_LicensePlate(filename, save_character=None): def xml_to_LicensePlate(filename, save_character=None):
plate = GrayscaleImage('../images/Images/%s.jpg' % filename) plate = GrayscaleImage('../images/Images/%s.jpg' % filename)
dom = parse('../images/Infos/%s.info' % filename) dom = parse('../images/Infos/%s.info' % filename)
...@@ -100,10 +105,10 @@ def xml_to_LicensePlate(filename, save_character=None): ...@@ -100,10 +105,10 @@ def xml_to_LicensePlate(filename, save_character=None):
data = retrieve_data(plate, corners) data = retrieve_data(plate, corners)
image = NormalizedCharacterImage(data=data) image = NormalizedCharacterImage(data=data)
result.append(Character(value, corners, image, filename)) result.append(Character(value, corners, image, filename))
if save_character: if save_character:
character_image = GrayscaleImage(data=data) character_image = GrayscaleImage(data=data)
path = "../images/LearningSet/%s" % value path = IMAGES_FOLDER + value
image_path = "%s/%d_%s.jpg" % (path, i, filename.split('/')[-1]) image_path = "%s/%d_%s.jpg" % (path, i, filename.split('/')[-1])
if not exists(path): if not exists(path):
...@@ -114,15 +119,19 @@ def xml_to_LicensePlate(filename, save_character=None): ...@@ -114,15 +119,19 @@ def xml_to_LicensePlate(filename, save_character=None):
return LicensePlate(country, result) return LicensePlate(country, result)
def get_node(node, tag): def get_node(node, tag):
return by_tag(node, tag)[0].firstChild.data return by_tag(node, tag)[0].firstChild.data
def by_tag(node, tag): def by_tag(node, tag):
return node.getElementsByTagName(tag) return node.getElementsByTagName(tag)
def get_attr(node, attr): def get_attr(node, attr):
return int(node.getAttribute(attr)) return int(node.getAttribute(attr))
def get_corners(dom): def get_corners(dom):
p = by_tag(dom, "point") p = by_tag(dom, "point")
...@@ -134,4 +143,4 @@ def get_corners(dom): ...@@ -134,4 +143,4 @@ def get_corners(dom):
return get_attr(p[0], "x") - x, get_attr(p[0], "y") - y,\ return get_attr(p[0], "x") - x, get_attr(p[0], "y") - y,\
get_attr(p[1], "x") + x, get_attr(p[1], "y") - y,\ get_attr(p[1], "x") + x, get_attr(p[1], "y") - y,\
get_attr(p[2], "x") + x, get_attr(p[2], "y") + y,\ get_attr(p[2], "x") + x, get_attr(p[2], "y") + y,\
get_attr(p[3], "x") - x, get_attr(p[3], "y") + y get_attr(p[3], "x") - x, get_attr(p[3], "y") + y
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment