Mercurial > ift6266
comparison data_generation/transformations/ttf2jpg.py @ 273:7800be7bce66
changes in ttf2jpg and pycaptcha to load a file list with cPickle (instead of doing a listdir()) in order to have always the same list order from different machine (to reproduce generation)
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Sun, 21 Mar 2010 16:45:48 -0400 |
parents | 1f5937e9e530 |
children |
comparison
equal
deleted
inserted
replaced
262:716c99f4eb3a | 273:7800be7bce66 |
---|---|
8 Author: Guillaume Sicard | 8 Author: Guillaume Sicard |
9 ''' | 9 ''' |
10 | 10 |
11 import sys, os, fnmatch, random | 11 import sys, os, fnmatch, random |
12 import Image, ImageFont, ImageDraw, numpy | 12 import Image, ImageFont, ImageDraw, numpy |
13 import cPickle | |
13 | 14 |
14 class ttf2jpg(): | 15 class ttf2jpg(): |
15 def __init__(self, font_file = ''): | 16 def __init__(self, font_file = ''): |
16 self.w = 32 | 17 self.w = 32 |
17 self.h = 32 | 18 self.h = 32 |
24 self.char_list.append(chr(ord('0') + i) ) | 25 self.char_list.append(chr(ord('0') + i) ) |
25 for i in range(0,26): | 26 for i in range(0,26): |
26 self.char_list.append(chr(ord('A') + i) ) | 27 self.char_list.append(chr(ord('A') + i) ) |
27 for i in range(0,26): | 28 for i in range(0,26): |
28 self.char_list.append(chr(ord('a') + i) ) | 29 self.char_list.append(chr(ord('a') + i) ) |
29 files = os.listdir(self.font_dir) | 30 f = open( self.font_dir + 'filelist.pkl' ,'r') |
30 self.font_files = fnmatch.filter(files, '*.ttf') + fnmatch.filter(files, '*.TTF') | 31 self.font_files = cPickle.load(f) |
32 f.close() | |
31 | 33 |
32 # get font name | 34 # get font name |
33 def get_settings_names(self): | 35 def get_settings_names(self): |
34 return [self.font_file] | 36 return [self.font_file] |
35 | 37 |