필터 지우기
필터 지우기

How to read video file stored in structure?

조회 수: 1 (최근 30일)
amit pathania
amit pathania 2012년 2월 11일
편집: Matt J 2013년 10월 8일
I am trying to process a video file,i am able to read and store it in a structure.But i am not able to read values from structure to process and play it. My code is like this:
vid = Video Reader('sample.avi');
nframes= vid.NumberOfFrames;
vidHeight = vid.Height;
vidWidth = vid.Width;
halfframes=round(nframes/2);
mov(1:halfframes) = struct('cdata',zeros(vidHeight, vidWidth, 3, 'uint8'),'colormap', []);
%to read the frames and store it in structure
for k = 1:halfframes
mov(k).cdata = read(vid,( 2*k -1));
end
%till here its working fine
%if i try to read values by using a loop its not working
for k = 1:halfframes
frame= mov(k).cdata
imshow(frame);
end
this loop is not working and i am not getting all images/frames please help me with this

답변 (2개)

Walter Roberson
Walter Roberson 2012년 2월 11일
A) There have been some reports that VideoReader is skipping frames and repeating frames, with the incidence of that perhaps higher for variable frame-rate files.
B) put a drawnow() after the imshow().
C) If you have the image processing toolkit, you may wish to consider using implay rather than looping displaying the frames yourself.
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 2월 11일
Note by the way that NumberOfFrames is not meaningful for a variable-frame-rate video until after the video has been read to the last frame.
Side note: you do not need to initialize the zeros for mov(k).cdata. The read() you are doing will construct new storage and will use that storage, discarding any storage already allocated for mov(k).cdata . Might as well just initialize it to a single 0.
amit pathania
amit pathania 2012년 4월 12일
Hi,
I am just reading a video file and for faster processing want it to store in structure first.But,it's not showing it in a loop.I can view them individually but not in loop

댓글을 달려면 로그인하십시오.


amit pathania
amit pathania 2012년 2월 11일
thanks Walter, but i need to process these frames by carrying out few image processing operations and then display processed image in GUI axes. Can you suggest me the solution?
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 2월 11일
B) put a drawnow() after the imshow().

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by