diff transformations/pipeline.py @ 130:38929c29b602

merge
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Thu, 18 Feb 2010 14:44:23 -0500
parents ccce06590e64
children 4981c729149c
line wrap: on
line diff
--- a/transformations/pipeline.py	Thu Feb 18 14:43:53 2010 -0500
+++ b/transformations/pipeline.py	Thu Feb 18 14:44:23 2010 -0500
@@ -55,6 +55,7 @@
 from add_background_image import AddBackground
 from affine_transform import AffineTransformation
 from ttf2jpg import ttf2jpg
+from ..pycaptcha.Facade import generateCaptcha
 
 if DEBUG:
     from visualizer import Visualizer
@@ -219,13 +220,15 @@
         ocr_img = ft.read(nist.ocr_data)
         ocr_labels = ft.read(nist.ocr_labels)
     ttf = ttf2jpg()
+    L = [chr(ord('0')+x) for x in range(10)] + [chr(ord('A')+x) for x in range(26)] + [chr(ord('a')+x) for x in range(26)]
 
     for i in xrange(num_img):
         r = numpy.random.rand()
         if r <= prob_font:
             yield ttf.generate_image()
         elif r <= prob_font + prob_captcha:
-            pass #get captcha
+            (arr, charac) = generateCaptcha(0,1)
+            yield arr.astype(numpy.float32)/255, L.index(charac)
         elif r <= prob_font + prob_captcha + prob_ocr:
             j = numpy.random.randint(len(ocr_labels))
             yield ocr_img[j].astype(numpy.float32)/255, ocr_labels[j]