Info
This question is closed. Reopen it to edit or answer.
Undeclared variable in script after assigning to worksapce
1 view (last 30 days)
Show older comments
function varargout = EyeDistance(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @EyeDistance_OpeningFcn, ...
'gui_OutputFcn', @EyeDistance_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
function EyeDistance_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.video = videoinput('macvideo','FaceTime HD Camera');
set(handles.video, 'ReturnedColorspace', 'RGB');
handles.hImage = image(zeros(720, 1280, 3), 'parent', handles.cameraAxes);
guidata(hObject, handles);
function varargout = EyeDistance_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in startCamera.
function startCamera_Callback(hObject, eventdata, handles)
preview(handles.video,handles.hImage);
% --- Executes on button press in captureImage.
function captureImage_Callback(hObject, eventdata, handles)
pause(1);
handles.I = getsnapshot(handles.video);
stop(handles.video);
imshow(handles.I, 'Parent', handles.cameraAxes);
assignin('base','I',handles.I);
% --- Executes on button press in cropFace.
function cropFace_Callback(hObject, eventdata, handles)
DetectFaceandEyes;
imshow(face, 'Parent', handles.cameraAxes);
NotYet = false;
%C = webcamlist;
%cam=webcam('macvideo','FaceTime HD Camera');
%preview(cam);
while ~NotYet
%tic;pause(0.10);toc;
%I = snapshot(cam);
faceDetect = vision.CascadeObjectDetector();
bbox=step(faceDetect,I);
if ~isempty(bbox)
NotYet = true;
break;
end
end
%closepreview;
%clear('cam');
face = imcrop(I,bbox);
Undefined function or variable 'I'.
Error in DetectFaceandEyes (line 9)
bbox=step(faceDetect,I);
Error in EyeDistance>cropFace_Callback (line 108)
DetectFaceandEyes;
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in EyeDistance (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)EyeDistance('cropFace_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
1 Comment
CS Researcher
on 8 May 2016
You need to pass I to DetectFaceandEyes function. The function does not know what I is.
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!