Repository navigation
Expand file tree
/
Copy pathdemo.py
More file actions
50 lines (46 loc) · 1.55 KB
/
Copy pathdemo.py
File metadata and controls
50 lines (46 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project: Helmet Detector
Author: Leo
-------------------------------------------------
# code is far away from bugs with the god animal protecting
I love animals. They taste delicious.
┏┓ ┏┓
┏┛┻━━━━━━━━━━┛┻┓
┃ ☃ ┃
┃ ┳━┛ ┗━┳ ┃
┃ ┻ ┃
┗━━━┓ ┏━┛
┃ ┗━━━━━━ ┓
┃ 神兽保佑 ┣┓
┃ 永无BUG! ┏┛
┗━┓ ┓ ┏━━┳ ┓ ┏━┛
┃ ┫ ┫ ┃ ┫ ┫
┗━┻━┛ ┗━┻━┛
-------------------------------------------------
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import cv2
from opts import opts
from lib.detectors.ctdet import CtdetDetector
time_stats = ['tot', 'pre', 'net', 'dec', 'post', 'merge']
def demo(opt):
detector = CtdetDetector(opt)
cam = cv2.VideoCapture(0)
while True:
_, img = cam.read()
ret = detector.run(img)
time_str = ''
for stat in time_stats:
time_str = time_str + '{} {:.3f}s |'.format(stat, ret[stat])
print(time_str)
if cv2.waitKey(1) == 27:
return # esc to quit
if __name__ == '__main__':
opt = opts().init()
print(opt)
demo(opt)