-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLaunch-os.py
59 lines (46 loc) · 1.44 KB
/
Launch-os.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
import cv2
cap = cv2.VideoCapture(0)
from cvzone.HandTrackingModule import HandDetector
handDetector = HandDetector()
import boto3
myec2client = boto3.client(
"ec2",
aws_access_key_id="AKIAUW5PJDEB2MITC3C",
aws_secret_access_key="VTNISAZu1xsK0KSYEtoxJvtW8mjQ9RMONmM6v1S",
region_name="ap-south-1"
)
def lwOSrun():
myosrun = myec2client.run_instances(
InstanceType="t2.micro",
ImageId="ami-02a2af70a66af6dfb",
MaxCount=1,
MinCount=1,
)
return myosrun
def lwOSterminate(myosrun):
myosterminate = myec2client.terminate_instances(
InstanceIds=[ myosrun['Instances'][0]['InstanceId'] ]
)
import time
while True:
status, myphoto = cap.read()
handPhotoDraw = handDetector.findHands(myphoto, draw=True)
if handPhotoDraw[0]:
photoDraw = handPhotoDraw[1]
handLmList = handPhotoDraw[0][0]
handFingerUp = handDetector.fingersUp(handLmList)
if handFingerUp == [0, 1, 0, 0, 0]:
myos = lwOSrun()
print("os launching ..")
time.sleep(2)
elif handFingerUp == [0, 1, 1, 0, 0]:
lwOSterminate(myos)
print("os terminating ..")
time.sleep(2)
else:
pass
cv2.imshow("My photo" , myphoto)
if cv2.waitKey(100) == 13:
break
cv2.destroyAllWindows()
cap.release()