File size: 1,444 Bytes
564e80a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Data Scientist.: Dr.Eddy Giusepe Chirinos Isidro
"""
import mediapipe as mp
import cv2
#from google.colab.patches import cv2_imshow

mp_drawing = mp.solutions.drawing_utils
mp_holistic = mp.solutions.holistic


image = cv2.imread('workout.png')
cv2.imshow('Image', image)
cv2.waitKey(0)
#cv2.destroyAllWindows()


# Executando detecções:
with mp_holistic.Holistic(
    static_image_mode=True, model_complexity=2, enable_segmentation=True, refine_face_landmarks=False) as holistic:

    image = cv2.imread("workout.png")

    # Convert the BGR image to RGB before processing.
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    image_recolored = holistic.process(image)

    # Drawing landmarks on the image.
    annotated_image = image.copy()
    image = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)

    # Drawing facial landmarks
    mp_drawing.draw_landmarks(image, image_recolored.face_landmarks, mp_holistic.FACEMESH_TESSELATION)

    # Drawing pose landmarks
    mp_drawing.draw_landmarks(image, image_recolored.pose_landmarks, mp_holistic.POSE_CONNECTIONS)

    # Drawing the right hand landmarks
    mp_drawing.draw_landmarks(image, image_recolored.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)

    # Drawing the left hand landmarks
    mp_drawing.draw_landmarks(image, image_recolored.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)


    cv2.imshow("Image", image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()