I am trying to track down a memory corruption in a routine that crops and resizes an UYVY frame (NDI is the source) but I am not sure if the cv::resize function works for a 2 byte per pixel map (type = CV_8UC2).
If I remove the resize section of my code, leaving only the cropping then I do not see the corruption.
// Create an OpenCV Mat from the source frame
cv::Mat srcMat(src_frame.yres, src_frame.xres, cvType, src_frame.p_data);
// Crop the image using a cv::Rect
cv::Rect crop_region(x, y, crop_width, crop_height);
cv::Mat croppedMat = srcMat(crop_region);
// Resize the cropped image
cv::Mat resizedMat;
cv::resize(croppedMat, resizedMat, cv::Size(new_width, new_height));
// Allocate memory for the resized frame
size_t buffer_size = new_width * new_height * bytes_per_pixel;
dst_frame.p_data = new uint8_t[buffer_size];
// Copy data from the resized OpenCV Mat to the NDIlib_video_frame_v2_t structure
memcpy(dst_frame.p_data, resizedMat.data, buffer_size);