5 Star 5 Fork 1

soldatJiang / robot-grasp-detection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
convert_validation.py 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
AngelJia 提交于 2018-05-04 16:41 . delete false file
import cv2
import os
if not os.path.exists('validation_img'):
os.makedirs('validation_img')
f = open("validation_result.txt",'r')
isFilename = True
filename = ''
while True:
line = f.readline()
if line == '':
break
#print('line:', line)
if isFilename:
filename = line.strip()
img = cv2.imread(filename)
print(filename)
else:
edges = line[:-1].strip().split(',')
p1 = (int(float(edges[0])/0.35), int(float(edges[1])/0.47))
p2 = (int(float(edges[2])/0.35), int(float(edges[3])/0.47))
p3 = (int(float(edges[4])/0.35), int(float(edges[5])/0.47))
p4 = (int(float(edges[6])/0.35), int(float(edges[7])/0.47))
cv2.line(img, p1, p2, (0, 0, 255))
cv2.line(img, p2, p3, (0, 0, 255))
cv2.line(img, p3, p4, (0, 0, 255))
cv2.line(img, p4, p1, (0, 0, 255))
writefile = filename.split('\\')[-1]
cv2.imwrite('validation_img/'+writefile, img)
isFilename = not isFilename
f.close()
Python
1
https://gitee.com/soldatjiang/robot-grasp-detection.git
git@gitee.com:soldatjiang/robot-grasp-detection.git
soldatjiang
robot-grasp-detection
robot-grasp-detection
master

搜索帮助