-
Notifications
You must be signed in to change notification settings - Fork 1
/
osd.py
executable file
·63 lines (47 loc) · 1.44 KB
/
osd.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python
import math
import numpy
import time
import cv2
from Connector.MspConnector import MspConnector
from DataModel.Hud import Hud
from Draw.Altitude import Altitude
from Draw.Pitch import Pitch
from Draw.PlaneSymbol import PlaneSymbol
from Draw.Speed import Speed
cap = cv2.VideoCapture(0)
frameNumber = numpy.int64(0)
start = time.time()
color = (0, 255, 0)
hud = Hud()
msp = MspConnector("/dev/ttyACM0", hud)
while True:
frameNumber += 1
# Capture frame-by-frame
ret, img = cap.read()
# Our operations on the frame come here
# img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Draw Center pointer
PlaneSymbol.draw(img, hud)
# Draw a pich line
Pitch.draw(img, hud, color)
# Altitude a pich line
Altitude.draw(img, hud, color)
# Speed a pich line
Speed.draw(img, hud, color)
# End time
end = time.time()
# Time elapsed
seconds = end - start
font = cv2.FONT_HERSHEY_PLAIN
fps = "%10.2f fps" % (frameNumber / seconds)
cv2.putText(img, fps, (10, 450), font, 1, color, 1, cv2.CV_AA)
cv2.putText(img, frameNumber.astype('|S10'), (10, 440), font, 1, color, 1, cv2.CV_AA)
# cv2.ellipse(img, (256, 256), (100, 100), 0, 40 + frameNumber, 160 + frameNumber, 255, 0)
# Display the resulting frame
cv2.imshow('frame', img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()