Skip to content

Commit

Permalink
move model into class
Browse files Browse the repository at this point in the history
  • Loading branch information
PetervDooren committed Oct 19, 2023
1 parent f115703 commit ff08f4d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ed_sensor_integration/scripts/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@

class table_segmentor:
def __init__(self) -> None:
model_path = "~/MEGA/developers/Donal/yolov8x-seg.pt"
device = "cuda"
self.model = YOLO(model_path).to(device)
self.table_class = 60 #table class defined with index 60 (person = 0)

rospy.init_node('listener', anonymous=True)
self.publisher = rospy.Publisher('/hero/segmented_image',Image)
self.subscriber = rospy.Subscriber('/hero/head_rgbd_sensor/rgb/image_raw',Image , self.callback)
Expand All @@ -63,16 +68,11 @@ def callback(self, data):
bridge = CvBridge()
cv_image = bridge.imgmsg_to_cv2(data, desired_encoding='passthrough')
rospy.loginfo("converted message")
#Yolov8 model code

model_path = "~/MEGA/developers/Donal/yolov8x-seg.pt"
device = "cuda"
model = YOLO(model_path).to(device)
table_class = 60 #table class defined with index 60 (person = 0)
classes, segmentations = self.detect(model, cv_image)
classes, segmentations = self.detect(self.model, cv_image)
#extract table segment and add to frame
for class_id, seg in zip(classes, segmentations):
if class_id == table_class:
if class_id == self.table_class:
cv2.polylines(cv_image, [seg], True, (255,0,0), 2)
# cv2.imshow("Segmented Image", cv_image)
# cv2.waitKey(1)
Expand Down

0 comments on commit ff08f4d

Please sign in to comment.