Mercurial > ift6266
view pycaptcha/Facade.py @ 116:3bec123dd75d
changes on pipeline mecanism: we now sample a different complexity for each transformations, this because when we use the same sampled complexity for all the modules 1/8 of the time we are close to 0 and we obtain an image very close to the source, we now save a complexity for each module in the parameters array
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Wed, 17 Feb 2010 16:22:54 -0500 |
parents | 4775b4195b4b |
children | 66b9513b578f |
line wrap: on
line source
#!/usr/bin/env python from Captcha.Visual.Tests import PseudoGimpy, AngryGimpy import numpy # Une fonction simple pour generer un captcha # ease : represente la difficulte du captcha a generer # 0 = facile et 1 (ou autre chose) = difficile #solution : specifie si on veut en retour un array numpy representant #l image ou un tuple contenant l'array et la solution du captcha. # Des fontes additionnelles peuvent etre ajoutees au dossier pyCaptcha/Captcha/data/fonts/others # Le programme choisit une fonte aleatoirement dans ce dossier ainsi que le dossir vera. def generateCaptcha (ease=0, solution=0): if ease == 1: g = AngryGimpy() else: g = PseudoGimpy() i = g.render() a = numpy.asarray(i) if solution == 0: return a else : return (a, g,solutions)