本文整理汇总了Python中Character.Character.get_single_cell_feature_vector方法的典型用法代码示例。如果您正苦于以下问题:Python Character.get_single_cell_feature_vector方法的具体用法?Python Character.get_single_cell_feature_vector怎么用?Python Character.get_single_cell_feature_vector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character.Character
的用法示例。
在下文中一共展示了Character.get_single_cell_feature_vector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_characters
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import get_single_cell_feature_vector [as 别名]
def load_characters(neighbours, blur_scale, verbose=0):
chars_file = 'characters_%s_%s.dat' % (blur_scale, neighbours)
if exists(chars_file):
print 'Loading characters...'
chars = fload(chars_file)
else:
print 'Going to generate character objects...'
chars = []
for char in sorted(listdir(IMAGES_FOLDER)):
count = 0
for image in sorted(listdir(IMAGES_FOLDER + char)):
image = GrayscaleImage(IMAGES_FOLDER + char + '/' + image)
norm = NormalizedCharacterImage(image, blur=blur_scale, \
height=NORMALIZED_HEIGHT)
character = Character(char, [], norm)
character.get_single_cell_feature_vector(neighbours)
chars.append(character)
count += 1
if verbose:
print 'Loaded character %s %d times' % (char, count)
if verbose:
print 'Saving characters...'
fdump(chars, chars_file)
return chars
示例2: classifier
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import get_single_cell_feature_vector [as 别名]
chars.append(char)
i += 1
if i == count:
br = True
break
if br:
break
# Load classifier (run create_classifier.py first)
classifier = load_classifier(neighbours, blur_scale, verbose=1)
# Measure the time it takes to recognize <count> characters
start = time()
for char in chars:
# Normalize the character image
char.image = NormalizedCharacterImage(image, blur=blur_scale, height=42)
# Create the image's feature vector
char.get_single_cell_feature_vector(neighbours)
# Feed the feature vector to the classifier
classifier.classify(char)
elapsed = time() - start
individual = elapsed / count
print "Took %fs to classify %d caracters (%fms per character)" % (elapsed, count, individual * 1000)