Professional Documents
Culture Documents
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
===================================================
xyloObj = mmreader('xylophone.mpg');
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
%// Preallocate movie structure.
mov(1:nFrames) = struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),
...
'colormap', []);
%// Read one frame at a time.
for k = 1 : nFrames
mov(k).cdata = read(xyloObj, k);
end
%// Size a figure based on the video's width and height.
hf = figure;
set(hf, 'position', [150 150 vidWidth vidHeight])
%// Play back the movie once at the video's frame rate.
movie(hf, mov, 1, xyloObj.FrameRate);
==================================================
mmreader('C:\Users\Public\Videos\Sample Videos\Wildlife.wmv')
==========================================================
filename = 'god.avi';%video file encoded with DivX 5.0
avi_obj=mmreader(filename);
no_frame=get(avi_obj,'NumberOfFrames');
figure
for i=1:no_frame
img=read(avi_obj,i);
imshow(img),title(sprintf('Frame %d',i));
drawnow; pause(0.5);
end
==================================================
================================
filename = 'seq3.avi';
avi_obj=aviread(filename);
no_frame=size(avi_obj,2);
figure
for i=721:no_frame
img=avi_obj(i).cdata;
imshow(img),title(sprintf('Frame %d',i));
drawnow; pause(0.5);
end
==================================================
==================================
function [ frame ] = readFrames( vid )
readerobj = mmreader(vid);
vidFrames = read(readerobj);
numFrames = get(readerobj, numberOfFrames);
for k = 1 : numFrames
mov(k).cdata = vidFrames(:,:,:,k);
mov(k).colormap = [];
%imshow(mov(k).cdata);
imagename=strcat(int2str(k), .jpeg);
imwrite(mov(k).cdata, strcat(vasanth,imagename));
%extractComponents(mov(k).cdata);
end
Matlab is to be utilized for data extraction,data analysis and data processing,it is further
utilized for some statistical task to analyze the behavior of the system by plotting.it is
used to generate stimulus for verification of the system
MATLAB is a commercial software package written by The MathWorks, Inc. Quoting from
their web page: "Numeric computation,
technical graphics and visualization, and an intuitive programming language for
applications in engineering and science."
MATLAB is a complete environment for high-level programming, as well as interactive
data analysis. MATLAB excels at numerical
computations, especially when dealing with vectors or matrices of data. Symbolic math is
available through an add-on toolbox
that uses a Maple kernel.
processing hardware is the first requirement for the conversion. Software then
analyzes the content's color and motion and even uses edges to define objects in
the picture. It can decide what parts of the image are in the background by
noticing how objects occlude, or cover, each other in the picture. In fact, the more
motion there is in a picture the easier it is for the software to determine what
objects on screen are in the foreground and which are in the background. The
more color or contrast difference there is between the foreground and the
background also helps the software to determine the depth of objects in the
picture.
After analyzing all of the above
information the software creates a
depth map of the picture and from
that creates two versions of the
frame with the 3D information
embedded into them, perspectives
of objects are slightly tweaked to
give the appearance that each eye is seeing the object from different angles
which creates the 3D effect. What is really amazing is that in the time it took you
read to this point a 3D TV would have completed this process about 1800 times
and rendered 3600 frames of 3D content.
required, based on what I have seen thus far. So I have to ask, what's the point
of having a subdued 3D effect? This is certainly not a feature upon which I will
critically evaluate which 3D TV to
purchase.
What 3D TVs
Have It?
Samsung currently has this
capability in all sizes of the C8000
and C7000 series plasmas and the
C9000, C8000 and C7000 series LED TVs. The C750 series of LCD televisions
also has 2D to 3D conversion. For 2011 the D9500, D7900, D8000, D7000 and
D6400 lines of LED TVs will have it as will the D8000 and D6500 plasmas. See
Samsung 3D TVs
Current Sony models featuring this technology are the LX900 and HX909 LED
backlit LCD TVs. In 2011 the HX929 and HX820 will feature this technology. See
Sony 3D TVs
LG, Toshiba, Panasonic and others will be featuring 2D to 3D converison on 2011
models but do not have it in any available models at press time.
[video, audio] = mmread(filename, frames, time, disableVideo, disableAudio, matlabCommand, trySeeking, useFFGRAB)
mmread reads virtually any media file. It now uses AVbin and FFmpeg to capture the data, this includes URLs. The code supports all major OSs and arc
Matlab runs on.
INPUT
filename input file to read (mpg, avi, wmv, asf, wav, mp3, gif, ...) frames specifies which video frames to capture, default [] for all or to specify time
time [startTime stopTime], default [] for all disableVideo disables ALL video capturing, to save memory or time disableAudio disables ALL audio capturing
or time
matlabCommand Do not return the video structure, but call the function specified by matlabCommand. The function definition must match that of proces
processFrame.m for more information.
trySeeking [true] setting this to false makes the code slower but more precise. If the first several frames are distorted or timing information isn't accurate
useFFGRAB [true] Use the new version of mmread, which uses ffmpeg. However, if an audio or video stream can't be read AND you are running Windo
false (old version).
OUTPUT
nrFramesTotal the total number of frames in the movie regardless of how many were captured. Unfortunately, this can not always be determined. If it is
an estimate based upon the duration and rate (normally accurate to within .1%). It can be 0, in which case it could not be determined at all. If it is a poss
should always be accurate.
totalDuration the total length of the video in seconds.
frames a struct array with the following fields:
cdata [height X width X 3] uint8 matricies
colormap always empty
times the corresponding time stamps for the frames (in msec)
skippedFrames some codecs (not mmread) will skip duplicate frames (i.e. identical to the previous) in fixed frame rate movies to save space and time.
frames can be detected by looking for jumps in the "times" field. This field will be true when frames are skipped.
audio is a struct with the following fields:
nrChannels the number of channels in the audio stream (1 or 2)
rate sampling rate of the audio, ex. 44100. If it can't be determined then it will be 1.
bits bit depth of the samples (8 or 16)
data the real data of the whole audio stream. This can be played using wavplay. If time ranges are specified, the length of the data may not correspond
This normally happens with movies. The issue is that the start of the audio stream is generally counted at the END of the first frame. So, time is shifted b
nrFramesTotal Audio comes in packets or frames when captured, the division of the audio into frames may or may not make sense.
totalDuration the total length of the audio in seconds.
frames cell array of uint8s. Probably not of great use.
times the corresponding time stamps for the frames (in milliseconds)
If there is no video or audio stream the corresponding structure will be empty.
Specifying frames does not effect audio capturing. If you want only a subsection of the audio use the 3rd parameter "time". Specifying time effects both a
Time is specified in seconds (subsecond resolution is supported with fractional numbers ex. 1.125), starting at 0. Time is defined as startTime (inclusive)
(exclusive), or using set notation [startTime stopTime).
If there are multiple video or audio streams, then the structure will be of length > 1. For example: audio(1).data and audio(2).data.
EXAMPLES
[video, audio] = mmread('chimes.wav'); % read whole wav file
wavplay(audio.data,audio.rate);
video = mmread('mymovie.mpg'); % read whole movie
movie(video.frames);
video = mmread('mymovie.mpg',1:10); %get only the first 10 frames
video = mmread('mymovie.mpg',[],[0 3.5]); %read the first 3.5 seconds of the video
[video, audio] = mmread('chimes.wav',[],[0 0.25]); %read the first 0.25 seconds of the wav
[video, audio] = mmread('chimes.wav',[],[0.25 0.5]); %read 0.25 to 0.5 seconds of the wav, there is no overlap with the previous example.
read a movie directly from a URL
video = mmread('http://www.nature.com/neuro/journal/v9/n4/extref/nn1660-S8.avi');
Acknowledgements