Question

I am trying to read an AVI file into Matlab but am having a problem with the frames being sheared. I am using the Matlab code from Mathworks for VideoReader with only a few minor modifications.

xyloObj = VideoReader('video.avi');

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

imagesc(mov(1).cdata)
colormap gray

Below is a single frame from the video. Has anyone encountered this before? The video was produced by a PI Connect infrared camera. The video shows no shearing when played in VLC. I know I can correct the shearing with a simple image processing operation, but I'd rather just avoid the problem altogether. Thanks in advance. images

Was it helpful?

Solution

I fixed the problem by using Virtual Dub to convert the file from YUY2 to RGB24. The new file is 50% larger, but Matlab can read it correctly and without shearing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top