Advertisement
Guest User

Untitled

a guest
May 27th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. filepath = 'C:\\bf4 2013-12-07 02-22-08-62.avi';
  2.  
  3. clc;
  4. try
  5. v_handle = VideoReader(filepath);
  6. % video_frames = read(v_handle);
  7. catch err
  8. error('prog:input', 'Invalid filepath! Enter as ''C:\\filelocation\\file.avi'' ');
  9. end
  10. numFrames = v_handle.NumberOfFrames;
  11.  
  12. tic;
  13.  
  14. %Big as possible that can still run in your memory
  15. PartitionSize = 500;
  16.  
  17. total = zeros(v_handle.Height, v_handle.Width, 3);
  18.  
  19. for n=1:PartitionSize:numFrames
  20.  
  21. stop = n+PartitionSize - 1;
  22. if(stop > numFrames)
  23. stop = numFrames;
  24. end
  25.  
  26. A = read(v_handle, [n stop]);
  27.  
  28. %Automatically converted to double by MATLAB
  29. B = sum(A,4);
  30.  
  31. total = total + B;
  32.  
  33. end
  34.  
  35. total = total./numFrames;
  36.  
  37. toc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement