Commit d2e524ef authored by Taddeus Kroes's avatar Taddeus Kroes

Fixed ranges.

parent de262d05
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*.nav *.nav
*.snm *.snm
*.jpg *.jpg
*.zip
images/BBB images/BBB
images/Images images/Images
images/Infos images/Infos
......
...@@ -23,7 +23,7 @@ class LearningSetGenerator: ...@@ -23,7 +23,7 @@ class LearningSetGenerator:
M = int(1.2 * (max(x0, x1, x2, x3) - min(x0, x1, x2, x3))) M = int(1.2 * (max(x0, x1, x2, x3) - min(x0, x1, x2, x3)))
N = max(y0, y1, y2, y3) - min(y0, y1, y2, y3) N = max(y0, y1, y2, y3) - min(y0, y1, y2, y3)
matrix = array([ matrix = array([
[x0, y0, 1, 0, 0, 0, 0, 0, 0], [x0, y0, 1, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, x0, y0, 1, 0, 0, 0], [ 0, 0, 0, x0, y0, 1, 0, 0, 0],
...@@ -88,43 +88,43 @@ class LearningSetGenerator: ...@@ -88,43 +88,43 @@ class LearningSetGenerator:
def read_xml(self, filename): def read_xml(self, filename):
dom = parse('../images/Infos/%s.info' % filename) dom = parse('../images/Infos/%s.info' % filename)
self.characters = [] self.characters = []
version = dom.getElementsByTagName("current-version")[0].firstChild.data version = dom.getElementsByTagName("current-version")[0].firstChild.data
info = dom.getElementsByTagName("info") info = dom.getElementsByTagName("info")
for i in info: for i in info:
if version == i.getElementsByTagName("version")[0].firstChild.data: if version == i.getElementsByTagName("version")[0].firstChild.data:
self.country = i.getElementsByTagName("identification-letters")[0].firstChild.data self.country = i.getElementsByTagName("identification-letters")[0].firstChild.data
temp = i.getElementsByTagName("characters") temp = i.getElementsByTagName("characters")
if len(temp): if len(temp):
characters = temp[0].childNodes characters = temp[0].childNodes
else: else:
self.characters = [] self.characters = []
break break
for i, character in enumerate(characters): for i, character in enumerate(characters):
if character.nodeName == "character": if character.nodeName == "character":
value = character.getElementsByTagName("char")[0].firstChild.data value = character.getElementsByTagName("char")[0].firstChild.data
corners = self.get_corners(character) corners = self.get_corners(character)
if not len(corners) == 4: if not len(corners) == 4:
break break
image = GrayscaleImage(data = self.retrieve_data(corners)) image = GrayscaleImage(data = self.retrieve_data(corners))
print value print value
path = "../images/LearningSet/%s" % value path = "../images/LearningSet/%s" % 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):
mkdir(path) mkdir(path)
if not exists(image_path): if not exists(image_path):
image.save(image_path) image.save(image_path)
break break
def get_corners(self, dom): def get_corners(self, dom):
...@@ -136,13 +136,13 @@ class LearningSetGenerator: ...@@ -136,13 +136,13 @@ class LearningSetGenerator:
corners.append(Point(node)) corners.append(Point(node))
return corners return corners
for i in range(1):
for j in range(1): for i in range(9):
for j in range(100):
try: try:
filename = '%04d/00991_%04d%02d.info' % (i, i, j) filename = '%04d/00991_%04d%02d.info' % (i, i, j)
print 'loading file "%s"' % filename print 'loading file "%s"' % filename
plate = LearningSetGenerator(i, j) plate = LearningSetGenerator(i, j)
except: except:
print "failure" print "failure"
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment