Spaces:
Running
Running
Commit
·
ab75898
1
Parent(s):
d61d710
deploy app
Browse files
app.py
CHANGED
@@ -70,7 +70,7 @@ file_urls = [
|
|
70 |
'https://github.com/lucarei/orientation-detection-robotic-grasping/assets/22428774/cefd9731-c57c-428b-b401-fd54a8bd0a95',
|
71 |
'https://github.com/lucarei/orientation-detection-robotic-grasping/assets/22428774/acbad76a-33f9-4028-b012-4ece5998c272',
|
72 |
'https://github.com/lucarei/orientation-detection-robotic-grasping/assets/22428774/ce8a0fb9-99ea-4952-bcc4-3afa023066d9',
|
73 |
-
'https://www.dropbox.com/
|
74 |
]
|
75 |
|
76 |
def download_file(url, save_name):
|
@@ -165,6 +165,23 @@ def show_preds_video(video_path):
|
|
165 |
if ret:
|
166 |
frame_copy = frame.copy()
|
167 |
outputs = model.predict(source=frame)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
results = outputs[0].cpu().numpy()
|
169 |
for i, det in enumerate(results.boxes.xyxy):
|
170 |
cv2.rectangle(
|
|
|
70 |
'https://github.com/lucarei/orientation-detection-robotic-grasping/assets/22428774/cefd9731-c57c-428b-b401-fd54a8bd0a95',
|
71 |
'https://github.com/lucarei/orientation-detection-robotic-grasping/assets/22428774/acbad76a-33f9-4028-b012-4ece5998c272',
|
72 |
'https://github.com/lucarei/orientation-detection-robotic-grasping/assets/22428774/ce8a0fb9-99ea-4952-bcc4-3afa023066d9',
|
73 |
+
'https://www.dropbox.com/scl/fi/z706oqbexdbk3gjvlzzjo/video-2160p.mp4?rlkey=7s3cx7tiwitwuad4k34f6jo9g&dl=0'
|
74 |
]
|
75 |
|
76 |
def download_file(url, save_name):
|
|
|
165 |
if ret:
|
166 |
frame_copy = frame.copy()
|
167 |
outputs = model.predict(source=frame)
|
168 |
+
for object in range(len(outputs[0].masks.masks)):
|
169 |
+
#obtain BW image
|
170 |
+
bw=(outputs[0].masks.masks[object].cpu().numpy() * 255).astype("uint8")
|
171 |
+
contours, _ = cv2.findContours(bw, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
|
172 |
+
for i, c in enumerate(contours):
|
173 |
+
# Calculate the area of each contour
|
174 |
+
area = cv2.contourArea(c)
|
175 |
+
|
176 |
+
# Ignore contours that are too small or too large
|
177 |
+
if area < 2500 or 500000 < area:
|
178 |
+
continue
|
179 |
+
|
180 |
+
# Draw each contour only for visualisation purposes
|
181 |
+
cv2.drawContours(frame_copy, contours, i, (0, 0, 255), 2)
|
182 |
+
|
183 |
+
# Find the orientation of each shape
|
184 |
+
angle_deg = getOrientation(c, frame_copy)
|
185 |
results = outputs[0].cpu().numpy()
|
186 |
for i, det in enumerate(results.boxes.xyxy):
|
187 |
cv2.rectangle(
|