Error using videoinput - Width and height values for ROIPosition must be greater than 0.

14 次查看(过去 30 天)
Hello everyone,
I'm trying to write a code in App Designer for the Lab. A part of it should just read in the input of a camera (Basler puA 1600-60uc) and display a live preview on a specified axes. Now my problem is that the code only works in 50% of cases. I never used App Designer and I don't know how to debug a code that sometimes works and starts the preview... and sometimes the program just closes itself and an error message is displayed. I'd be thankful if anyone could help me correct the code, so it just starts the camera reliably.
The Startup Fcn contains code to clear all.
The code I use to start the camera (from a previous search):
vHeight = 1200;
vWidth = 1600;
% Image acquisition
app.camObj = videoinput('gentl', 1,'BayerRG8');
% Create blank image
app.hImage = image(app.UIPreview,zeros(vHeight,vWidth,3));
pause(2);
% Aspect ratio
app.UIPreview.XLim = [0,vWidth];
app.UIPreview.YLim = [0,vHeight];
app.UIPreview.XTick = [];
app.UIPreview.YTick = [];
pbaspect(app.UIPreview,[vWidth,vHeight,1]);
% Preview the image
preview(app.camObj,app.hImage);
'gentl' and 'BayerRG8' per se is correct, I checked.
The error message I am getting:
Thank you in advance.
  3 个评论
Jessica Winkler
Jessica Winkler 2022-8-27
It just closes the app and shows "Error using videoinput: There are no devices installed for the specified
ADAPTORNAME. See IMAQHWINFO."

请先登录,再进行评论。

回答(1 个)

Swaraj
Swaraj 2024-1-17
Hi Jessica,
The error message indicates that "ROIPosition" is not set for the videoinput object. You can try the below code and check if it works fine for the cases where this error is getting thrown.
app.camObj = videoinput('gentl', 1,'BayerRG8');
app.camObj.ROIPosition = [10,10,500,500];
You can find more information in the below documentation.
Hope it helps!!

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for IP Cameras 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by