After reading depth information video file of Kinect as binary(.dat) file, my resulting frames are not proper
1 view (last 30 days)
Show older comments
I read the file until the end, try to store it frame by frame into array, but somehow I have got no successful representation of the video. I am going to put some screenshots also, if it is not clear.
I could not get it why the video is shaped into this much distorted form. By the way, I do not know what the meaning of pixel precision, and by assigning it into uint8, and I need some more elaborated explanation for struct creation and the definitive meaning for cdata. Thanks in advance, sorry for the confusing explanation, but I myself am unfortunately confused.
P.s.: Here are the screenshots:
[1]:http://i.stack.imgur.com/be8Q5.png
[2]:http://i.stack.imgur.com/3CLVL.png
fid = fopen('depth.dat');
col = 640;
row = 480;
frames = {}; %// Put Frames
numFrames = 0; %// Number of frames
while (true) %// end of file
B = fread(fid, [col row],'uint8=>uint8'); %// Read in one frame at a time
if (isempty(B))
break;
end
frames{end+1} = B.'; %// Transpose
numFrames = numFrames + 1; %// Count frame
%imwrite(frames{numFrames},sprintf('Depth_%03d.png',numFrames));
end
movieFrames(numFrames) = struct('cdata',[],'colormap',[]);
for idx = numFrames: 1
img = frames{idx};
movieFrames(idx) = im2frame(cat(3,img, img, img));
end
figure;
imshow(movieFrames(1).cdata); %// figure size
movie(movieFrames, 1, 30);
fclose(fid);
0 Comments
Answers (0)
See Also
Categories
Find more on Kinect For Windows Sensor in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!