Borrar filtros
Borrar filtros

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

14 visualizaciones (últimos 30 días)
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 comentarios
Walter Roberson
Walter Roberson el 25 de Ag. de 2022
app.camObj = videoinput('gentl', 1,'BayerRG8');
What happens if the camera is already in use or disconnected?
Jessica Winkler
Jessica Winkler el 27 de Ag. de 2022
It just closes the app and shows "Error using videoinput: There are no devices installed for the specified
ADAPTORNAME. See IMAQHWINFO."

Iniciar sesión para comentar.

Respuestas (1)

Swaraj
Swaraj el 17 de En. de 2024
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!!

Categorías

Más información sobre MATLAB Support Package for IP Cameras en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by