From: Bradley on 4 Jun 2010 03:57 Having upgraded to MATLAB 2010a, I am trying to replace 'aviread' calls in my program with 'mmreader' calls. However the equivalent read in time seems to be about 20 times slower. Given that aviread already took about 50% of the program runtime for a time-sensitive program, that is very slow. Eg: start=1; finish=1000; tic; arvideo = aviread(filename,start:finish); toc compared to (on a fresh restart of MATLAB) clear all; close all; start=1; finish=1000; tic; videoobj = mmreader(filename); mmvideo = read(videoobj,[start finish]); toc The relative timings are 0.30-0.32 seconds and 6.1-7.5 seconds (128x16 uncompressed 8 bit avi, taking times of runs 2-5 to allow jit compilation) Additionally, mmreader seems to run out of memory very easily - 'aviread' can load 40,000 frames into a structure while 'read' can only cope with ~1,000 before giving an error to do with not enough memory to hold the array ('memory' says max array size of 16MB: my videos are just over 200,000 frames long - so that means loading in >200 fragments instead of 6) Does anyone have any suggestions? A 20x slowdown on video reading would be extremely painful, and the additional fragmentation would be mildly annoying.
From: Rune Allnor on 4 Jun 2010 04:23 On 4 Jun, 09:57, "Bradley" <starstrik...(a)yahoo.com.au> wrote: > Does anyone have any suggestions? A 20x slowdown on video reading would be extremely painful, and the additional fragmentation would be mildly annoying. Video decoding is hard at the best of times. One needs an extremely streamlined data flow from file to display to have anything done in real time. Matlab was never designed with that kind of thing in mind, so it is hardly surprising that it is slow. I think you will find that matlab's video format access functions are intended to allow you to access video file. Not access and display video in real time. Rune
From: Bradley on 4 Jun 2010 06:36 Hi Rune, Thanks. We're not trying to display video in real time, but to do image analysis on the video frames to measure the location of objects under a microscope - something well suited to MATLAB. It's just that even with aviread, the file-read time was a significant fraction of the processing time (one or a few objects in a sparse video), and the default usage of mmreader seems to be much slower than aviread - which seems odd for a new function that is replacing an older one?
From: Rune Allnor on 4 Jun 2010 09:00 On 4 Jun, 12:36, "Bradley" <starstrik...(a)yahoo.com.au> wrote: > Hi Rune, > > Thanks. We're not trying to display video in real time, but to do image analysis on the video frames to measure the location of objects under a microscope - something well suited to MATLAB. It's just that even with aviread, the file-read time was a significant fraction of the processing time (one or a few objects in a sparse video), and the default usage of mmreader seems to be much slower than aviread - which seems odd for a new function that is replacing an older one? This depends on a number of questions, like where AVIREAD came from and why MMREADER replaces it. As far as I know, fast video decoders tend to use the MMX processor in the intel CPU. There are tow problems with that: 1) One needs to hand-code assembly language to exploit this processor (as far as I know, few if any compiler use this instruction set) 2) Due to a design flaw, the MMX processor does not work well with the FPU in the Intel processor. Somebody who write the first AVI decoder might be inclined to use the fast MMX instruction set. However, maintaining the code will be hard. One might imagine that somebody who is in charge of the function over its life time - coding, maintenance, support - decides to sacrifice run-time speed over easily understood and maintained C code. It *could* be that the replacement function uses 'naive' C where the original function used hand-crafted MMX assembly. You ought to ask at matlab tech support. Rune
|
Pages: 1 Prev: Enabled subsystem output signals Next: Audemars Piguet Royal Oak Offshore Jewellery Collection |