Update app.py
Browse files
app.py
CHANGED
|
@@ -183,7 +183,7 @@ def calculate_angles_landmarks(landmarks):
|
|
| 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,10 +192,11 @@ def calculate_and_display_angles(image1, return_angles=False):
|
|
| 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 |
-
image_np = np.array(pil_image) # Convert to NumPy array
|
| 198 |
-
image_rgb = cv2.cvtColor(image_np, cv2.COLOR_RGB2BGR)
|
| 199 |
|
| 200 |
# Get pose landmarks
|
| 201 |
results = pose.process(image_rgb)
|
|
@@ -279,7 +280,7 @@ def upload_file():
|
|
| 279 |
file.seek(0)
|
| 280 |
mime_type, _ = mimetypes.guess_type(file.filename)
|
| 281 |
|
| 282 |
-
|
| 283 |
|
| 284 |
return send_file(
|
| 285 |
BytesIO(file.read()), mimetype=mime_type,
|
|
|
|
| 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 |
+
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 196 |
|
| 197 |
+
# pil_image = Image.open(image).convert('RGB') # PIL image
|
| 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)
|
|
|
|
| 280 |
file.seek(0)
|
| 281 |
mime_type, _ = mimetypes.guess_type(file.filename)
|
| 282 |
|
| 283 |
+
f1 = calculate_and_display_angles(file)
|
| 284 |
|
| 285 |
return send_file(
|
| 286 |
BytesIO(file.read()), mimetype=mime_type,
|