Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_45659693
yolo_v3
提交
f286391e
yolo_v3
项目概览
qq_45659693
/
yolo_v3
与 Fork 源项目一致
Fork自
DataBall / yolo_v3
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
yolo_v3
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f286391e
编写于
2月 07, 2021
作者:
DataBall
🚴🏻
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add show_yolo_anno
上级
4ee293a7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
67 addition
and
0 deletion
+67
-0
show_yolo_anno.py
show_yolo_anno.py
+67
-0
未找到文件。
show_yolo_anno.py
0 → 100644
浏览文件 @
f286391e
#-*-coding:utf-8-*-
# date:2019-08
# Author: Eric.Lee
# function: show yolo datasets anno
import
cv2
import
os
import
numpy
as
np
if
__name__
==
"__main__"
:
path
=
'./datasets_fusion_hand_train/anno/train.txt'
path_voc_names
=
'./cfg/hand.names'
with
open
(
path_voc_names
,
'r'
)
as
f
:
label_map
=
f
.
readlines
()
for
i
in
range
(
len
(
label_map
)):
label_map
[
i
]
=
label_map
[
i
].
strip
()
print
(
i
,
') '
,
label_map
[
i
].
strip
())
with
open
(
path
,
'r'
)
as
file
:
img_files
=
file
.
read
().
splitlines
()
img_files
=
list
(
filter
(
lambda
x
:
len
(
x
)
>
0
,
img_files
))
label_files
=
[
x
.
replace
(
'images'
,
'labels'
).
replace
(
"JPEGImages"
,
'labels'
).
replace
(
'.bmp'
,
'.txt'
).
replace
(
'.jpg'
,
'.txt'
).
replace
(
'.png'
,
'.txt'
)
for
x
in
img_files
]
# print('img_files : ',img_files[1])
# print('label_files : ',label_files[1])
for
i
in
range
(
len
(
img_files
)):
print
(
img_files
[
i
])
img
=
cv2
.
imread
(
img_files
[
i
])
w
=
img
.
shape
[
1
]
h
=
img
.
shape
[
0
]
label_path
=
label_files
[
i
]
print
(
i
,
label_path
)
if
os
.
path
.
isfile
(
label_path
):
with
open
(
label_path
,
'r'
)
as
file
:
lines
=
file
.
read
().
splitlines
()
x
=
np
.
array
([
x
.
split
()
for
x
in
lines
],
dtype
=
np
.
float32
)
for
k
in
range
(
len
(
x
)):
anno
=
x
[
k
]
label
=
int
(
anno
[
0
])
x1
=
int
((
float
(
anno
[
1
])
-
float
(
anno
[
3
])
/
2
)
*
w
)
y1
=
int
((
float
(
anno
[
2
])
-
float
(
anno
[
4
])
/
2
)
*
h
)
x2
=
int
((
float
(
anno
[
1
])
+
float
(
anno
[
3
])
/
2
)
*
w
)
y2
=
int
((
float
(
anno
[
2
])
+
float
(
anno
[
4
])
/
2
)
*
h
)
cv2
.
rectangle
(
img
,
(
x1
,
y1
),
(
x2
,
y2
),
(
255
,
30
,
30
),
2
)
cv2
.
putText
(
img
,
(
"%s"
%
(
str
(
label_map
[
label
]))),
(
x1
,
y1
),
\
cv2
.
FONT_HERSHEY_PLAIN
,
2.5
,
(
0
,
255
,
55
),
6
)
cv2
.
putText
(
img
,
(
"%s"
%
(
str
(
label_map
[
label
]))),
(
x1
,
y1
),
\
cv2
.
FONT_HERSHEY_PLAIN
,
2.5
,
(
0
,
55
,
255
),
2
)
# cv2.circle(img, (x1,y1), 4, (0,255,225), 6)
cv2
.
namedWindow
(
'image'
,
0
)
cv2
.
imshow
(
'image'
,
img
)
if
cv2
.
waitKey
(
1
)
==
27
:
break
cv2
.
destroyAllWindows
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录