Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,10 +97,19 @@ def process_images(flat_img, persp_img, json_file):
|
|
| 97 |
roi_corners_flat = get_rotated_rect_corners(roi_x, roi_y, roi_w, roi_h, roi_rot_deg)
|
| 98 |
roi_corners_persp = cv2.perspectiveTransform(roi_corners_flat.reshape(-1,1,2), H).reshape(-1,2)
|
| 99 |
|
| 100 |
-
# Draw ROI
|
| 101 |
persp_out = persp_img.copy()
|
| 102 |
cv2.polylines(persp_out, [roi_corners_persp.astype(int)], True, (0,255,0), 3)
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# Convert to RGB for Gradio
|
| 106 |
persp_rgb = cv2.cvtColor(persp_out, cv2.COLOR_BGR2RGB)
|
|
@@ -117,10 +126,10 @@ iface = gr.Interface(
|
|
| 117 |
gr.File(type="filepath", label="JSON File")
|
| 118 |
],
|
| 119 |
outputs=[
|
| 120 |
-
gr.Gallery(label="Detector Results (Perspective Images with ROI & Label)")
|
| 121 |
],
|
| 122 |
title="Feature Detection ROI Projection",
|
| 123 |
-
description="Shows SIFT, ORB, BRISK, AKAZE, KAZE detector results on the Perspective image only, with ROI and detector label."
|
| 124 |
)
|
| 125 |
|
| 126 |
iface.launch()
|
|
|
|
| 97 |
roi_corners_flat = get_rotated_rect_corners(roi_x, roi_y, roi_w, roi_h, roi_rot_deg)
|
| 98 |
roi_corners_persp = cv2.perspectiveTransform(roi_corners_flat.reshape(-1,1,2), H).reshape(-1,2)
|
| 99 |
|
| 100 |
+
# Draw ROI
|
| 101 |
persp_out = persp_img.copy()
|
| 102 |
cv2.polylines(persp_out, [roi_corners_persp.astype(int)], True, (0,255,0), 3)
|
| 103 |
+
|
| 104 |
+
# Draw attractive detector label box
|
| 105 |
+
text = det
|
| 106 |
+
font = cv2.FONT_HERSHEY_SIMPLEX
|
| 107 |
+
scale = 1
|
| 108 |
+
thickness = 2
|
| 109 |
+
text_size = cv2.getTextSize(text, font, scale, thickness)[0]
|
| 110 |
+
text_x, text_y = 10, 30
|
| 111 |
+
cv2.rectangle(persp_out, (text_x-5, text_y-25), (text_x + text_size[0]+5, text_y+5), (0,0,0), -1)
|
| 112 |
+
cv2.putText(persp_out, text, (text_x, text_y), font, scale, (0,255,255), thickness)
|
| 113 |
|
| 114 |
# Convert to RGB for Gradio
|
| 115 |
persp_rgb = cv2.cvtColor(persp_out, cv2.COLOR_BGR2RGB)
|
|
|
|
| 126 |
gr.File(type="filepath", label="JSON File")
|
| 127 |
],
|
| 128 |
outputs=[
|
| 129 |
+
gr.Gallery(label="Detector Results (Perspective Images with ROI & Detector Label)")
|
| 130 |
],
|
| 131 |
title="Feature Detection ROI Projection",
|
| 132 |
+
description="Shows SIFT, ORB, BRISK, AKAZE, KAZE detector results on the Perspective image only, with ROI and attractive detector label."
|
| 133 |
)
|
| 134 |
|
| 135 |
iface.launch()
|