how to set exposuretime in appdesigner with EditField?

7 ビュー (過去 30 日間)
Happy PhD
Happy PhD 2019 年 10 月 17 日
回答済み: Hope Q 2019 年 10 月 28 日
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.

採用された回答

Hope Q
Hope Q 2019 年 10 月 28 日
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

その他の回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by