代码拉取完成,页面将自动刷新
import cv2
import numpy as np
import os
dir_img = "../data/images/"
dir_txt = "model/ship_gt/labels_withoutname/"
save_dir = os.path.dirname(os.path.dirname(dir_img)) + '/show_pt/'
if not os.path.exists(save_dir):
os.makedirs(save_dir)
# import pdb
# pdb.set_trace()
def deal_txt_pt(path_txt):
lll_pt = []
with open(path_txt, 'r') as fr:
for line in fr.readlines():
ll_pt = []
line = line.strip()
list_num = line.split(',')
l_pt = []
for cnt, num in enumerate(list_num):
num = float(num)
l_pt.append(num)
if 2 == len(l_pt):
ll_pt.append(l_pt)
l_pt = []
lll_pt.append(ll_pt)
return lll_pt
list_img = os.listdir(dir_img)
label_num = [0,0,0,0,0,0]
_classes = {'__background__':0,'cg':1,'cvn':2,'ddg':3,'lcc':4,'render':5}
# import pdb
# pdb.set_trace()
for cnt,img_name in enumerate(list_img):
print("cnt=%d,img_name=%s"%(cnt,img_name))
# txt_name = img_name.replace('.jpg','.txt')
txt_name = img_name.replace('.png','.txt')
label_num[_classes[txt_name.split('_')[0].lower().strip()]]+=1
# path_img = dir_img + img_name
# path_txt = dir_txt + txt_name
# save_path = save_dir + img_name
# img = cv2.imread(path_img)
# lll_pt = deal_txt_pt(path_txt)
# for ll_pt in lll_pt:
# pts = np.array(ll_pt,np.int32)
# pts = pts.reshape((-1, 1, 2))
# cv2.polylines(img, [pts], 1, (0, 255, 255),2)
# cv2.imwrite(save_path,img)
print(label_num)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。