how to set exposuretime in appdesigner with EditField?

8 views (last 30 days)
Hi,
I am trying to change the exposure time with an Edit Field, but I am problem accessing the camera properties wihin the app.
For example I define the camera properties as 'scr', then I set Camera Exposure and other properties when the camera starts.
% Code that executes after component creation
function startupFcn(app)
clc
delete(imaqfind);
% Create video object
imaqreset % resettar videoiput
app.VidObj = videoinput('gentl', 1, 'Mono12');
% camera properties
scr=getselectedsource(app.VidObj);
% setting the exposure time
scr.ExposureTimeAbs = 100000; % us 100 ms = 100'000 us
But then I want to add some kind of editable field (like EditField) where I can enter a number that will set the exposure time of the camera. Like, ..
function ExposureTimemsEditFieldValueChanged(app, event)
value = app.ExposureTimemsEditField.Value; % in ms
% 100 ms = 100'000us; 1 ms = 1000 us
% camera properties 'again'
scr=getselectedsource(app.VidObj);
scr.ExposureTimeAbs = value*1000; % anges i us
disp(['The exposure time was changed to ',num2str(value),' microseconds'])
However, the scr does not "exist" here as it is not a global property. I tried to add it as a global object, bu it didnt like the app.scr everywhere. So I call the scr again with getselectedsource function. Nothing seems to be happening though.
How can i change the exposure time "again" so it will change?
I have tried to change the exposuretime here with code above, but it seems to be nothing happening.

Accepted Answer

Hope Q
Hope Q on 28 Oct 2019
I suggest adding some diagnostic statements to assure that you have the desired source object and that is supports the ExposureTimeAbs property. I'm working on a simliar project that sets the FrameRate property.
You can also create an app property for the selected source that you don't have to keep calling getselectedsource().
For example:
app.videoCam = getselectedsource(obj.VidObj);
propertyList = set(obj.videoCame,'FrameRate'') % gives options for FrameRate

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!