Limits of ROI in imaqtool
6 views (last 30 days)
Show older comments
I am working on a code that will use the Image Acquisition Tool in the command line with functions I have created. Currently I am having problems with the Range of Interest commands, and I keep getting an error that says:
Error using imaqdevice/subsasgn (line 33)
VideoResolution width exceeded. The sum of the ROIPosition X offset and Width values is too large.
I understand this is because the numbers entered are too large for the system to handle, but I ma trying to create a function that will handle this. I created a line already that dealt with possible negatives in X-Offset and Y-Offset, but I need to either change this or add another line that will catch the above error. Here is the code I have already:
vid.ROIPosition = [max(0,ROI(1)),max(0,ROI(2)),min(ROI(3),CurROI(3)),min(ROI(4),CurROI(4))];
Anything would be helpful, thank you!
0 Comments
Answers (1)
Charu
on 27 Mar 2025
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:
0 Comments
See Also
Categories
Find more on Acquisition Using Image Acquisition Explorer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!