⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 domultifullreadtest.m

📁 Video IO toolbox for matlab. 用directshow做的
💻 M
字号:
function doMultiFullReadTest(varargin)%DOMULTIFULLREADTEST(...)%  First we read the entire specified file into memory.  Then we attempt to%  simultaneously read the same file in using two videoReader objects.%  This tests thread and video handle management issues.%%  Any arguments given are passed directly to the videoReader constructor.%%Examples:%  doMultiFullReadTest%  doMultiFullReadTest ffmpegPopen2  % linux & similar%  doMultiFullReadTest ffmpegDirect  % ...if system's gcc is compatible w/ Matlab's%  doMultiFullReadTest DirectShow    % Windows%%Copyright (c) 2006 Gerald Dalley%See "MIT.txt" in the installation directory for licensing details (especially%when using this library on GNU/Linux).ienter('>>> doMultiFullReadTest(''%s'',...)', varargin{1});images = doFullRead(varargin{:});if (size(images,3) > 1) % skip single-frame videos  % make sure first two frames have different data (makes sure next is  % working)  vrassert any(images(:,:,1) ~= images(:,:,2));  % read from multiple videos at the same time  vr1 = videoReader(varargin{:});  vr2 = videoReader(varargin{:});  i = 1;  while (next(vr1) && next(vr2))    i1 = getframe(vr1); i1 = i1(:,:,1);    i2 = getframe(vr2); i2 = i2(:,:,1);        % Ideally, we'd test     %   all(all(i1 == i2))    %   all(all(images(:,:,i) == i1))    % but it turns out that some decoders (namely ffdshow-tryout's)     % will produce slightly different output when reading a video    % file multiple times.  This may be a decoder bug, or it may be    % an optimization where it does a higher-quality decode after    % the first pass.  If you know the real answer, feel free to    % contact the videoIO authors and let us know.    vrassert all(abs(double(i1(:)) - double(i2(:))) < 35);    vrassert mean(abs(double(i1(:)) - double(i2(:)))) < 4;        vrassert all(all(abs(double(images(:,:,i)) - double(i1)) < 35));    vrassert mean(mean(abs(double(images(:,:,i)) - double(i1)))) < 4;        % since the error bounds are quite high for the above tests,    % we'll also make sure that the frames are more like each other than    % the previous/next frame    errThisFrame = err(mydiff(ilookup(images,i),   i1));    errNextFrame = err(mydiff(ilookup(images,i+1), i1));    errPrevFrame = err(mydiff(ilookup(images,i-1), i1));    vrassert errThisFrame < errNextFrame;    vrassert errThisFrame < errPrevFrame;        errThisFrame = err(mydiff(ilookup(images,i),   i2));    errNextFrame = err(mydiff(ilookup(images,i+1), i2));    errPrevFrame = err(mydiff(ilookup(images,i-1), i2));    vrassert errThisFrame < errNextFrame;    vrassert errThisFrame < errPrevFrame;        i = i + 1;  end  vr1 = close(vr1);  vr2 = close(vr2);endiexit('<<< doMultiFullReadTest(''%s'',...)', varargin{1});%------------------------------------------------------function out = mydiff(a,b) out = abs(double(a(:)) - double(b(:)));function out = clipper(d) dontCareErrThresh = 2;out = d(d>dontCareErrThresh);function out = err(d) out = sum(clipper(d).^2);function out = ilookup(images,i) out = images(:,:,mod(i-1,size(images,3))+1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -