view pycaptcha/Facade.py @ 96:17fabd74dd2b

Changed behavior of gaussian noise to apply a gauss filter with a random sigma, and then select some point of the image to be averaged with it
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Thu, 11 Feb 2010 16:34:25 -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)