Width and height values for ROIPosition must be greater than 0. error even when explicitly defining them.
Show older comments
I am using the image aquisition toolbox to connect to a camera using the gentl communications. I used the imaqhwinfo command to get the needed information and run:
vid = videoinput("gentl", 4, "Mono8",'ROIPosition',[0 0 320 320]);
After this I show the preview window, but this is the first line in the script and it fails here.
Initially this worked fine, but when I restarted matlab and tried again I get the error:
"Width and height values for ROIPosition must be greater than 0."
Initially I didn't specify the ROIPosition and it worked fine, but now even with it specified as shown I get this error.
It starts working again if I launch the imageAcquisitionExplorer. I don't even have to connect to the camera, just launching the explorer and detecting the camera is enough. Then I can close the explorer and after this the above command works in my code with or without the ROIPosition specified. I would rather not have to launch imageAcquisitionExplorer every time I want my script to work. Is there some other way to preemptively correct this problem?
4 Comments
Image Analyst
on 13 Mar 2026
"After this I show the preview window" <== for some reason you forgot to show that line of code. Please give it.
NEEL
on 13 Mar 2026
dpb
on 13 Mar 2026
" I used the imaqhwinfo command to get the needed information..."
@Image Analyst was asking for you to show the results of that command...
Answers (1)
Image Analyst
on 13 Mar 2026
Edited: Image Analyst
on 17 Mar 2026
0 votes
I'm using a Teledyne camera with gentl. What happens if you call this attached InitializeVideoCamera function? It's meant to be called from an AppDesigner program so if you don't have that, just comment out the referenced to "app".
Categories
Find more on GigE Vision Hardware 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!