comparison data_generation/transformations/pycaptcha/Facade.py @ 167:1f5937e9e530

More moves - transformations into data_generation, added "deep" folder
author Dumitru Erhan <dumitru.erhan@gmail.com>
date Fri, 26 Feb 2010 14:15:38 -0500
parents pycaptcha/Facade.py@66b9513b578f
children ff26436d42d6
comparison
equal deleted inserted replaced
166:17ae5a1a4dd1 167:1f5937e9e530
1 #!/usr/bin/env python
2
3
4
5 from Captcha.Visual.Tests import PseudoGimpy, AngryGimpy
6 import numpy
7
8 # Une fonction simple pour generer un captcha
9 # ease : represente la difficulte du captcha a generer
10 # 0 = facile et 1 (ou autre chose) = difficile
11 #solution : specifie si on veut en retour un array numpy representant
12 #l image ou un tuple contenant l'array et la solution du captcha.
13
14 # Des fontes additionnelles peuvent etre ajoutees au dossier pyCaptcha/Captcha/data/fonts/others
15 # Le programme choisit une fonte aleatoirement dans ce dossier ainsi que le dossir vera.
16
17
18 def generateCaptcha (ease=0, solution=0):
19
20 if ease == 1:
21 g = AngryGimpy()
22
23 else:
24 g = PseudoGimpy()
25
26 i = g.render()
27 a = numpy.asarray(i)
28
29 if solution == 0:
30 return a
31
32 else :
33 return (a, g.solutions)