Update app.py
Browse files
app.py
CHANGED
|
@@ -202,6 +202,13 @@ def calculate_and_display_angles(image1, return_angles=False):
|
|
| 202 |
image = image1#cv2.imread(image_path)
|
| 203 |
image_rgb = image1 #cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
# Get pose landmarks
|
| 206 |
results = pose.process(image_rgb)
|
| 207 |
|
|
@@ -221,8 +228,8 @@ def calculate_and_display_angles(image1, return_angles=False):
|
|
| 221 |
# Display the angle values at corresponding locations
|
| 222 |
def overlay_angle(angle, location, color=(0, 255, 0)):
|
| 223 |
# Coordinates are normalized, scale them to the image size
|
| 224 |
-
x = int(location[0] * image.shape[1])
|
| 225 |
-
y = int(location[1] * image.shape[0])
|
| 226 |
cv2.putText(image, f'{angle:.2f}', (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.3, color, 1)
|
| 227 |
|
| 228 |
# Overlay angles on the image
|
|
|
|
| 202 |
image = image1#cv2.imread(image_path)
|
| 203 |
image_rgb = image1 #cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 204 |
|
| 205 |
+
# Decode image from memory
|
| 206 |
+
data = np.frombuffer(image1.getvalue(), dtype=np.uint8)
|
| 207 |
+
image = cv2.imdecode(data, cv2.IMREAD_COLOR)
|
| 208 |
+
|
| 209 |
+
# Get image dimensions
|
| 210 |
+
height, width, channels = image.shape
|
| 211 |
+
|
| 212 |
# Get pose landmarks
|
| 213 |
results = pose.process(image_rgb)
|
| 214 |
|
|
|
|
| 228 |
# Display the angle values at corresponding locations
|
| 229 |
def overlay_angle(angle, location, color=(0, 255, 0)):
|
| 230 |
# Coordinates are normalized, scale them to the image size
|
| 231 |
+
x = int(location[0] * width)#image.shape[1])
|
| 232 |
+
y = int(location[1] * height)#image.shape[0])
|
| 233 |
cv2.putText(image, f'{angle:.2f}', (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.3, color, 1)
|
| 234 |
|
| 235 |
# Overlay angles on the image
|