フィルターのクリア

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 Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by