2015-05-02 3 views
0

Я попытался создать matlab gui, используя оси и кнопку включения, используя пример, который я получил из математического произведения. Однако он дает мне эти ошибки, которые я не могу исправить. Может ли кто-нибудь сказать мне, что произойдет?Ошибка при создании графического интерфейса с использованием примера математики

Ссылка на несуществующее поле 'txtInfo'.

Ошибка в реальном времени21> btnPreviewVideo_Callback (строка 100) set (handles.txtInfo, 'string', errorMessage);

Ошибка в gui_mainfcn (строка 96) feval (varargin {:});

Ошибка в реальном времени21 (строка 42) gui_mainfcn (gui_State, varargin {:});

Ошибка в @ (hObject, данныеСобытия) realtime21 ('btnPreviewVideo_Callback', hObject, данныеСобытия, guidata (hObject))

Ошибка при оценке UIControl CALLBACK

Кодекса

function varargout = realtime21(varargin) 
% REALTIME21 MATLAB code for realtime21.fig 
%  REALTIME21, by itself, creates a new REALTIME21 or raises the existing 
%  singleton*. 
% 
%  H = REALTIME21 returns the handle to a new REALTIME21 or the handle to 
%  the existing singleton*. 
% 
%  REALTIME21('CALLBACK',hObject,eventData,handles,...) calls the local 
%  function named CALLBACK in REALTIME21.M with the given input arguments. 
% 
%  REALTIME21('Property','Value',...) creates a new REALTIME21 or raises the 
%  existing singleton*. Starting from the left, property value pairs are 
%  applied to the GUI before realtime21_OpeningFcn gets called. An 
%  unrecognized property name or invalid value makes property application 
%  stop. All inputs are passed to realtime21_OpeningFcn via varargin. 
% 
%  *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 
%  instance to run (singleton)". 
% 
% See also: GUIDE, GUIDATA, GUIHANDLES 

% Edit the above text to modify the response to help realtime21 

% Last Modified by GUIDE v2.5 28-Apr-2015 11:02:05 

% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',  mfilename, ... 
       'gui_Singleton', gui_Singleton, ... 
       'gui_OpeningFcn', @realtime21_OpeningFcn, ... 
       'gui_OutputFcn', @realtime21_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 


% --- Executes just before realtime21 is made visible. 
function realtime21_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 realtime21 (see VARARGIN) 

% Choose default command line output for realtime21 
handles.output = hObject; 

% Update handles structure 
guidata(hObject, handles); 

% UIWAIT makes realtime21 wait for user response (see UIRESUME) 
% uiwait(handles.figure1); 


% --- Outputs from this function are returned to the command line. 
function varargout = realtime21_OutputFcn(hObject, eventdata, handles) 
% varargout cell array for returning output args (see VARARGOUT); 
    % hObject handle to figure 
% eventdata reserved - to be defined in a future version of MATLAB 
% handles structure with handles and user data (see GUIDATA) 

% Get default command line output from handles structure 
varargout{1} = handles.output; 


% --- 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 

%===================================================================== 
% Turn on the live video preview. Display the bounding box over it if there is one selected. 
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 
+0

Самая первая строка ошибки говорит вам проблему. Ссылка на несуществующее поле 'txtInfo'. – Augwa

+0

Так что я должен сделать, чтобы исправить эту ошибку? – chonglim

ответ

0

@Augwa правильный. Ссылка на код для несуществующего поля 'txtInfo'.

Вы когда-нибудь создавали 'txtInfo', но вы удалили его раньше?

Если так

Вы можете иметь проверку блога ниже, кто-то имеет такую ​​же проблему, как и вы.

Link =>http://strivingworksmartobserver.blogspot.tw/2015/05/matlab-gui-problems.html

Смежные вопросы