Update app.py
Browse files
app.py
CHANGED
|
@@ -183,6 +183,7 @@ def calculate_angles_landmarks(landmarks):
|
|
| 183 |
}
|
| 184 |
return angles,locations
|
| 185 |
|
|
|
|
| 186 |
# Function to calculate the angles for both left and right sides and overlay on image
|
| 187 |
def calculate_and_display_angles(image1, return_angles=False):
|
| 188 |
|
|
@@ -191,7 +192,11 @@ def calculate_and_display_angles(image1, return_angles=False):
|
|
| 191 |
pose = mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
| 192 |
|
| 193 |
image = image1#cv2.imread(image_path)
|
| 194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
# Get pose landmarks
|
| 197 |
results = pose.process(image_rgb)
|
|
|
|
| 183 |
}
|
| 184 |
return angles,locations
|
| 185 |
|
| 186 |
+
from PIL import Image
|
| 187 |
# Function to calculate the angles for both left and right sides and overlay on image
|
| 188 |
def calculate_and_display_angles(image1, return_angles=False):
|
| 189 |
|
|
|
|
| 192 |
pose = mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
| 193 |
|
| 194 |
image = image1#cv2.imread(image_path)
|
| 195 |
+
|
| 196 |
+
pil_image = Image.open(image).convert('RGB') # PIL image
|
| 197 |
+
|
| 198 |
+
image_np = np.array(pil_image) # Convert to NumPy array
|
| 199 |
+
image_rgb = cv2.cvtColor(image_np, cv2.COLOR_RGB2BGR)
|
| 200 |
|
| 201 |
# Get pose landmarks
|
| 202 |
results = pose.process(image_rgb)
|