Mercurial > ift6266
annotate data_generation/transformations/pycaptcha/Facade.py @ 438:a6d339033d03
added AMT
author | Yoshua Bengio <bengioy@iro.umontreal.ca> |
---|---|
date | Mon, 03 May 2010 07:46:18 -0400 |
parents | ff26436d42d6 |
children |
rev | line source |
---|---|
87 | 1 #!/usr/bin/env python |
174
ff26436d42d6
Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents:
167
diff
changeset
|
2 import sys, os |
ff26436d42d6
Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents:
167
diff
changeset
|
3 curdir = os.path.dirname(__file__) |
ff26436d42d6
Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents:
167
diff
changeset
|
4 if curdir != '': |
ff26436d42d6
Make data_generation.transformations importable and fixup test.py to not try some of the modules.
Arnaud Bergeron <abergeron@gmail.com>
parents:
167
diff
changeset
|
5 sys.path.append(curdir) |
87 | 6 |
7 from Captcha.Visual.Tests import PseudoGimpy, AngryGimpy | |
8 import numpy | |
9 | |
10 # Une fonction simple pour generer un captcha | |
11 # ease : represente la difficulte du captcha a generer | |
12 # 0 = facile et 1 (ou autre chose) = difficile | |
13 #solution : specifie si on veut en retour un array numpy representant | |
14 #l image ou un tuple contenant l'array et la solution du captcha. | |
15 | |
16 # Des fontes additionnelles peuvent etre ajoutees au dossier pyCaptcha/Captcha/data/fonts/others | |
17 # Le programme choisit une fonte aleatoirement dans ce dossier ainsi que le dossir vera. | |
18 | |
19 | |
20 def generateCaptcha (ease=0, solution=0): | |
21 | |
22 if ease == 1: | |
23 g = AngryGimpy() | |
24 | |
25 else: | |
26 g = PseudoGimpy() | |
27 | |
28 i = g.render() | |
29 a = numpy.asarray(i) | |
30 | |
31 if solution == 0: | |
32 return a | |
33 | |
34 else : | |
126
66b9513b578f
Fixed bug in pycaptcha/Facade.py
boulanni <nicolas_boulanger@hotmail.com>
parents:
87
diff
changeset
|
35 return (a, g.solutions) |