import cv2
from utils.not_good import is_ok
file_names =[ ]# get_image_list(ini_name,360000,list_path)
txt_path =r"WIDER_train\train_label.txt"
f = open(txt_path, 'r')
lines = f.readlines()
isFirst = True
labels = []
words = []
for line in lines:
line = line.rstrip()
if line.startswith('#'):
if isFirst is True:
isFirst = False
else:
labels_copy = labels.copy()
words.append(labels_copy)
labels.clear()
path = line[2:]
path = txt_path.replace('train_label.txt', 'images/') + path
file_names.append(path)
else:
line = line.split(' ')
label = [float(x) for x in line]
labels.append(label)
words.append(labels)
datas =[]
a_len =len(file_names)
for index, i in enumerate(file_names[::-1]):
res,datas =is_ok(i)
if not res:
file_names.remove(i)
words.remove(words[a_len -index -1])
for index, file in enumerate(file_names):
img_raw = cv2.imread(file)
labels = words[index]
face_num = 0
has_small = False
has_max = False
for label in labels:
x1 = int(label[0])
y1 = int(label[1])
x2 = int(label[0] + label[2])
y2 = int(label[1] + label[3])
print((x1, y1), (x2, y2), label[2] * label[3])
cv2.rectangle(img_raw, (x1, y1), (x2, y2), (0, 255, 0), 1)
cv2.imshow("sdf",img_raw)
cv2.waitKey()
widerface筛选数据
猜你喜欢
转载自blog.csdn.net/jacke121/article/details/103826647
今日推荐
周排行