Borrar filtros
Borrar filtros

How to display the webcam through the correct axes?

2 visualizaciones (últimos 30 días)
Muammar Khadafi
Muammar Khadafi el 21 de Ag. de 2017
Respondida: Cam Salzberger el 21 de Ag. de 2017
I want to display the webcam via axes by using this code,
Function c11_OpeningFcn (hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% HObject handle to figure
% Eventdata reserved - to be defined in a future version of MATLAB
% Handles structure with handles and user data (see GUIDATA)
% Varargin command line arguments to c11 (see VARARGIN)
% Choose default command line output for c11
Handles.output = hObject;
Axes (handles.axes1);
Vid = webcam (1);
HImage = image (zeros (720,1280,3), 'Parent', handles.axes1);
Preview (vid, hImage);
%%Update handles structure
Guidata (hObject, handles);
But after I run it looks can not be closed. How to display the webcam through the correct axes?

Respuestas (1)

Cam Salzberger
Cam Salzberger el 21 de Ag. de 2017
Hello Muammar,
Capitalization matters in MATLAB. There is no variable "Handles", but there is "handles". Similarly, there is no function "Axes" or "Guidata", but there is "axes" and "guidata". You define "Vid" and "HImage", but then use "vid" and "hImage". So I'm surprised you weren't getting some more basic errors.
I don't think "image" allows for the 'Parent'-style axes specification. The documentation indicates that you should just have the axes as the first input argument:
hImage = image(handles.axes1, zeros(720,1280,3));
Hope that helps.
-Cam

Categorías

Más información sobre Images 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