Ship_Tilt_Detection/image_filename_to_txtlist.py

13 lines
351 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
import os
import random
#将./testimages 里图片处理成test.txt用于检测。存放在./dataPath/test.txt
paths = r'./testimages' # 储存图片的文件夹路径
f = open('./dataPath/test.txt', 'w')
filenames = os.listdir(paths) # 读取图片名称
for filename in filenames:
out = filename.split('.jpg')[0]
f.write(out + '\n')
f.close()