-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
33 lines (30 loc) · 1.12 KB
/
check.py
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
import math
from detects.helmet import *
from detects.gps import *
from settings import *
class Check:
def __init__(self):
self.helmet = Helmet()
self.gps = Gps()
self.move = 'stop'
def set_speed(self, helmet_state, tim):
global max_speed
if helmet_state == 'on' or (BOHO[0][0] < self.gps.lat < BOHO[1][0] and BOHO[0][1] < self.gps.lon < BOHO[1][1]):
if max_speed > 19.8:
max_speed = 20
else:
var_speed = 10 / (1 + math.exp(-0.05 * (tim%36) + 5))
max_speed = max_speed + var_speed
if helmet_state == 'off':
if max_speed < 10.2:
max_speed = 10
else:
var_speed = 10 / (1 + math.exp(-0.05 * (tim%36) + 5))
max_speed = max_speed - var_speed
else:
self.helmet.helmet_state = 'non'
print(max_speed)
def update(self, img0, xyxy, detect_name, draw_color, sec):
self.helmet.detect_helmet(img0, xyxy, detect_name, draw_color)
self.gps.detect_gps()
self.set_speed(self.helmet.helmet_state, sec)