-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
69 lines (53 loc) · 1.88 KB
/
main.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
64
65
66
67
68
69
import mediapipe as mp
import cv2
from handTracking import HandTracking
from touchSensing import TouchSensing
from multiprocessing import Process, Queue
#from userStudy1 import UserStudy1
from view import Window
from PyQt5.QtWidgets import QApplication
import sys
def getImage(q):
mp_hands = mp.solutions.hands
cap = cv2.VideoCapture(1)
with mp_hands.Hands(
model_complexity=0,
min_detection_confidence=0.5,
min_tracking_confidence=0.5) as hands:
while cap.isOpened():
success, image = cap.read()
if not success:
print("Empty camera frame")
else:
image.flags.writeable = False
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.flip(image, 1)
results = hands.process(image)
q.put(image)
def handTrackingFunction(q):
handTracking = HandTracking(imageQueue = q)
handTracking.getImage()
def touchSensingFunction(q):
touchSensing = TouchSensing(q, port="/dev/cu.usbserial-AL03KLV2", baudrate=115200)
touchSensing.getSensorData()
if __name__ == '__main__':
imageQueue = Queue()
handTrackingProcess = Process(target=handTrackingFunction, args=(imageQueue, ))
handTrackingProcess.start()
getImageProcess = Process(target=getImage, args=(imageQueue,))
getImageProcess.start()
touchSensingQueue = Queue()
touchSensingProcess = Process(target=touchSensingFunction, args=(touchSensingQueue, ))
touchSensingProcess.start()
#userStudy1 = UserStudy1(imageQueue, touchSensingQueue, )
App = QApplication(sys.argv)
window = Window(touchSensingQueue)
sys.exit(App.exec_())
#try:
#while True:
#result = touchSensingQueue.get()
#except:
#pass
handTrackingProcess.join()
getImageProcess.join()
touchSensingProcess.join()