1
我正在研究以下代碼。如何獲得光流場的速度和大小矢量?我正在使用Lucas-Kande光流的方法
n=0;
folder = fileparts(which('viptraffic.avi'));
movieFullFileName = fullfile(folder, 'viptraffic.avi');
vidReader = VideoReader(movieFullFileName);
opticFlow = opticalFlowLK('NoiseThreshold',0.0039);
while hasFrame(vidReader)
frameRGB = readFrame(vidReader);
frameGray = rgb2gray(frameRGB);
flow = estimateFlow(opticFlow,frameGray);
H=imag(flow)
V=real(flow)
frameWithFlow = getframe(gca);
imshow(frameRGB);
imshow(frameWithFlow.cdata)
hold on
plot(flow,'DecimationFactor',[5 5], 'ScaleFactor',10)
hold off
n=n+1;
end
是否有一種方法可以獲得每個圖像中獲得的每個光流場的速度和大小的光流估計?
那麼,用上面的代碼,它將覆蓋每個幀的相位和幅度的值。爲了避免這種情況,我創建了一個三維矩陣: - nArrays = Vid_dur * Vid_frate; %Vid_dur是視頻持續時間,Vid_frate是視頻幀速率 threeD_Ori =零(Vid_height,Vid_width,nArrays,'single'); %Vid_height和Vid_width是視頻幀的高度和寬度。 現在,我將數據存儲在矩陣中作爲 threeD_Ori(:,:,ii)= flow.Orientation; 但是,它給出了不正確的矩陣尺寸誤差。我如何存儲結果? –