-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (37 loc) · 1.48 KB
/
Copy pathmain.py
File metadata and controls
54 lines (37 loc) · 1.48 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
import cv2
import mediapipe as mp
from modules.face_analyzer import FaceAnalyzer
from modules.hand_analyzer import HandAnalyzer
from modules.canvas_manager import CanvasManager
def main():
face_analyzer = FaceAnalyzer()
hand_analyzer = HandAnalyzer()
cap = cv2.VideoCapture(0)
# Lecture d'une premiere frame pour obtenir la resolution
success, image = cap.read()
if not success:
print("Erreur: Impossible d'acceder a la camera.")
return
img_h, img_w, _ = image.shape
canvas_manager = CanvasManager(img_w, img_h)
print("Appuyez sur 'q' pour quitter la fenetre de la camera.")
while cap.isOpened():
success, image = cap.read()
if not success:
break
image = cv2.flip(image, 1) # Effet miroir naturel
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=image_rgb)
# Analyser le visage et dessiner le HUD
face_analyzer.draw_face_hud(image, mp_image, img_w, img_h)
# Analyser les mains et appliquer les interactions de dessin
hand_analyzer.analyze_hands(image, mp_image, img_w, img_h, canvas_manager)
# Fusionner la toile et la camera
final_image = canvas_manager.overlay_on(image)
cv2.imshow("Face Tracker & AR Drawing", final_image)
if cv2.waitKey(5) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
main()