update,
This commit is contained in:
5
vinniesniper-54816/task1/_lab/007-train-bus-test/posdata.1/.gitignore
vendored
Normal file
5
vinniesniper-54816/task1/_lab/007-train-bus-test/posdata.1/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
*.jpg
|
||||
*.png
|
||||
*.bmp
|
||||
*.gif
|
||||
*.webp
|
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
from PIL import Image
|
||||
|
||||
json_dir = "./"
|
||||
label_names = os.listdir(json_dir)
|
||||
label_dir = []
|
||||
|
||||
for filename in label_names:
|
||||
label_dir.append(os.path.join(json_dir,filename))
|
||||
|
||||
for i,filename in enumerate(label_dir):
|
||||
|
||||
im = Image.open(filename) # open ppm file
|
||||
|
||||
newname = label_names[i].split('.')[0] + '.jpg' # new name for png file
|
||||
im.save(os.path.join(json_dir,newname))
|
@@ -0,0 +1,9 @@
|
||||
# -*- coding:utf8 -*-
|
||||
import os
|
||||
|
||||
|
||||
# 生成路径列表文件
|
||||
os.system("dir /b/s/p/w *.jpg > pos.txt")
|
||||
|
||||
|
||||
os.system("pause")
|
@@ -0,0 +1,26 @@
|
||||
# -*- coding:utf8 -*-
|
||||
import cv2
|
||||
import numpy as np
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib2 import Path
|
||||
|
||||
|
||||
# 批量灰度化图片
|
||||
def GrayPic(srcImgDir):
|
||||
for item in srcImgDir.rglob("*.jpg"):
|
||||
# 获取图片名
|
||||
imgName = item.name
|
||||
img=cv2.imread(imgName)
|
||||
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
|
||||
cv2.imwrite("gray"+imgName,gray)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# 文件路径--跟代码同目录
|
||||
srcImgPath = Path("./")
|
||||
GrayPic(srcImgPath)
|
||||
|
||||
os.system("pause")
|
@@ -0,0 +1,27 @@
|
||||
# -*- coding:utf8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib2 import Path
|
||||
|
||||
|
||||
# 批量命名图片
|
||||
def renamePic(srcImgDir):
|
||||
i=0
|
||||
for item in srcImgDir.rglob("*.jpg"):
|
||||
# 获取图片名
|
||||
imgName = item.name
|
||||
newName = str(i)+".jpg"
|
||||
i=i+1
|
||||
# 重命名
|
||||
print(f"prepare to rename {imgName}")
|
||||
item.rename(newName)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# 文件路径--跟代码同目录
|
||||
srcImgPath = Path("./")
|
||||
renamePic(srcImgPath)
|
||||
|
||||
os.system("pause")
|
@@ -0,0 +1,8 @@
|
||||
# -*- coding:utf8 -*-
|
||||
import os
|
||||
|
||||
|
||||
os.system("copy .\\pos.txt ..\\")
|
||||
|
||||
|
||||
os.system("pause")
|
Reference in New Issue
Block a user