GUI with camera input error

1 view (last 30 days)
Hock Hock
Hock Hock on 1 Nov 2011
I just learn to use MATLAB to make GUI for camera input. I have got 1 sample for me to learn from in file exchange and i tried it out myself but it doesnt work.
I need to capture image using webcam with a click on the button for futher processing. however error message pop up when i click the button.
the error message are:
??? Error using ==> feval
Undefined function or method 'startstopcamera_Callback' for input arguments of type 'double'.
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> camera at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)camera('startstopcamera_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
and my code for gui are:
function varargout = camera(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @camera_OpeningFcn, ...
'gui_OutputFcn', @camera_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
function camera_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.video = videoinput('winvideo', 1);
set(handles.video,'TimerPeriod', 0.05, ...
'TimerFcn',['if(~isempty(gco)),'...
'handles=guidata(gcf);'...
'image(getsnapshot(handles.video));'...
'set(handles.cameraAxes,''ytick'',[],''xtick'',[]),'...
'else '...
'delete(imaqfind);'...
'end']);
triggerconfig(handles.video,'manual');
guidata(hObject, handles);
uiwait(handles.myCameraGUI);
function varargout = myCameraGUI_OutputFcn(hObject, eventdata, handles)
handles.output = hObject;
varargout{1} = handles.output;
function startStopCamera_Callback(hObject, eventdata, handles)
if strcmp(get(handles.startStopCamera,'String'),'Start Camera')
set(handles.startStopCamera,'String','Stop Camera')
start(handles.video)
else
set(handles.startStopCamera,'String','Start Camera')
stop(handles.video)
end
can any1 point out my problem?? and it will be better if you link more samples for me to learn. Thanks in advance.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Nov 2011
You have a function named startStopCamera_Callback but you are trying to call upon the function named startstopcamera_Callback . Notice the 's' vs 'S' and 'c' vs 'C' .
You will have to change the callback associated with some uicontrol or other whose code you do not show here. Probably it is part of a .fig file.
This sort of problem occurs regularly when people rename their GUIDE GUI. (Just one more of the reasons I don't use GUIDE...)
  1 Comment
Hock Hock
Hock Hock on 2 Nov 2011
oh..ok got it.. i will try other method to create GUI. thanks

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Support Package for USB Webcams in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!