____________________________________________________________________ Department of Electronics and Communication, SMIT. 1 MAJOR PROJECT REPORT ON REAL -TIME MULTIMEDIA SIGNAL PROCESSING USING MATLAB Submitted by: Angshuman Ghosh - (Reg.no. - 200212080) Aritri Debnath - (Reg.no. – 200212113) In partial fulfillment of VIII Semester, B.Tech (Electronics and communication Engineering) Under the Guidance of: Prof. Rabindranath Bera (Electronics and Communication Dept., SMIT) Dr. Jitendranath Bera and Dr. Madhuchhanda Mitra (Dept. of Applied Physics, University of Calcutta) ELECTRONICS AND COMMUNICATION ENGINEERING DEPARTMENT, JUNE 2006. SIKKIM MANIPAL INSTITUTE OF TECHNOLOGY MAJITAR, RANGPO, EAST SIKKIM-737132
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
____________________________________________________________________Department of Electronics and Communication, SMIT.
1
MAJOR PROJECT REPORT ON REAL -TIME MULTIMEDIA SIGNAL
VIII Semester, B.Tech (Electronics and communication Engineering)
Under the Guidance of:
Prof. Rabindranath Bera (Electronics and Communication Dept., SMIT)
Dr. Jitendranath Bera and Dr. Madhuchhanda Mitra (Dept. of Applied Physics, University of Calcutta)
ELECTRONICS AND COMMUNICATION ENGINEERING DEPARTMENT, JUNE 2006.
SIKKIM MANIPAL INSTITUTE OF TECHNOLOGY MAJITAR, RANGPO, EAST SIKKIM-737132
____________________________________________________________________Department of Electronics and Communication, SMIT.
2
SIKKIM MANIPAL INSTITUTE OF TECHNOLOGY (A constituent college of Sikkim Manipal University of Health Medical and
Technological Sciences)
CERTIFICATE
This is to certify that ANGSHUMAN GHOSH bearing the registration no:-
200212080 has successfully completed the major project titled ‘REAL-TIME
MULTIMEDIA SIGNAL PROCESSING USING MATLAB’ at Department of
Applied Physics, University of Calcutta, in partial fulfillment of the requirement for the
award of Bachelor Of Technology in Electronics and Communication Engineering of
SIKKIM MANIPAL UNIVERSITY OF HEALTH MEDICAL AND
TECHNOLOGICAL SCIENCES in the year 2005-06.
___________________________ Dr. R. N. Bera (Internal Guide) Head of Department, Department of Electronics and Communication Engineering, S.M.I.T, Majitar, Rangpo, Sikkim- 737132
DEPARTMENTAL SEAL
DEPARTMENT OF ELECTRONICS AND COMMUNICATION.
____________________________________________________________________Department of Electronics and Communication, SMIT.
5
ABSTRACT
The aim of our major project is Real-Time Multimedia Signal Processing Using
MATLAB using a comparatively cheaper card in contrast to expensive cards like TI
DM642EVM. The project on completion will process the multi-media files like the video
and audio from the TV as well as from the digital camera and these can be viewed on the
computer. For this objective we have the following two Real-time approaches:
• Tuner mode: - that is processing the data’s from the TV.
• Composite mode: - that is processing the data’s from the digital camera.
These two approaches works in two different video modes: the tuner mode and the
composite mode. The online approach where the data are acquired from the TV works in
the tuner video mode.
While the offline approach where the data’s are acquired from a digital camera works in
the composite video mode. These two modes can be turned on and off by the program we
have developed in MATLAB.
For acquiring data’s from the TV & Camera we have chosen a TV tuner card, which is
the PIXEL VIEW TV Tuner card having the model no. TCL2002MB-33F. The reason for
choosing the TV Tuner card as the video card is that the TV Tuner card has a wide
bandwidth of 815MHz. And the digital camera we have chosen is OLYMPUS
CAMEDIA C- 750.
We have used MATLAB 7.1 for the simulation purpose, as it is a high-speed computation
program, which performs various kinds of operations in much less time.
____________________________________________________________________Department of Electronics and Communication, SMIT.
6
TABLE OF CONTENTS
TOPIC PAGE NO.
CHAPTER 1: LIST INSERTED………………………………………..9.
1.1 List of Tables………………………………………………..10.
1.2 List of Figures……………………………………………….11.
CHAPTER 2: INTRODUCTION………………………………………13.
2.1 Why we are interested in this project .........................................14.
2.2 Mobile TV?……………………………………...……………..14.
2.1.1. What is a Mobile TV ……….…..……………………..14.
2.1.2. Mobile TV Theory……………..………………………14.
2.1.3 Companies Engaged……………………………………15.
2.1.4 Merits……………………….…………………………17.
CHAPTER 3: MATLAB…………………….………………………….18.
3.1 Why We Are Using MATLAB?...............................................19.
3.2 What is MATLAB?………...........................................………19.
3.2.1 MATLAB Uses……………………………………………21.
3.2.2 MATLAB Syntax………………………………………….21.
3.2.3 The MATLAB Systems……………………………………21.
3.2.4 Functions……………………………………………...22
3.2.5 .Desktop Overview……………………………………23.
3.2.6 Start Button……………………………………………23.
3.2.7 Command Window……………………………………24.
3.2.8 Command History……………………………………..24.
3.2.9 Demos…………………………………………………25.
3.2 M-file…………………………………………………….….25.
3.3.1 What is a M-file?…………………………………………...25.
3.3.2 Why use M-file?……………………………………………25.
____________________________________________________________________Department of Electronics and Communication, SMIT.
7
3.3.3 How to Create, Save and Open a M-file?…………………..26.
3.3.4 How to Run a M-file?………………………………………26.
CHAPTER 4: SIMULINK……………………………………………………27.
4.1 What is SIMULINK?……………………………………………………..28.
4.1.1 Tool For Simulation…………………………………………………….28.
4.1.2 Tool For Model Based Designs…………………………………………29.
4.1.3 Creating Empty Model………………………………………………….29.
4.1.4 Adding The Blocks……………………………………………………...31.
4.1.5 Configuring The Model…………………………………………………33.
4.1.6 Running The Model……………………………………………………..33.
4.2 How Does Simulink Works?……………………………………………...34.
Here we make a video object i.e. “vidobj” and then access the properties of the video
object i.e. colors, brightness, hue, etc and also the properties of the video source. Not
only we access them but also we can modify them. By default the source selects the
composite mode, out of the three possible modes, which are:
1. S-Video mode.
2. Tuber mode.
____________________________________________________________________Department of Electronics and Communication, SMIT.
51
3. Composite mode.
Now in the line “set(vidobj,’selectedsourcename’,’tuner’)” we select the tuner source so
the problem is solved i.e. if we keep this line we can access TV and if we omit this line
we can access camera. This program also had some problems, which are:
1. Though it cost a lot of time and effort it seems too simple.
2. It is not user friendly.
3. A puzzle to a lay man.
So, ultimately we switched over to GUIDE tool of MATLAB to build a user friendly and
sophisticated looking GUI.
We faced a lot of problems in there to. Though the basic image acquisition concept
remains the same, the basic m-file writing format and syntax changes drastically from
command window m-file to Simulink model to a GUI. But finally with lots of efforts we
developed a program for building a GUI.
7.2 - PROGRAMME FOR BUILDING GUI
function varargout = cameracompositeandtvtuner(varargin) % cameracompositeandtvtuner - launch a GUI to control image acquisition session: % The GUI helps in: % craeting the video object, % previewing and snap shotting, % controlling frame grabber parameters, % The video object constructor is: videoinput('winvideo', 1, format) - % session begins with pressing the 'VideoInput' pushbutton to create the video object. % % The application sends its messages to the MATLAB environment. % user should keep the MATLAB environment visible. % % Quick start: % 1. Press VideoInput (wait untill the label changes to: 'Delete VideoInput'). % 2. Press Preview (user should see the video stream from the camera or tv % the label changes to: 'Close Preview'). % 3. Press FramesAcquired (=0), FramesAvailable (=0), IsRunning (No), IsLogging (No) -
____________________________________________________________________Department of Electronics and Communication, SMIT.
52
% all answers appear in the Matlab environment. % 4. Press START (the acquisition begins with default parameters: FramesPerTrigger=10 etc...). % 5. Press FramesAcquired (=10), FramesAvailable(=10). % 6. Press GetData (to get the acquired data from the video object). % 7. Press Save ( a dialog box appears suggesting a file-name composed from the Test name and % the time yyyymmdd_HHMMSS). % 8. Press ImageDisplay (it should load another independent GUI to view what user created in VideoControl). % % Image Acquisition: % Editing the fields: FrameGrabInterval (take a frame every X frames), % FramesPerTrigger, TriggerRepeat (the system expects 1+TriggerRepeat triggers after START), % TriggerFrameDelay (number of frames to skip after trigger). % Note: When video object is created it always has the defaults values, % regardless of what is written in the edit fields. % Video Source: % From this pannel user can control Brightness, Contrast and % resolution . % Function: % START - make the video object running (ready for logging upon % trigger) % Trigger - useful at manual trigger only, begins logging. % STOP - stop the video object from running. % GetData - brings acquired data from video object to the MATLAB % environment. user can not save data unless he pressed it before! % Save - save the acquired data to a file. user can change the % suggested file name as user like. % ImageDisplay - launch an independent GUI to display images of the % unique structure preduced by CAMERACOMPOSITEANDTVTUNER. % Trigger: % Immediate - begin logging immediately after user press's START. % Manual - begin logging after user press's TRIGGER. % % Logging: % LoggingMode - 'memory' (producing data structure that will be saved by SAVE), % 'disk&memory' (creating also an avi file) or 'disk'. % % MENU: % On the menu bar user has 'Trigger' and 'Info' to display the status % of the video object, video source and trigger info. If user's window % is docked into the MATLAB window, the menus will join the MATLAB % menu bar on top of the window. % gui_Singleton = 1;
____________________________________________________________________Department of Electronics and Communication, SMIT.
53
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @cameracompositeandtvtuner_OpeningFcn, ... 'gui_OutputFcn', @cameracompositeandtvtuner_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 cameracompositeandtvtuner is made visible. function cameracompositeandtvtuner_OpeningFcn(hObject, eventdata, handles, varargin) %avidobj = videoinput('winvideo') %sources = avidobj.source %whos sources %set(avidobj,'selectedsourcename','tuner') %sources = avidobj.source % 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 cameracompositeandtvtuner (see VARARGIN) % Choose default command line output for cameracompositeandtvtuner handles.output = hObject; % my global definitions: handles.data = []; handles.aviobj =[]; imaqreset % Update handles structure guidata(hObject, handles); % UIWAIT makes cameracompositeandtvtuner wait for user response (see
UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = cameracompositeandtvtuner_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; % --------------------------------------------------------------------
____________________________________________________________________Department of Electronics and Communication, SMIT.
54
function miFramesPerTrigger_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; fpt = num2str(get(handles.vid, 'FramesPerTrigger')); disp([' Frames per trigger: ', fpt]); return % -------------------------------------------------------------------- function miTriggerType_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; t = get(handles.vid, 'TriggerType'); disp([' Trigger type: ', t]); return % -------------------------------------------------------------------- function miTriggerCondition_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; tc = get(handles.vid, 'TriggerCondition'); disp([' Trigger condition: ', tc]); return % -------------------------------------------------------------------- function miTriggerSource_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; ts = get(handles.vid, 'TriggerSource'); disp([' Trigger source: ', ts]); return % -------------------------------------------------------------------- function menuTrigger_Callback(hObject, eventdata, handles) % --- Executes on button press in pbVideoInput. function pbVideoInput_Callback(hObject, eventdata, handles) if get(hObject, 'userdata') == 0, % video is closed imaqreset; handles.vid = videoinput('winvideo'); set((handles.vid),'selectedsourcename','tuner'); handles.source = getselectedsource(handles.vid); set(hObject, 'string', 'Delete VideoInput'); set(hObject, 'userdata', 1); guidata(hObject, handles); return else delete(handles.vid); clear handles.vid; set(hObject, 'string', 'VideoInput'); set(hObject, 'userdata', 0); set(handles.pbPreview, 'userdata', 0, 'string', 'Preview'); %set(handles.pbCreateSource, 'userdata', 0, 'string', 'CreateSource'); guidata(hObject, handles); return end % --- Executes on button press in pbPreview. function pbPreview_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; if get(hObject, 'userdata') == 0, %preview is OFF
____________________________________________________________________Department of Electronics and Communication, SMIT.
55
preview(handles.vid); set(hObject, 'string', 'ClosePreview'); set(hObject, 'userdata', 1.0); guidata(hObject, handles); return else closepreview(handles.vid); set(hObject, 'string', 'Preview'); set(hObject, 'userdata', 0.0); guidata(hObject, handles); return end % --- Executes during object creation, after setting all properties. function figure1_CreateFcn(hObject, eventdata, handles) handles.vid = []; handles.source = []; guidata(hObject, handles); return % --- Executes on slider movement. function slBrightness_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; b = round(get(hObject, 'value')); set(handles.source, 'Brightness', b); set(handles.edBrightness, 'string', num2str(b)); return % --- Executes during object creation, after setting all properties. function slBrightness_CreateFcn(hObject, eventdata, handles) usewhitebg = 1; if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);
else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes upon editing. function edBrightness_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; b = round(str2num(get(hObject, 'string'))); set(handles.slBrightness, 'value', b); set(handles.src, 'Brightness', b); return % --- Executes during object creation, after setting all properties. function edBrightness_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else
____________________________________________________________________Department of Electronics and Communication, SMIT.
56
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % -------------------------------------------------------------------- function miGetSelectedSource_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; get(handles.source) return % -------------------------------------------------------------------- function menuInfo_Callback(hObject, eventdata, handles) function edContrast_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; c = round(str2num(get(hObject, 'string'))); set(handles.slContrast, 'value', c); set(handles.src, 'Contrast', c); return % --- Executes during object creation, after setting all properties. function edContrast_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on slider movement. function slContrast_Callback(hObject, eventdata, handles) % hObject handle to slContrast (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider if get(handles.pbVideoInput, 'userdata') == 0, return, end; c = round(get(hObject, 'value')); set(handles.source, 'Contrast', c); set(handles.edContrast, 'string', num2str(c)); return % --- Executes during object creation, after setting all properties. function slContrast_CreateFcn(hObject, eventdata, handles) usewhitebg = 1; if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]); else
____________________________________________________________________Department of Electronics and Communication, SMIT.
57
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in ppTriggerConfig. function ppTriggerConfig_Callback(hObject, eventdata, handles) % hObject handle to ppTriggerConfig (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns ppTriggerConfig contents as cell array % contents{get(hObject,'Value')} returns selected item from ppTriggerConfig if get(handles.pbVideoInput, 'userdata') == 0, return, end; selection = get(hObject, 'value'); config = triggerinfo(handles.vid); triggerconfig(handles.vid, config(selection)); % --- Executes during object creation, after setting all properties. function ppTriggerConfig_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pbFramesAcquired. function pbFramesAcquired_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; frames = get(handles.vid, 'FramesAcquired'); s = sprintf('%s%g\n', 'Frames acquired: ', frames); disp(s); % -------------------------------------------------------------------- function miGetVideoInput_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; get(handles.vid) return function edFrameGrabInterval_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; set(handles.vid, 'FrameGrabInterval', str2num(get(hObject, 'string'))); guidata(hObject, handles); return % --- Executes during object creation, after setting all properties. function edFrameGrabInterval_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else
____________________________________________________________________Department of Electronics and Communication, SMIT.
58
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function edFramesPerTrigger_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; set(handles.vid, 'FramesPerTrigger', str2num(get(hObject, 'string'))); guidata(hObject, handles); return % --- Executes during object creation, after setting all properties. function edFramesPerTrigger_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function edTriggerRepeat_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; set(handles.vid, 'TriggerRepeat', str2num(get(hObject, 'string'))); guidata(hObject, handles); return % --- Executes during object creation, after setting all properties. function edTriggerRepeat_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pbDefaultsAcquisition. function pbDefaultsAcquisition_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; set(handles.edFrameGrabInterval, 'string', '1'); set(handles.vid, 'FrameGrabInterval', 1); set(handles.edFramesPerTrigger, 'string', '10'); set(handles.vid, 'FramesPerTrigger', 10); set(handles.edTriggerRepeat, 'string', '0'); set(handles.vid, 'TriggerRepeat', 0); set(handles.edTriggerFrameDelay, 'string', '0'); set(handles.vid, 'TriggerFrameDelay', 0); guidata(hObject, handles); return function edTriggerFrameDelay_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; set(handles.vid, 'TriggerFrameDelay', str2num(get(hObject, 'string'))); guidata(hObject, handles); return
____________________________________________________________________Department of Electronics and Communication, SMIT.
59
% --- Executes during object creation, after setting all properties. function edTriggerFrameDelay_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pbSnapshot. function pbGetSnapshot_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; % video object absent if get(hObject, 'userdata') == 0, set(hObject, 'userdata', 1.0); s = getsnapshot(handles.vid); figure(1); imshow(s); set(hObject, 'userdata', 0.0); guidata(hObject, handles); return else return end return % --- Executes on button press in pbFramesAvailable. function pbFramesAvailable_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; frames = get(handles.vid, 'FramesAvailable'); s = sprintf('%s%g\n', 'Frames available: ', frames); disp(s); return % --- Executes on button press in pbStart. function pbStart_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; if isrunning(handles.vid), return, end; start(handles.vid); return % --- Executes on button press in pbTrigger. function pbTrigger_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; if ~strcmp(get(handles.vid, 'TriggerType'), 'manual'), return, end; if ~isrunning(handles.vid), return, end; if islogging(handles.vid), return, end; trigger(handles.vid); return % --- Executes on button press in pbStop. function pbStop_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; if ~isrunning(handles.vid), return, end;
____________________________________________________________________Department of Electronics and Communication, SMIT.
60
stop(handles.vid); return % % --- Executes on button press in pbImaqMontage. % function pbImaqMontage_Callback(hObject, eventdata, handles) % if get(handles.pbVideoInput, 'userdata') == 0, return, end; % % figure(2);% TO DO:: use the correct data structure to display... % % imaqmontage(handles.data); % return % --- Executes on button press in pbFlushData. function pbFlushData_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; flushdata(handles.vid); return % --- Executes on button press in pbImageDisplay. function pbImageDisplay_Callback(hObject, eventdata, handles) ImageDisplay return
% --- Executes on button press in pbGetData. function pbGetData_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; if get(handles.vid, 'FramesAvailable') == 0, return, end; if get(handles.vid, 'TriggersExecuted') < 1, return, end; handles.data = []; T = get(handles.vid, 'TriggersExecuted'); for t=1:T, [handles.data{t}.frames, handles.data{t}.time, handles.data{t}.metadata] = getdata(handles.vid); end guidata(hObject, handles); return % --- Executes on button press in pbSave. function pbSave_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; if isempty(handles.data), return, end; tx = get(handles.edTransducerID, 'string'); d=handles.data; c = fix(clock); filename=sprintf('%s_%4d-%02d-%02d_%02d%02d%02d%s', tx, c(1), c(2), c(3), c(4), c(5), c(6), '.mat'); prompt={'Enter file name:'}; name='Save current data to a file'; numlines=1; defaultanswer= {filename}; filename2=''; filename2=inputdlg(prompt,name,numlines,defaultanswer); if isempty(filename2), return, end; save(filename2{1}, 'd'); return
____________________________________________________________________Department of Electronics and Communication, SMIT.
61
% --- Executes on editing. function edROIx_Callback(hObject, eventdata, handles) % if get(handles.pbVideoInput, 'userdata') == 0, return, end; % a = get(handles.vid, 'ROI'); % new = str2num(get(hObject, 'string')); % set(handles.vid, 'ROI', [new a(2) a(3) a(4)]); return; % --- Executes during object creation, after setting all properties. function edROIx_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on editing.
function edROIy_Callback(hObject, eventdata, handles) % if get(handles.pbVideoInput, 'userdata') == 0, return, end; % a = get(handles.vid, 'ROI'); % new = str2num(get(hObject, 'string')); % set(handles.vid, 'ROI', [a(1) new a(3) a(4)]); return; % --- Executes during object creation, after setting all properties. function edROIy_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on editing. function edROIwidth_Callback(hObject, eventdata, handles) % if get(handles.pbVideoInput, 'userdata') == 0, return, end; % a = get(handles.vid, 'ROI'); % new = str2num(get(hObject, 'string')); % set(handles.vid, 'ROI', [a(1) a(2) new a(4)]); return; % --- Executes during object creation, after setting all properties. function edROIwidth_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end
____________________________________________________________________Department of Electronics and Communication, SMIT.
62
% --- Executes on editing. function edROIheight_Callback(hObject, eventdata, handles) % --- Executes during object creation, after setting all properties. function edROIheight_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pbROIdefaults. function pbROIdefaults_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; a = get(handles.vid, 'videoresolution');
x = 0; y = 0; set(handles.vid, 'ROI', [x y a(1) a(2)]); set(handles.edROIx, 'string', num2str(x)); set(handles.edROIy, 'string', num2str(y)); set(handles.edROIwidth, 'string', num2str(a(1))); set(handles.edROIheight, 'string', num2str(a(2))); guidata(hObject, handles); return % --- Executes on button press in pbROIupdate. function pbROIupdate_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; a = zeros(1,4); a(1) = str2num(get(handles.edROIx, 'string')); a(2) = str2num(get(handles.edROIy, 'string')); a(3) = str2num(get(handles.edROIwidth, 'string')); a(4) = str2num(get(handles.edROIheight, 'string')); set(handles.vid, 'ROI', a); guidata(hObject, handles); return % --- Executes on editing. function edTransducerID_Callback(hObject, eventdata, handles) % --- Executes during object creation, after setting all properties. function edTransducerID_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pbIsRunning. function pbIsRunning_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; s = isrunning(handles.vid);
____________________________________________________________________Department of Electronics and Communication, SMIT.
63
switch s case 0 disp(' Video object is NOT running'); case 1 disp(' Video object is running'); end return % --- Executes on button press in pbIsLogging. function pbIsLogging_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; s = islogging(handles.vid); switch s case 0 disp(' Video object is NOT logging'); case 1 disp(' Video object is logging'); end return % --- Executes on selection change in ppLoggingMode. function ppLoggingMode_Callback(hObject, eventdata, handles) if get(handles.pbVideoInput, 'userdata') == 0, return, end; index = get(hObject, 'value'); str = get(hObject, 'string'); sLoggingMode = str{index}; set(handles.vid, 'LoggingMode', sLoggingMode); guidata(hObject, handles); return % --- Executes on creation. function ppLoggingMode_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on editing. function edFps_Callback(hObject, eventdata, handles) % --- Executes during object creation, after setting all properties. function edFps_CreateFcn(hObject, eventdata, handles) if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pushbutton25. function pushbutton25_Callback(hObject, eventdata, handles) close(gcf) % hObject handle to pushbutton25 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
____________________________________________________________________Department of Electronics and Communication, SMIT.
64
With the help of this program we have created a GUI for the video files from both the TV
and the camera. GUIDE tool used for creating GUI is set to composite mode by default.
By this program we change the composite mode to tuner mode.
Department of Electronics and Communication, SMIT
7.3 - AUDIO ACQUISITION BLOCK
Work space
MATLAB AUDIO
VIDEO
A/V
Fig – 7.3(a) Audio Acquisition Block
The audio input from a microphone is feed into the sound card, which is an analog to
digital converter. The output is a digitized audio. This digitized audio is then saved in
MATLAB workspace, where it is converted into audio wave. The sound card does not
access both the video and audio simultaneously. It accesses them separately with a
faction of time interval in between, which we cannot notice. So the video and audio are
merged together in a multiplexer, which together forms a transport stream, which in the
audio video output (A/V). This A/V then goes to the display device.
MIC Sound card
Software control
ADC Digitized
Audio
Audio Wave
MUX
T S
DEVICE
____________________________________________________________________Department of Electronics and Communication, SMIT.
65
7.4 - SIMULILNK MODEL FOR AUDIO ACQUISITION
Fig – 7.4(a):- Simulink Based Audio Acquisition Block
For audio acquisition we have designed the above model. The model consists of a audio
input block which takes audio inputs, a audio output block for producing audio output
and a “to web file” block which records and saves the audio data as a web file i.e. audio
file. The audio data taken from the audio input device goes to the audio output device
form where we can be heard and then to a “web file” block where it is recorded and saved
as a web file. The model can be modified by changing the parameters the blocks. The