From d73dd50e509371806f4f1757ac463b3fb18a74e3 Mon Sep 17 00:00:00 2001 From: Ryan Peters Date: Thu, 30 May 2024 13:13:00 -0500 Subject: [PATCH] Fix ROI mask always being invalid Fixes Region of Interest mask always being invalid for the entire image when toggled. In SDK v4.0, Region of Interest mask can no longer be populated with '1' to indicate a valid pixel; must use '255'. --- gst-zed-src/gstzedsrc.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gst-zed-src/gstzedsrc.cpp b/gst-zed-src/gstzedsrc.cpp index 589fd35..5fd2fd7 100644 --- a/gst-zed-src/gstzedsrc.cpp +++ b/gst-zed-src/gstzedsrc.cpp @@ -2238,7 +2238,7 @@ static gboolean gst_zedsrc_start(GstBaseSrc *bsrc) { init_params.camera_disable_self_calib = src->camera_disable_self_calib == TRUE; GST_INFO(" * Disable self calibration: %s", (init_params.camera_disable_self_calib ? "TRUE" : "FALSE")); - + sl::String opencv_calibration_file(src->opencv_calibration_file.str); init_params.optional_opencv_calibration_file = opencv_calibration_file; GST_INFO(" * Calibration File: %s ", init_params.optional_opencv_calibration_file.c_str()); @@ -2368,13 +2368,11 @@ static gboolean gst_zedsrc_start(GstBaseSrc *bsrc) { src->roi_y >= 0 && src->roi_y < resolution.height && roi_x_end <= resolution.width && roi_y_end <= resolution.height) { - sl::uchar1 uint0 = 0; - sl::uchar1 uint1 = 1; sl::Mat roi_mask(resolution, sl::MAT_TYPE::U8_C1, sl::MEM::CPU); - roi_mask.setTo(uint0); - for (int row = src->roi_y; row < roi_y_end; row++) - for (int col = src->roi_y; col < roi_x_end; col++) - roi_mask.setValue(col, row, uint1); + roi_mask.setTo(0, sl::MEM::CPU); + for (unsigned int v = src->roi_y; v < roi_y_end; v++) + for (unsigned int u = src->roi_x; u < roi_x_end; u++) + roi_mask.setValue(u, v, 255, sl::MEM::CPU); GST_INFO(" * ROI mask: (%d,%d)-%dx%d", src->roi_x, src->roi_y, src->roi_w, src->roi_h);