Facial_Recognition_with_Python_OpenCV_mediapipe / 2_MediaPipe-Object-Detections.py
eddygiusepe
Exemplo com opencv
564e80a
"""
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()