I am working on implementing custom YOLO segmentation masking into my ROS2 node and have come across an issue where I cannot call setCustomObjectDetectionRuntimeParameters without the process failing. No error is given. If I remove this line and use, I’m assuming, default parameters the process works.
Am I able to set custom object/class parameters if the model is a segmentation model? If I remove this function call, my segmentation detections work but I can’t set properties like is_static, is_grounded, tracking_timeout, etc.
Hi @17njensen,
We will take a look at this to reproduce. Can you confirm whether you are using the official ZED ROS2 wrapper or your own C++ node?
If you can share the JSON result of the ZED_Diagnostic tool, this would help as well.
Hi @mattrouss
It is my own C++ node, though it is mostly merging the ROS2 wrapper into my codebase. As for the JSON result, I am using an SVO recording for my testing. I do not have a ZED camera with me at this moment.
Hi @17njensen,
Are you calling the setCustomObjectDetectionRuntimeParameters method before enableObjectDetection? The SDK expects it to be called after, which may explain why the parameters are not applied.
@mattrouss I just checked and I am calling setCustomObjectDetectionRuntimeParameters after enableObjectDetection.
Do you have the same issue with the official custom segmentation sample: zed-sdk/object detection/custom detector/cpp/tensorrt_yolov8_seg_onnx at master · stereolabs/zed-sdk · GitHub ?
If not, can you send a code snippet that shows if you are handling the parameters differently?
@mattrouss I do get the same issue it seems. To clarify, I can run the custom segmentation sample no problem as the code is given. Making adjustments to that code (the github link you sent) to allow me to add CustomObjectDetectionProperties seems to break things (at least the way I am doing it).
I’ve added a code snippet of adjustments I have made to zed-sdk/object detection/custom detector/cpp/tensorrt_yolov8_seg_onnx/src/main.cpp below. This is how I am doing it in my ROS node as well.
//...
// Custom OD
sl::ObjectDetectionParameters detection_parameters;
detection_parameters.enable_tracking = true;
detection_parameters.enable_segmentation = true;
detection_parameters.detection_model =
sl::OBJECT_DETECTION_MODEL::CUSTOM_BOX_OBJECTS;
state = zed.enableObjectDetection(detection_parameters);
if (state != sl::ERROR_CODE::SUCCESS) {
std::cerr << "[ERROR] Enabling Object Detection: " << \
state << std::endl;
zed.close();
return EXIT_FAILURE;
}
// ---> Changes added here
std::unordered_map<int, sl::CustomObjectDetectionProperties> class_props;
size_t number_of_classes = 2; // According to my loaded model
for (int i = 0; i < number_of_classes; i++) {
sl::CustomObjectDetectionProperties customOdProperties;
//--------add properties to customOdProperties-----------
customOdProperties.enabled = true;
customOdProperties.is_static = true;
// ... (define other properties per class)
//-------------------------------------------------------
class_props[i] = customOdProperties;
}
sl::CustomObjectDetectionRuntimeParameters runtime_params(
sl::CustomObjectDetectionProperties{}, // default properties
class_props
);
std::cout << "Setting Custom Runtime Parameters..." << std::endl;
auto error = zed.setCustomObjectDetectionRuntimeParameters(runtime_params);
std::cout << "Successfully made it past my issue." << std::endl;
// <--- End of changes
// Get camera configuration
sl::CameraConfiguration const camera_config {zed.getCameraInformation().camera_configuration};
sl::Resolution const pc_resolution {std::min(camera_config.resolution.width, 720), std::min(camera_config.resolution.height, 404)};
sl::CameraConfiguration const camera_info {zed.getCameraInformation(pc_resolution).camera_configuration};
// Create OpenGL Viewer
GLViewer viewer;
viewer.init(argc, argv, camera_info.calibration_parameters.left_cam, true);
// ...
Then when building/running it this is the output I get:
[2026-01-27 07:53:01 UTC][ZED][INFO] Logging level INFO
[2026-01-27 07:53:02 UTC][ZED][INFO] [Init] Serial Number: S/N xxxxxxxxx
[2026-01-27 07:53:02 UTC][ZED][INFO] [Init] Depth mode: NEURAL
Setting Custom Runtime Parameters…
Segmentation fault (core dumped)
Thanks
Hi @17njensen,
We have been able to reproduce the issue on our side, and we are currently preparing a fix for the next version of the SDK.
Thank you for reporting this.
@mattrouss Was this added to the latest release? I saw that was posted today (also this latest release sounds amazing!)
Hi @17njensen,
The issue was raised a bit short for release 5.2, a fix is currently in review for the next patch release. Sorry for the wait.