필터 지우기
필터 지우기

How to display the webcam through the correct axes?

조회 수: 2 (최근 30일)
Muammar Khadafi
Muammar Khadafi 2017년 8월 21일
답변: Cam Salzberger 2017년 8월 21일
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?

답변 (1개)

Cam Salzberger
Cam Salzberger 2017년 8월 21일
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

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by