-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCode.py
More file actions
93 lines (79 loc) · 2.71 KB
/
Code.py
File metadata and controls
93 lines (79 loc) · 2.71 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# This app will use your built-in webcam to control your slides presentation.
import win32com.client
from cvzone.HandTrackingModule import HandDetector
import cv2
import os
import numpy as np
import aspose.slides as slides
import aspose.pydrawing as drawing
Application = win32com.client.Dispatch("PowerPoint.Application" )
Presentation = Application.Presentations.Open("C:\\Users\\ujair shaha\\Desktop\\3rd year Notes\\DBMS\ADBMS CA\\ADBMS presentation.pptx")
print(Presentation.Name)
Presentation.SlideShowSettings.Run()
# Parameters
width, height = 900, 720
gestureThreshold = 300
maxZoomFactor = 2
minZoomFactor = 1
zoomFactor = 1
# Camera Setup
cap = cv2.VideoCapture(0)
cap.set(3, width)
cap.set(4, height)
# Hand Detector
detectorHand = HandDetector(detectionCon=0.8, maxHands=1)
# Variables
imgList = []
delay = 30
buttonPressed = False
counter = 0
drawMode = False
imgNumber = 20
delayCounter = 0
annotations = [[]]
annotationNumber = -1
annotationStart = False
while True:
# Get image frame
success, img = cap.read()
imgCurrent = img.copy()
# Find the hand and its landmarks
hands, img = detectorHand.findHands(img) # with draw
if hands and buttonPressed is False: # If hand is detected
hand = hands[0]
cx, cy = hand["center"]
lmList = hand["lmList"] # List of 21 Landmark points
fingers = detectorHand.fingersUp(hand) # List of which fingers are up
if cy <= gestureThreshold: # If hand is at the height of the face
if fingers == [1, 1, 1, 1, 1]:
print("Next")
buttonPressed = True
if imgNumber > 0:
Presentation.SlideShowWindow.View.Next()
annotations = [[]]
annotationNumber = -1
annotationStart = False
if fingers == [1, 0, 0, 0, 0]:
print("Previous")
buttonPressed = True
if imgNumber >0 :
Presentation.SlideShowWindow.View.Previous()
imgNumber += 1
annotations = [[]]
annotationNumber = -1
annotationStart = False
else:
annotationStart = False
if buttonPressed:
counter += 1
if counter > delay:
counter = 0
buttonPressed = False
for i, annotation in enumerate(annotations):
for j in range(len(annotation)):
if j != 0:
cv2.line(imgCurrent, annotation[j - 1], annotation[j], (0, 0, 200), 12)
cv2.imshow("Image", img)
key = cv2.waitKey(1)
if key == ord('q'):
break