aubome/trial.py
2024-06-18 23:39:03 +05:30

39 lines
977 B
Python

import cv2
import mediapipe as mp
def detect_points(image_path):
image = cv2.imread(image_path)
target_width = 256
target_height = int(image.shape[0] * target_width / image.shape[1])
image = cv2.resize(image, (target_width, target_height))
mp_pose = mp.solutions.pose #type: ignore
pose = mp_pose.Pose(static_image_mode=True, min_detection_confidence=0.5)
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pose.process(image_rgb)
if results.pose_landmarks:
for landmark in results.pose_landmarks.landmark:
cv2.circle(
image,
(int(landmark.x * image.shape[1]),
int(landmark.y * image.shape[0])),
5,
(0, 255, 0),
-1,
)
cv2.imshow("Image", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
image_path = "/home/aparna/projects/aubome/assets/aparna_side.jpg"
detect_points(image_path)