1 Star 1 Fork 1

字符错误 / Python图像处理

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
size.py 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
字符错误 提交于 2021-11-02 03:13 . 上传文件
import os
import xml.dom.minidom
import cv2
from openpyxl import Workbook,load_workbook
def getFileList(dir, Filelist, ext=None):
"""
获取文件夹及其子文件夹中文件列表
输入 dir:文件夹根目录
输入 ext: 扩展名
返回: 文件路径列表
"""
newDir = dir
if os.path.isfile(dir):
if ext is None:
Filelist.append(dir)
else:
if ext in dir[-3:]:
Filelist.append(dir)
elif os.path.isdir(dir):
for s in os.listdir(dir):
newDir = os.path.join(dir, s)
getFileList(newDir, Filelist, ext)
return Filelist
base_PATH=os.getcwd()
PATH_images = './limite50_face' # 当前文件路径
wb=load_workbook('size_limite50_face.xlsx')
sn=wb.sheetnames
ws = wb[sn[0]]
# 检索文件
imglist = getFileList(PATH_images, [], 'png')
print('本次执行检索到 '+str(len(imglist))+' 张图像\n')
id=1
for imgpath in imglist:
#imgname = os.path.splitext(os.path.basename(imgpath))[0]
img = cv2.imread(imgpath)
_size = img.shape
width = _size[1]
height = _size[0]
ws.cell(row=id, column=1).value = width
ws.cell(row=id, column=2).value = height
id+=1
os.chdir(base_PATH)
wb.save('size_limite50_face.xlsx')
Python
1
https://gitee.com/zifucuowu/python-image-processing.git
git@gitee.com:zifucuowu/python-image-processing.git
zifucuowu
python-image-processing
Python图像处理
master

搜索帮助