eddygiusepe commited on
Commit
564e80a
·
1 Parent(s): 66a70b3

Exemplo com opencv

Browse files
Files changed (1) hide show
  1. 2_MediaPipe-Object-Detections.py +47 -0
2_MediaPipe-Object-Detections.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Data Scientist.: Dr.Eddy Giusepe Chirinos Isidro
3
+ """
4
+ import mediapipe as mp
5
+ import cv2
6
+ #from google.colab.patches import cv2_imshow
7
+
8
+ mp_drawing = mp.solutions.drawing_utils
9
+ mp_holistic = mp.solutions.holistic
10
+
11
+
12
+ image = cv2.imread('workout.png')
13
+ cv2.imshow('Image', image)
14
+ cv2.waitKey(0)
15
+ #cv2.destroyAllWindows()
16
+
17
+
18
+ # Executando detecções:
19
+ with mp_holistic.Holistic(
20
+ static_image_mode=True, model_complexity=2, enable_segmentation=True, refine_face_landmarks=False) as holistic:
21
+
22
+ image = cv2.imread("workout.png")
23
+
24
+ # Convert the BGR image to RGB before processing.
25
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
26
+ image_recolored = holistic.process(image)
27
+
28
+ # Drawing landmarks on the image.
29
+ annotated_image = image.copy()
30
+ image = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
31
+
32
+ # Drawing facial landmarks
33
+ mp_drawing.draw_landmarks(image, image_recolored.face_landmarks, mp_holistic.FACEMESH_TESSELATION)
34
+
35
+ # Drawing pose landmarks
36
+ mp_drawing.draw_landmarks(image, image_recolored.pose_landmarks, mp_holistic.POSE_CONNECTIONS)
37
+
38
+ # Drawing the right hand landmarks
39
+ mp_drawing.draw_landmarks(image, image_recolored.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)
40
+
41
+ # Drawing the left hand landmarks
42
+ mp_drawing.draw_landmarks(image, image_recolored.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)
43
+
44
+
45
+ cv2.imshow("Image", image)
46
+ cv2.waitKey(0)
47
+ cv2.destroyAllWindows()