コード例 #1
0
ファイル: GUI.py プロジェクト: teym/captchacker
    def OnSelectModel(self, evt):
        dlg = wx.FileDialog(self, "Selectionnez le modele", os.path.join(os.getcwd(),MODEL_FOLDER), DEFAULT_MODEL_FILE,
                            wildcard = "Model files (*.svm)|*.svm",
                            style = wx.OPEN)
        retour = dlg.ShowModal()
        self.chemin = dlg.GetPath().encode("latin-1")
        fichier = dlg.GetFilename().encode("latin-1")
        dlg.Destroy()

        if retour == wx.ID_OK and fichier != "":
            self.model = Break_Captcha_util.load_model(self.chemin, self, fichier)
        self.Update()
コード例 #2
0
ファイル: GUI.py プロジェクト: yangpuyi/captchacker
 def OnSelectModel(self, evt):
     dlg = wx.FileDialog(self, "Selectionnez le modele", os.path.join(os.getcwd(),MODEL_FOLDER), DEFAULT_MODEL_FILE,
                         wildcard = "Model files (*.svm)|*.svm",
                         style = wx.OPEN)
     retour = dlg.ShowModal()
     self.chemin = dlg.GetPath().encode("latin-1")
     fichier = dlg.GetFilename().encode("latin-1")
     dlg.Destroy()
     
     if retour == wx.ID_OK and fichier != "":
         self.model = Break_Captcha_util.load_model(self.chemin, self, fichier)
     self.Update()
コード例 #3
0
ファイル: GUI.py プロジェクト: teym/captchacker
    def OnSelectCaptcha(self, evt):
        dlg = wx.FileDialog(self, "Selectionnez l'image", os.path.join(os.getcwd(), CAPTCHA_FOLDER), DEFAULT_CAPTCHA_FILE,
                            wildcard = "Image files (*.jpg;)|*.jpg",
                            style = wx.OPEN)
        retour = dlg.ShowModal()
        self.chemin = dlg.GetPath().encode("latin-1")
        fichier = dlg.GetFilename()
        dlg.Destroy()

        if retour == wx.ID_OK and fichier != "":
            self.captcha, self.beau_captcha = Break_Captcha_util.preprocess_captcha_part(self.chemin, self)
            self.setCaptchaImage(self.beau_captcha)
            self.captcha_selected = True
        self.Update()
コード例 #4
0
ファイル: GUI.py プロジェクト: yangpuyi/captchacker
 def OnSelectCaptcha(self, evt):
     dlg = wx.FileDialog(self, "Selectionnez l'image", os.path.join(os.getcwd(), CAPTCHA_FOLDER), DEFAULT_CAPTCHA_FILE,
                         wildcard = "Image files (*.jpg;)|*.jpg",
                         style = wx.OPEN)
     retour = dlg.ShowModal()
     self.chemin = dlg.GetPath().encode("latin-1")
     fichier = dlg.GetFilename()
     dlg.Destroy()
     
     if retour == wx.ID_OK and fichier != "":
         self.captcha, self.beau_captcha = Break_Captcha_util.preprocess_captcha_part(self.chemin, self)
         self.setCaptchaImage(self.beau_captcha)
         self.captcha_selected = True
     self.Update()
コード例 #5
0
def compute_scores_list(model, captcha, parent=None):
    #Liste des scores
    liste_scores = []

    #Compute scores for all widths and starting positions
    for size in range(8, 30, 1):
        print size, "/", 30
        for starting_pos in range(0, captcha.size[0] - size):
            preprocessed_captcha_part = captcha.crop(
                (starting_pos, 0, starting_pos + size, 31))

            #Si parent=None, on enlève le blanc sur les cotés
            miny = 100000
            maxy = 0
            for i in xrange(size):
                for j in xrange(31):
                    if preprocessed_captcha_part.getpixel((i, j)) == 0:
                        if j < miny:
                            miny = j
                        if j > maxy:
                            maxy = j
            preprocessed_captcha_part = preprocessed_captcha_part.crop(
                (0, miny, size, maxy + 1))
            sizei = maxy - miny + 1

            im = Image.new('L', (31, 31), 1)
            im.paste(preprocessed_captcha_part,
                     ((31 - size) / 2, (31 - sizei) / 2))

            prediction, max_score = Break_Captcha_util.predict(
                model, im, None, 0)
            #liste_scores.append((starting_pos+size, size, 1/(1-max_score), prediction))
            liste_scores.append(
                (starting_pos + size, size, math.log(max_score), prediction))

    if not parent:
        f = open('scores.pck', 'w')
        pickle.dump(liste_scores, f)
        f.close()

    return liste_scores
コード例 #6
0
def compute_scores_list(model, captcha, parent=None):
        #Liste des scores
        liste_scores = []
        
        #Compute scores for all widths and starting positions
        for size in range(8, 30, 1):
            print size, "/", 30
            for starting_pos in range(0, captcha.size[0] - size):
                preprocessed_captcha_part = captcha.crop((starting_pos, 0, starting_pos+size, 31))
                
                
                #Si parent=None, on enlève le blanc sur les cotés
                miny=100000
                maxy=0
                for i in xrange(size):
                    for j in xrange(31):
                        if preprocessed_captcha_part.getpixel((i,j)) == 0:
                            if j<miny:
                                miny=j
                            if j>maxy:
                                maxy=j        
                preprocessed_captcha_part = preprocessed_captcha_part.crop((0, miny, size, maxy+1))
                sizei = maxy-miny+1

                im = Image.new('L', (31, 31), 1)
                im.paste(preprocessed_captcha_part, ((31-size)/2, (31-sizei)/2))

                prediction, max_score = Break_Captcha_util.predict(model, im, None, 0)
                #liste_scores.append((starting_pos+size, size, 1/(1-max_score), prediction))
                liste_scores.append((starting_pos+size, size, math.log(max_score), prediction))


        if not parent:
            f=open('scores.pck', 'w')
            pickle.dump(liste_scores, f)
            f.close()

        return liste_scores
コード例 #7
0
        for y in xrange(0, h):
            segmented_captcha.putpixel((x*parent.zoom, y), (255,0,0))

    parent.SetGraphImage(segmented_captcha)
    parent.actif = False
    parent.launchPredictionButton.SetLabel("Lancer la prédiction")
    


if __name__ == "__main__":
        MODEL_FILE = "Hotmail/Models/model_31x31_3DE2MT_DXDY.svm"
        #MODEL_FILE = "Hotmail/Models/model_31x31_3DE2MT_classes.svm"
        CAPTCHA_FILE = os.path.join("Hotmail", "Rough Captchas", 'Image011.jpg')

        #Chargement du modèle
        model = Break_Captcha_util.load_model(MODEL_FILE)

        #Préprocessing du captcha
        captcha, beau_captcha = Break_Captcha_util.preprocess_captcha_part(CAPTCHA_FILE)
        
        #Calcul des scores
        liste_scores = compute_scores_list(model, captcha)

        #Chargement des scores sauvegardés
##        f=open('scores.pck')
##        liste_scores = pickle.load(f)
##        f.close()
        use_dynamic_programming(liste_scores)
        
        raw_input()
コード例 #8
0
    for x in segs:
        for y in xrange(0, h):
            segmented_captcha.putpixel((x * parent.zoom, y), (255, 0, 0))

    parent.SetGraphImage(segmented_captcha)
    parent.actif = False
    parent.launchPredictionButton.SetLabel("Lancer la prédiction")


if __name__ == "__main__":
    MODEL_FILE = "Hotmail/Models/model_31x31_3DE2MT_DXDY.svm"
    #MODEL_FILE = "Hotmail/Models/model_31x31_3DE2MT_classes.svm"
    CAPTCHA_FILE = os.path.join("Hotmail", "Rough Captchas", 'Image011.jpg')

    #Chargement du modèle
    model = Break_Captcha_util.load_model(MODEL_FILE)

    #Préprocessing du captcha
    captcha, beau_captcha = Break_Captcha_util.preprocess_captcha_part(
        CAPTCHA_FILE)

    #Calcul des scores
    liste_scores = compute_scores_list(model, captcha)

    #Chargement des scores sauvegardés
    ##        f=open('scores.pck')
    ##        liste_scores = pickle.load(f)
    ##        f.close()
    use_dynamic_programming(liste_scores)

    raw_input()