From: Gil on

How can I sent variable (database) to function display_frame.m from GUI.

I call the function like this.

set(handles.vidobj,'FramesAcquiredFcn', {'display_frame'});

I tray to path a handles or global variable and it doesn't work.

HELP ME PLEASE.


############################################
I added my code
############################################
function varargout = start_stop_cam_gui(varargin)
% START_STOP_CAM_GUI M-file for start_stop_cam_gui.fig
% START_STOP_CAM_GUI, by itself, creates a new START_STOP_CAM_GUI or raises the existing
% singleton*.
%
% H = START_STOP_CAM_GUI returns the handle to a new START_STOP_CAM_GUI or the handle to
% the existing singleton*.
%
% START_STOP_CAM_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in START_STOP_CAM_GUI.M with the given input arguments.
%
% START_STOP_CAM_GUI('Property','Value',...) creates a new START_STOP_CAM_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before start_stop_cam_gui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to start_stop_cam_gui_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 start_stop_cam_gui

% Last Modified by GUIDE v2.5 09-May-2010 19:43:28

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @start_stop_cam_gui_OpeningFcn, ...
'gui_OutputFcn', @start_stop_cam_gui_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 start_stop_cam_gui is made visible.
function start_stop_cam_gui_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 start_stop_cam_gui (see VARARGIN)
handles.vidobj = videoinput('winvideo', 1);
srcObj3 = get(handles.vidobj, 'Source');
set(srcObj3(1), 'FrameRate', '5.0000');
set(handles.vidobj, 'ReturnedColorSpace', 'grayscale')
%Configure property values — This example sets the FramesPerTrigger value to 30 and the TriggerRepeat property to 4. The example also specifies as the value of the FramesAcquiredFcn callback the event callback function display_frame, created in Example: Writing a Callback Function. The object will execute the FramesAcquiredFcn every five frames, as specified by the value of the FramesAcquiredFcnCount property.
set(handles.vidobj,'FramesPerTrigger', 1);
set(handles.vidobj,'TriggerRepeat', inf);
set(handles.vidobj,'FramesAcquiredFcnCount', 5);
vid.FrameGrabInterval = 5;
set(handles.vidobj,'FramesAcquiredFcn', {'display_frame'});
% Choose default command line output for start_stop_cam_gui
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes start_stop_cam_gui wait for user response (see UIRESUME)

% --- Outputs from this function are returned to the command line.
function varargout = start_stop_cam_gui_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;
uiwait(handles.figure1);



% --- Executes on button press in start_stop_cam.
function start_stop_cam_Callback(hObject, eventdata, handles)
% hObject handle to start_stop_cam (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(handles.start_stop_cam,'String'),'Start Camera')
% Camera is off. Change button string and start camera.
set(handles.start_stop_cam,'String','Stop Camera')
start(handles.vidobj)
guidata(hObject, handles);

else
% Camera is on. Stop camera and change button string.
set(handles.start_stop_cam,'String','Start Camera')
stop(handles.vidobj)
guidata(hObject, handles);
end



############################################
display_frame
############################################


function display_frame(obj,event,handles)

sample_frame = peekdata(obj,1);
imshow(sample_frame )



drawnow; % force an update of the figure window

abstime = event.Data.AbsTime;

t = fix(abstime);

sprintf('%s %d:%d:%d','timestamp', t(4),t(5),t(6))

#################################################