Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
26c2e54c
Unverified
提交
26c2e54c
authored
2月 16, 2021
作者:
Glenn Jocher
提交者:
GitHub
2月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add check_imshow() (#2231)
* Add check_imshow() * Update general.py * Update general.py
上级
f8464b4f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
4 行删除
+17
-4
detect.py
detect.py
+4
-4
general.py
utils/general.py
+13
-0
没有找到文件。
detect.py
浏览文件 @
26c2e54c
...
@@ -9,8 +9,8 @@ from numpy import random
...
@@ -9,8 +9,8 @@ from numpy import random
from
models.experimental
import
attempt_load
from
models.experimental
import
attempt_load
from
utils.datasets
import
LoadStreams
,
LoadImages
from
utils.datasets
import
LoadStreams
,
LoadImages
from
utils.general
import
check_img_size
,
check_requirements
,
non_max_suppression
,
apply_classifier
,
scale_coords
,
\
from
utils.general
import
check_img_size
,
check_requirements
,
check_imshow
,
non_max_suppression
,
apply_classifier
,
\
xyxy2xywh
,
strip_optimizer
,
set_logging
,
increment_path
scale_coords
,
xyxy2xywh
,
strip_optimizer
,
set_logging
,
increment_path
from
utils.plots
import
plot_one_box
from
utils.plots
import
plot_one_box
from
utils.torch_utils
import
select_device
,
load_classifier
,
time_synchronized
from
utils.torch_utils
import
select_device
,
load_classifier
,
time_synchronized
...
@@ -45,7 +45,7 @@ def detect(save_img=False):
...
@@ -45,7 +45,7 @@ def detect(save_img=False):
# Set Dataloader
# Set Dataloader
vid_path
,
vid_writer
=
None
,
None
vid_path
,
vid_writer
=
None
,
None
if
webcam
:
if
webcam
:
view_img
=
True
view_img
=
check_imshow
()
cudnn
.
benchmark
=
True
# set True to speed up constant image size inference
cudnn
.
benchmark
=
True
# set True to speed up constant image size inference
dataset
=
LoadStreams
(
source
,
img_size
=
imgsz
,
stride
=
stride
)
dataset
=
LoadStreams
(
source
,
img_size
=
imgsz
,
stride
=
stride
)
else
:
else
:
...
@@ -118,7 +118,7 @@ def detect(save_img=False):
...
@@ -118,7 +118,7 @@ def detect(save_img=False):
# Stream results
# Stream results
if
view_img
:
if
view_img
:
cv2
.
imshow
(
str
(
p
),
im0
)
cv2
.
imshow
(
str
(
p
),
im0
)
cv2
.
waitKey
(
1
)
# 1 millisecond
cv2
.
waitKey
(
1
)
# 1 millisecond
# Save results (image with detections)
# Save results (image with detections)
if
save_img
:
if
save_img
:
...
...
utils/general.py
浏览文件 @
26c2e54c
...
@@ -95,6 +95,19 @@ def check_img_size(img_size, s=32):
...
@@ -95,6 +95,19 @@ def check_img_size(img_size, s=32):
return
new_size
return
new_size
def
check_imshow
():
# Check if environment supports image displays
try
:
cv2
.
imshow
(
'test'
,
np
.
zeros
((
1
,
1
,
3
)))
cv2
.
waitKey
(
1
)
cv2
.
destroyAllWindows
()
cv2
.
waitKey
(
1
)
return
True
except
Exception
as
e
:
print
(
f
'WARNING: Environment does not support cv2.imshow() or PIL Image.show() image previews
\n
{e}'
)
return
False
def
check_file
(
file
):
def
check_file
(
file
):
# Search for file if not found
# Search for file if not found
if
os
.
path
.
isfile
(
file
)
or
file
==
''
:
if
os
.
path
.
isfile
(
file
)
or
file
==
''
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论