Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ROI mask always being invalid #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions gst-zed-src/gstzedsrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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<sl::uchar1>(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<sl::uchar1>(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);
Expand Down