-
Notifications
You must be signed in to change notification settings - Fork 0
/
ishearthbeating.py
60 lines (50 loc) · 1.7 KB
/
ishearthbeating.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
import cv2
import numpy as np
import time
import sys
from dronekit import connect, VehicleMode
# ls -l /dev
#vehicle = connect('/dev/ttyS0', wait_ready=True, baud=921600)
vehicle = connect('/dev/ttyS0', baud=921600)
#vehicle = connect('/dev/ttyAMA0', baud=921600)
# Get some vehicle attributes (state)
print (" Get some vehicle attribute values:")
print (" GPS: %s" % vehicle.gps_0)
print (" Battery: %s" % vehicle.battery)
print (" Attitude: %s" % vehicle.attitude)
print (" Velocity: %s" % vehicle.velocity)
print (" Last Heartbeat: %s" % vehicle.last_heartbeat)
print (" Is Armable?: %s" % vehicle.is_armable)
print (" System status: %s" % vehicle.system_status.state)
print (" Mode: %s" % vehicle.mode.name) # settable
# Get all channel values from RC transmitter
print "Channel values from RC Tx:", vehicle.channels
# Access channels individually
print "Read channels individually:"
print " Ch1: %s" % vehicle.channels['1']
"""
# Set Ch2 override to 200 using indexing syntax
vehicle.channels.overrides['2'] = 200
# Set Ch3, Ch4 override to 300,400 using dictionary syntax"
vehicle.channels.overrides = {'3':300, '4':400}
"""
#Capturing Real Time Video
cap = cv2.VideoCapture(0)
#width
#cap.set(3,432)
#height
#cap.set(4,432)
if cap.isOpened():
ret , frame = cap.read()
#cap.read() returns a bool (True/False). If frame is read correctly, it will be True. So you can check end of the video by checking this return value.
#ret will store that bool value
else:
ret = False
while ret:
_, frame = cap.read()
cv2.imshow("Real Time", frame)
if cv2.waitKey(1) == 27:
break
cv2.destroyAllWindows()
cap.release()
sys.exit("Quit")