Python 读取文件夹将里面的图片处理成想要的大小并保存在个指定位置

 我来答
cjjohn3
2017-08-07 · TA获得超过6641个赞
知道大有可为答主
回答量:3622
采纳率:69%
帮助的人:953万
展开全部
# -*- coding: utf-8 -*-
import cv2
import os
import numpy
import cutHumanFace

def saveCutFace(filePath, pathSave = 'cutFace', normalizeWidth = 300, normalizeHeight = 300):
    """
    :param filePath: string, 文件夹路径
    """
    
    if not os.path.exists(savePath):
        os.makedirs(savePath);                   #保存的文件夹
        
    files = os.listdir(filePath);                #列出目录下的所有文件
    
    normalizeWidth = 100                         #以100×100为大小
    normalizeHeight = 100
    for file in files:
        normalizeFace = cv2.resize(cutFace, (normalizeWidth,normalizeHeight), interpolation=cv2.INTER_AREA);
        cv2.imwrite(savePath, normalizeFace);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式