Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
7b0eb952
Unverified
提交
7b0eb952
authored
5月 19, 2021
作者:
yeric1789
提交者:
GitHub
5月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
`plot_one_box()` default `color=(128, 128, 128)` (#3240)
* Color can be none by default * `plot_one_box()` default `color=(128, 128, 128)` Co-authored-by:
Glenn Jocher
<
glenn.jocher@ultralytics.com
>
上级
b7cd1f54
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
5 行增加
和
7 行删除
+5
-7
plots.py
utils/plots.py
+5
-7
没有找到文件。
utils/plots.py
浏览文件 @
7b0eb952
...
@@ -68,11 +68,10 @@ def butter_lowpass_filtfilt(data, cutoff=1500, fs=50000, order=5):
...
@@ -68,11 +68,10 @@ def butter_lowpass_filtfilt(data, cutoff=1500, fs=50000, order=5):
return
filtfilt
(
b
,
a
,
data
)
# forward-backward filter
return
filtfilt
(
b
,
a
,
data
)
# forward-backward filter
def
plot_one_box
(
x
,
im
,
color
=
None
,
label
=
None
,
line_thickness
=
3
):
def
plot_one_box
(
x
,
im
,
color
=
(
128
,
128
,
128
)
,
label
=
None
,
line_thickness
=
3
):
# Plots one bounding box on image 'im' using OpenCV
# Plots one bounding box on image 'im' using OpenCV
assert
im
.
data
.
contiguous
,
'Image not contiguous. Apply np.ascontiguousarray(im) to plot_on_box() input image.'
assert
im
.
data
.
contiguous
,
'Image not contiguous. Apply np.ascontiguousarray(im) to plot_on_box() input image.'
tl
=
line_thickness
or
round
(
0.002
*
(
im
.
shape
[
0
]
+
im
.
shape
[
1
])
/
2
)
+
1
# line/font thickness
tl
=
line_thickness
or
round
(
0.002
*
(
im
.
shape
[
0
]
+
im
.
shape
[
1
])
/
2
)
+
1
# line/font thickness
color
=
color
or
[
random
.
randint
(
0
,
255
)
for
_
in
range
(
3
)]
c1
,
c2
=
(
int
(
x
[
0
]),
int
(
x
[
1
])),
(
int
(
x
[
2
]),
int
(
x
[
3
]))
c1
,
c2
=
(
int
(
x
[
0
]),
int
(
x
[
1
])),
(
int
(
x
[
2
]),
int
(
x
[
3
]))
cv2
.
rectangle
(
im
,
c1
,
c2
,
color
,
thickness
=
tl
,
lineType
=
cv2
.
LINE_AA
)
cv2
.
rectangle
(
im
,
c1
,
c2
,
color
,
thickness
=
tl
,
lineType
=
cv2
.
LINE_AA
)
if
label
:
if
label
:
...
@@ -83,17 +82,16 @@ def plot_one_box(x, im, color=None, label=None, line_thickness=3):
...
@@ -83,17 +82,16 @@ def plot_one_box(x, im, color=None, label=None, line_thickness=3):
cv2
.
putText
(
im
,
label
,
(
c1
[
0
],
c1
[
1
]
-
2
),
0
,
tl
/
3
,
[
225
,
255
,
255
],
thickness
=
tf
,
lineType
=
cv2
.
LINE_AA
)
cv2
.
putText
(
im
,
label
,
(
c1
[
0
],
c1
[
1
]
-
2
),
0
,
tl
/
3
,
[
225
,
255
,
255
],
thickness
=
tf
,
lineType
=
cv2
.
LINE_AA
)
def
plot_one_box_PIL
(
box
,
im
,
color
=
None
,
label
=
None
,
line_thickness
=
None
):
def
plot_one_box_PIL
(
box
,
im
,
color
=
(
128
,
128
,
128
)
,
label
=
None
,
line_thickness
=
None
):
# Plots one bounding box on image 'im' using PIL
# Plots one bounding box on image 'im' using PIL
im
=
Image
.
fromarray
(
im
)
im
=
Image
.
fromarray
(
im
)
draw
=
ImageDraw
.
Draw
(
im
)
draw
=
ImageDraw
.
Draw
(
im
)
line_thickness
=
line_thickness
or
max
(
int
(
min
(
im
.
size
)
/
200
),
2
)
line_thickness
=
line_thickness
or
max
(
int
(
min
(
im
.
size
)
/
200
),
2
)
draw
.
rectangle
(
box
,
width
=
line_thickness
,
outline
=
tuple
(
color
)
)
# plot
draw
.
rectangle
(
box
,
width
=
line_thickness
,
outline
=
color
)
# plot
if
label
:
if
label
:
fontsize
=
max
(
round
(
max
(
im
.
size
)
/
40
),
12
)
font
=
ImageFont
.
truetype
(
"Arial.ttf"
,
size
=
max
(
round
(
max
(
im
.
size
)
/
40
),
12
))
font
=
ImageFont
.
truetype
(
"Arial.ttf"
,
fontsize
)
txt_width
,
txt_height
=
font
.
getsize
(
label
)
txt_width
,
txt_height
=
font
.
getsize
(
label
)
draw
.
rectangle
([
box
[
0
],
box
[
1
]
-
txt_height
+
4
,
box
[
0
]
+
txt_width
,
box
[
1
]],
fill
=
tuple
(
color
)
)
draw
.
rectangle
([
box
[
0
],
box
[
1
]
-
txt_height
+
4
,
box
[
0
]
+
txt_width
,
box
[
1
]],
fill
=
color
)
draw
.
text
((
box
[
0
],
box
[
1
]
-
txt_height
+
1
),
label
,
fill
=
(
255
,
255
,
255
),
font
=
font
)
draw
.
text
((
box
[
0
],
box
[
1
]
-
txt_height
+
1
),
label
,
fill
=
(
255
,
255
,
255
),
font
=
font
)
return
np
.
asarray
(
im
)
return
np
.
asarray
(
im
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论