本文整理汇总了Python中common.Logger.writeMsg方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.writeMsg方法的具体用法?Python Logger.writeMsg怎么用?Python Logger.writeMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Logger
的用法示例。
在下文中一共展示了Logger.writeMsg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: align_all
# 需要导入模块: from common import Logger [as 别名]
# 或者: from common.Logger import writeMsg [as 别名]
def align_all(filelist, savePath):
'''
--advised: custom reference image--
@breif:对其所有的人脸图像,需要选择参考的图像,默认为第一张
--advised--
NOTICE: HARD CODE!!
custom reference image:
CASIA-WebFace/5587543/52.jpg
'''
ref_word = ['/workspace/datasets/CASIA-WebFace/5587543/052.jpg', \
93.8033091545, \
107.536554384, \
154.941061592, \
105.698314667, \
127.14125061, \
146.21746006, \
98.2846255302, \
164.093176651, \
148.728798866, \
163.938378143]
print 'reference image:' + ref_word[0]
#随机选择一个参考图像和参考点
#todo:人工选择一张比较合适的图像作为参考图像,默认情况下,第一张作为参考图像
ref_points = np.empty((10,1), dtype = np.int)
points = np.empty((10,1), dtype = np.int)
ref_filePath = ref_word[0]
for i in range(10):
ref_points[i] = float(ref_word[i+1])
refimage = skimage.io.imread(ref_filePath)
if refimage.ndim == 3:
rows, cols, ch = refimage.shape
else:
rows, cols = refimage.shape
#rows,cols,ch = refimage.shape
#为保留数据的完整性,重新扫描
fid = open(filelist,'r')
lines = fid.readlines()
fid.close()
logger = Logger(os.path.join(FACE_ALIGNMENT_ROOT, 'faceAlignemnt.list'))
for line in lines:
word = line.split()
filePath = word[0]
for j in range(10):
points[j] = float(word[j+1])
warpimage, warpimage_cv2 = alignment(filePath, points, ref_points)
'''
filePath format:
origin: /workspace/datasets/CASIA-WebFace/5587543/001.jpg
splited: ['', 'workspace', 'datasets', 'CASIA-WebFace', '5587543', '001.jpg']
'''
splitedPath = filePath.split('/')
className = splitedPath[-2] # NOTICE: HARD CODE!!
filename = splitedPath[-1] # NOTICE: HARD CODE!!
savename = join(savePath, className, filename)
#处理多层文件,不能写入的问题,新建文件
dirname, basename = os.path.split(savename)
if not os.path.exists(dirname):
os.makedirs(dirname)
if warpimage_cv2.shape == refimage.shape:
skimage.io.imsave(savename, warpimage_cv2)
else:
if warpimage_cv2.ndim == 3:
rows,cols,ch = warpimage_cv2.shape
skimage.io.imsave(savename, warpimage_cv2[0:rows, 0:cols, :])
else:
rows,cols = warpimage_cv2.shape
skimage.io.imsave(savename, warpimage_cv2[0:rows, 0:cols])
print filePath
logger.writeMsg("%s\n" % filePath)
'''
free memory: force the Garbage Collector to release
'''
gc.collect()