Untitled
unknown
python
2 years ago
776 B
9
Indexable
def return_predictions(images_paths, model, classes=None):
'''
Create bounding box generator
'''
for image in images_paths:
results = model.predict(image, classes=classes)
for r in results:
boxes = [box for box in r.boxes]
names = [model.names[int(box.cls)] for box in r.boxes]
yield boxes, names, image
def get_avg_depth(xyxy, depth_coords, depth_values):
# depths_coords = dict(
# coords=depth_coords,
# )
# top left
x_points, y_points = depth_coords
xmin, ymin, xmax, ymax = xyxy
filtered_points = np.logical_and.reduce((
x_points >= xmin,
x_points <= xmax,
y_points >= ymin,
y_points <= ymax
))
avg_depth = np.mean(depth_values[filtered_points])
return avg_depth
Editor is loading...
Leave a Comment