当前位置:网站首页>批量可视化目标检测标注框——YOLO格式数据集
批量可视化目标检测标注框——YOLO格式数据集
2022-07-22 22:02:00 【Dreamcatcher风】
import cv2
import os
img_dir = 'D:/images/'
label_dir = 'D:/labels/'
save_dir = 'D:/save/' # 事先新建一个文件夹,用来存放标注好的图片
lable_file = os.listdir(label_dir)
img_file = os.listdir(img_dir)
for file in lable_file:
file_dir = os.path.join(label_dir, file)
with open(file_dir, 'r') as f:
print(os.path.join(img_dir, file.split('.')[0]+'.jpg'))
image_src = cv2.imread(os.path.join(img_dir, file.split('.')[0]+'.jpg'))
image_row = image_src.shape[0]
image_col = image_src.shape[1]
for line in f.readlines():
x_ = float(line.split(' ')[1])
y_ = float(line.split(' ')[2])
w_ = float(line.split(' ')[3])
h_ = float(line.split(' ')[4])
w = image_col
h = image_row
x1 = w * x_ - 0.5 * w * w_
x2 = w * x_ + 0.5 * w * w_
y1 = h * y_ - 0.5 * h * h_
y2 = h * y_ + 0.5 * h * h_
draw = cv2.rectangle(image_src,(int(x1),int(y1)),(int(x2),int(y2)),[0,255,0],2)
cv2.imwrite(os.path.join(save_dir, file.split('.')[0]+'.jpg'), draw)
边栏推荐
- 使用路由协议配置 IPv6 over IP手动隧道
- Example analysis of SQL error reporting and blind injection
- 实验五 JPEG
- Flick batch reading es
- RN underlying principle -- 1. Component and purecomponent analysis
- Amazon's zoox passed the safety test and applied for a test drive in California
- Rust -- detailed explanation of option
- Expérience II Yuv
- Spark疑难杂症排查-Premature EOF: no length prefix available
- golang--module
猜你喜欢

二冲程发动机均值模型仿真

Jmeter查看结果树之查看响应的13种详解方法!

Fledgling Xiao Li's 108th blog binary print

Wechat applet project practice

多商户系统的直播功能用过吗?用过的朋友扣个 666!

Worthington羟基类固醇脱氢酶技术说明及测定方案

Worthington纯化酶制剂助力新生儿心肌细胞分离系统研究

The boss asked me to do an IP territorial function and an open source library!

如何用C语言实现简单职工信息管理系统

Graduation project ----- Internet of things environment detection system based on stm32
随机推荐
PNY file to picture
Experiment 2 YUV
主题域模型
模拟Not All Endpoints Registered异常及解决方案
Example analysis of SQL error reporting and blind injection
Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction
不会吧?钉钉都下载了,你还不知道可以这样玩?
大咖訪談 | 開源社區裏各種奇怪的現狀——夜天之書陳梓立tison
C#中C/S端如何实现WebService服务
Worthington哺乳动物乳酸脱氢酶研究——特点及测定方案
使用Hystrix实现容错处理
Live broadcast preview | live broadcast Seminar on open source security governance models and tools
Three things programmers want to do most | comics
Web资源共享
Scala learning -- six uses of generics [t]
Using private key to connect to server remotely in pycharm
How to use C language to realize simple employee information management system
HCIP --- BGP综合实验
Qt+vtk+pcl pictures are converted to grayscale images and displayed with grayscale as the Y axis
Spark疑难杂症排查-Premature EOF: no length prefix available