www.pudn.com > database.zip > ppdb.m, change:2012-11-07,size:5187b


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

% Last Modified by GUIDE v2.5 07-Nov-2012 14:38:21

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ppdb_OpeningFcn, ...
                   'gui_OutputFcn',  @ppdb_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 ppdb is made visible.
function ppdb_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 ppdb (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = ppdb_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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

vid = videoinput('winvideo',2,'YUY2_640x480');
% only capture one frame per trigger, we are not recording a video
vid.FramesPerTrigger = 1;
% output would image in RGB color space
vid.ReturnedColorspace = 'rgb';
% tell matlab to start the webcam on user request, not automatically
triggerconfig(vid, 'manual');
% we need this to know the image height and width
vidRes = get(vid, 'VideoResolution');
% image width
imWidth = vidRes(1);
% image height
imHeight = vidRes(2);
% number of bands of our image (should be 3 because it's RGB)
nBands = get(vid, 'NumberOfBands');
% create an empty image container and show it on axPreview
hImage = image(zeros(imHeight, imWidth, nBands), 'parent', handles.axes1);
% begin the webcam preview
preview(vid, hImage);

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

vid = videoinput('winvideo',2, 'YUY2_640x480');
vid.FramesPerTrigger = 1;
vid.ReturnedColorspace = 'rgb';
triggerconfig(vid, 'manual');
vidRes = get(vid, 'VideoResolution');
imWidth = vidRes(1);
imHeight = vidRes(2);
nBands = get(vid, 'NumberOfBands');
hImage = image(zeros(imHeight, imWidth, nBands), 'parent', handles.axes1);
preview(vid, hImage);

tic
for i=1:6
% prepare for capturing the image preview
start(vid); 
% pause for 2 seconds to give our webcam a "warm-up" time
pause(1); 
% do capture!
trigger(vid);
% stop the preview
stoppreview(vid);
% get the captured image data and save it on capt1 variable
capt1 = getdata(vid);
i=num2str(i);
filename = ['./',i,'.bmp'];
% now write capt1 into file
imwrite(capt1,filename);
end
one=imread('1.bmp');
imagesc(one,'Parent',handles.axes2);
two=imread('2.bmp');
imagesc(two,'Parent',handles.axes3);
three=imread('3.bmp');
imagesc(three,'Parent',handles.axes4);
one=imread('4.bmp');
imagesc(one,'Parent',handles.axes5);
two=imread('5.bmp');
imagesc(two,'Parent',handles.axes6);
three=imread('6.bmp');
imagesc(three,'Parent',handles.axes7);

% just dialog that we are done capturing
warndlg('Done!');
toc