-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
26 lines (19 loc) · 816 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import cv2
import math
from yoloseg import YOLOSeg
def calculate_projection(z, projection_factor, pixel, center, width, height):
x = z * projection_factor['x'] * (pixel['x'] - center['x']) / width
y = z * projection_factor['y'] * (pixel['y'] - center['y']) / height
return x, y
def process_image(image_path):
# Placeholder for the actual model processing
# This function should process the image and return the output image
model_path = "/home/manh/WED_distance_calculator/yolov8m-seg.onnx"
yoloseg = YOLOSeg(model_path, conf_thres=0.5, iou_thres=0.3)
image = cv2.imread(image_path)
img = cv2.imread(image_path)
# Detect Objects
boxes, scores, class_ids, masks = yoloseg(img)
# Draw detections
output_image = yoloseg.draw_masks(img)
return output_image