Filter löschen
Filter löschen

How to run webcam on an axis in app designer ?

4 Ansichten (letzte 30 Tage)
Ahmer Shahid
Ahmer Shahid am 1 Nov. 2018
Kommentiert: Ahmer Shahid am 4 Dez. 2018
function startcamerabutton_Callback(app, event)
% hObject handle to startcamerabutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
app.camera=videoinput('winvideo',1);
imshow(app.camera,'Parent',app.livedisplay);
end
  1 Kommentar
Ahmer Shahid
Ahmer Shahid am 1 Nov. 2018
This Error showing up there.......
Error using imageDisplayValidateParams Expected input number 1, I, to be one of these types:
numeric, logical
Instead its type was videoinput.
Error in images.internal.imageDisplayValidateParams (line 11) validateattributes(common_args.CData, {'numeric','logical'},...
Error in images.internal.imageDisplayParseInputs (line 78) common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 245) images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Astarag Chattopadhyay
Astarag Chattopadhyay am 20 Nov. 2018
Bearbeitet: Astarag Chattopadhyay am 23 Nov. 2018
Hi Ahmer,
You do not need to use "videoinput" object you can use "webcam" object.
In your app define two properties like this:
properties (Access = private)
webcamObject;
imageObject;
end
You can define the startup function using the following code snippet:
function startupFcn(app)
app.webcamObject = webcam;
app.imageObject = image(app.UIAxes);
axis(app.UIAxes,'ij')
res = split(app.webcamObject.Resolution,'x');
app.UIAxes.XLim = [0,str2double(res{1})];
app.UIAxes.YLim = [0,str2double(res{2})];
app.webcamObject.preview(app.imageObject);
end
This will setup the UIAxis with the resolution of the webcam object and start the preview.
  4 Kommentare
Astarag Chattopadhyay
Astarag Chattopadhyay am 4 Dez. 2018
Which version of MATLAB you are working on?
If you want to take a snapshot you can add a snapshot button to the app and add a callback to the button where you may use the function "snapshot".
Ahmer Shahid
Ahmer Shahid am 4 Dez. 2018
I'm using Matlab R2018a, I'm already working on that but when I use snapshot or getsnapshot then it give me error that snapshot is invalid function for webcam.
I can use snapshot function for videoinput but I cannot get the live streaming on axis while using videoinput.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by