Spaces:
Sleeping
Sleeping
Update shadow_map.py
Browse files- shadow_map.py +6 -2
shadow_map.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import cv2, numpy as np
|
| 2 |
from PIL import Image
|
|
|
|
| 3 |
|
| 4 |
def analyze_uv_exposure(image_path):
|
| 5 |
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|
|
@@ -14,6 +15,9 @@ def analyze_uv_exposure(image_path):
|
|
| 14 |
if mask[y, x] == 0:
|
| 15 |
pixels[x, y] = (255, 0, 0, 125)
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
return round(coverage, 2), annotated_path
|
|
|
|
| 1 |
import cv2, numpy as np
|
| 2 |
from PIL import Image
|
| 3 |
+
import tempfile
|
| 4 |
|
| 5 |
def analyze_uv_exposure(image_path):
|
| 6 |
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|
|
|
|
| 15 |
if mask[y, x] == 0:
|
| 16 |
pixels[x, y] = (255, 0, 0, 125)
|
| 17 |
|
| 18 |
+
# Save to temp file instead of current dir
|
| 19 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
|
| 20 |
+
overlay.save(temp_file.name)
|
| 21 |
+
annotated_path = temp_file.name
|
| 22 |
+
|
| 23 |
return round(coverage, 2), annotated_path
|