I am trying to implement a yolov8 object detection model from Ultralytics and have encountered issues regarding the use of applying segmentation mask on detected objects based on this given sample. Currently, bounding boxes could be displayed but the mask is not displayed even when setting as such: detection_parameters.enable_segmentation = true
. Furthermore, using the code below to obtain the segmentation mask height only outputs 0.
Note: I have edited the code such that ROS2 is built around the sample code provided
for (size_t j = 0; j < detections.size(); j++)
{
if (objects.object_list.size() > 0)
{
RCLCPP_INFO_STREAM(LOGGER, ("obj_id: " + std::to_string((int) detections[j].label)));
object_mask = objects.object_list[j].mask;
RCLCPP_INFO_STREAM(LOGGER, ("obj_height: " + std::to_string(object_mask.getHeight())));
}
}
Hence, I thought that an instance segmentation model (Yolov8n-seg model) is required which led me to generate a .engine file but it could not get past the TensorRT engine initialization and crashed as shown below.
Therefore, what is the solution to obtain the segmentation mask and its related data through C++?