Info
This question is closed. Reopen it to edit or answer.
Error while evaluating uicontrol Callback
2 views (last 30 days)
Show older comments
Hi, i got this error when try to run the program. Can anyone explain what is wrong?
Reference to non-existent field 'txtInfo'.
Error in realtime21>btnPreviewVideo_Callback (line 100) set(handles.txtInfo, 'string', errorMessage);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in realtime21 (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)realtime21('btnPreviewVideo_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Below is the coding for my gui
if true
% --- Executes on button press in btnPreviewVideo.
function btnPreviewVideo_Callback(hObject, eventdata, handles)
% hObject handle to btnPreviewVideo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Initialize the video camera.
global vidobj; % Video camera object.
try
% Initialize Logitech webcam
vidobj = videoinput('winvideo', 1, 'YUY2_320x240');
if ~isempty(vidobj)
src = getselectedsource(vidobj);
vidobj.FramesPerTrigger = 1;
axes(handles.axesImage);
hImage = findobj(handles.axesImage, 'Type', 'image');
preview(vidobj, hImage);
% src.ZoomMode = 'manual';
% Turn on the live video preview. Display the bounding box over it if there is one selected.
TurnOnLiveVideo(handles);
end
% Turn on the live video preview. Display the bounding box over it if there is one selected.
TurnOnLiveVideo(handles);
catch ME
errorMessage = sprintf('Error in function logitech_webcam_OpeningFcn.\nNo Logitech webcam detected!\n\nError Message:\n%s', ME.message);
set(handles.txtInfo, 'string', errorMessage);
uiwait(warndlg(errorMessage));
end
if true
function TurnOnLiveVideo(handles)
global vidobj; % Video camera object.
% Bail out if there is no video object class instantiated.
if isempty(vidobj), return, end;
% Switch the current graphic axes to handles.axesImage.
% This is where we want the video to go.
axes(handles.axesImage);
% Reset image magnification. Required if you ever displayed an image
% in the axes that was not the same size as your webcam image.
hold off;
axis auto;
% Get the handle to the image in the axes.
hImage = findobj(handles.axesImage, 'Type', 'image');
% Turn on the live video.
preview(vidobj, hImage);
% Put hold on so that displaying our bounding box doesn't blow away the image.
hold on;
% Retrieve our x,y coordinates of the bounding box corners.
GetImageMask(handles);
% They have been previously set elsewhere as global variables.
global maskVerticesXCoordinates;
global maskVerticesYCoordinates;
if ~(isempty(maskVerticesXCoordinates) || isempty(maskVerticesYCoordinates))
% If the bounding box coordinates exist,
% plot the bounding box over the live video.
plot(maskVerticesXCoordinates, maskVerticesYCoordinates);
end
% stoppreview(vidobj);
return; % from TurnOnLiveVideo
end
Thanks
0 Comments
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!