need help with code to convert yuv sequences to a mat file

need help with code to convert yuv sequences to a mat file

Post by Naee » Thu, 03 Jun 2010 15:49:09


I am trying to use the code below to convert yuv sequences into a single matlab video file.
but when i run the code it shows error "Invalid file identifier".

can someone please point out the mistake it would be a great help.

clear;
%***************
for i=1:150
i
indx=num2str(i,'%11.3d');

fid = fopen(['C:\video_sim\test_seq\tennis\tt',indx,'.yuv'],'r');
s = fread(fid,[352 240],'uchar');
fclose(fid);
frames_t(:,:,i)=s;
end
frames=frames_t;
for j = 1:150
imshow(frames_t(:,:,j)/255);
Frm(j) = getframe;
end
fp_sec=10;
movie(Frm,2,fp_sec)
 
 
 

need help with code to convert yuv sequences to a mat file

Post by Walter Rob » Thu, 03 Jun 2010 23:02:47


That means an open failed. Your code does not check for that
possibility, and does not display the status result of the open if it
happens.


That is going to result in spaces before the number, and will have .000
at the end (since all the values being converted are integers). Do you
really want a name that has spaces and a decimal place in it?


Test the result of the fopen!

 
 
 

need help with code to convert yuv sequences to a mat file

Post by Naee » Fri, 04 Jun 2010 02:18:06


well i have 112 yuv sequences with names like tt001.yuv, tt002.yuv,tt003.yuv etc
i got the above code from a friend , the loop runs for each of 112 frames but the fopen function doesn't seem to work.

If i could atleast convert these sequences into yuv video then i could use yuv2mov function to convert to matlab movie.

do u have any idea please help me out.
 
 
 

need help with code to convert yuv sequences to a mat file

Post by Walter Rob » Fri, 04 Jun 2010 03:19:15


for i = 1:150
filename = sprintf('C:\video_sim\test_seq\tennis\tt%03d.yuv', i);
fid = fopen(filename,'r);
...
end
 
 
 

need help with code to convert yuv sequences to a mat file

Post by Naee » Mon, 14 Jun 2010 15:34:04


could u please tell me how to convert a matlab movie into a mat file.
 
 
 

need help with code to convert yuv sequences to a mat file

Post by Walter Rob » Mon, 14 Jun 2010 18:44:08


save()

Somehow though I suspect that might not be exactly what you want; if
not, then please indicate what format you want to store the data in.
 
 
 

need help with code to convert yuv sequences to a mat file

Post by Naee » Tue, 15 Jun 2010 02:27:04


i have a file "football.mat" which is made from yuv video sequences such as football00.yuv,football01.yuv etc. i dont know how it was created so when i used the whos function in matlab it showed

whos -file football.mat
Name Size Bytes Class

org_football 240x352x125 84480000 double array

Grand total is 10560000 elements using 84480000 bytes

So i would like to create a similar mat file for some other yuv video sequences.
i have used the code below to read the yuv sequences and create a matlab movie.
All i need is a mat file like the above one. Please help.

clear;
%***************
for i=1:150
i
indx=num2str(i,'%03d');
fid = fopen(['C:\video_sim\test_seq\coastguard\coastguard',indx,'.yuv'],'r');
s = fread(fid,[352 288],'uchar');
fclose(fid);
frames_t(:,:,i)=s';
end
frames=frames_t;
for j = 1:150
imshow(frames_t(:,:,j)/255);
Frm(j) = getframe;
end
fp_sec=10;

movie(Frm,2,fp_sec);

movie2avi(Frm,'C:\video_sim\test_seq\coastguard\coastguard.avi','fps',10,'compression','none','quality',100);
 
 
 

need help with code to convert yuv sequences to a mat file

Post by Walter Rob » Tue, 15 Jun 2010 09:53:18


It appears likely that the matrix org_bootball would be the same kind of
content as you would get if you were to save your variable frames_t
 
 
 

need help with code to convert yuv sequences to a mat file

Post by Naee » Tue, 15 Jun 2010 13:09:06


thanks a lot it worked.