Hello Cordelia,
To resolve the Range of Interest error, make sure that the “ROIPosition” does not exceed the maximum allowed video resolution. This involves adjusting the width of the ROI so that the sum of the “x offset” and “Width” does not exceed the video resolution.
You can refer to the following code snippet to resolve the issue:
vid = videoinput('winvideo', 1);
maxResolution = vid.VideoResolution;
% Define an ROIPosition
% Initially exceeds width
initialROI = [0, 0, maxResolution(1) + 10, maxResolution(2)];
%Adjust the ROI to fit within the video resolution
adjustedWidth = min(initialROI(3), maxResolution(1) - initialROI(1));
% Set the ROIPosition with the adjusted width
vid.ROIPosition = [initialROI(1), initialROI(2), adjustedWidth, initialROI(4)];
% Verify the ROIPosition
disp('Adjusted ROIPosition:');
disp(vid.ROIPosition);
Hope this helps!
For more information, refer to the following MathWorks Documentation:
“videoinput” function:
