How to run webcam on an axis in app designer ?

17 vues (au cours des 30 derniers jours)
Ahmer Shahid
Ahmer Shahid le 1 Nov 2018
Commenté : Ahmer Shahid le 4 Déc 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 commentaire
Ahmer Shahid
Ahmer Shahid le 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{:});

Connectez-vous pour commenter.

Réponse acceptée

Astarag Chattopadhyay
Astarag Chattopadhyay le 20 Nov 2018
Modifié(e) : Astarag Chattopadhyay le 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 commentaires
Astarag Chattopadhyay
Astarag Chattopadhyay le 4 Déc 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 le 4 Déc 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by