这个函数 videooptflowlines() 的目的是什么;对象 hof 是否还包含有关前一帧的信息来计算光流?
hvfr = vision.VideoFileReader('viptraffic.avi', ...
'ImageColorSpace', 'Intensity', ...
'VideoOutputDataType', 'uint8');
hidtc = vision.ImageDataTypeConverter;
hof = vision.OpticalFlow('ReferenceFrameDelay', 1);
hof.OutputValue = 'Horizontal and vertical components in complex form';
hsi = vision.ShapeInserter('Shape','Lines','BorderColor','Custom', 'CustomBorderColor', 255);
hvp = vision.VideoPlayer('Name', 'Motion Vector');
while ~isDone(hvfr)
frame = step(hvfr);
im = step(hidtc, frame); % convert the image to 'single' precision
of = step(hof, im); % compute optical flow for the video
lines = videooptflowlines(of, 20); % generate coordinate points
if ~isempty(lines)
out = step(hsi, im, lines); % draw lines to indicate flow
step(hvp, out); % view in video player
end
end
release(hvp);
release(hvfr);