Optical Flow in Computer Vision tool box

1 view (last 30 days)
KaMu
KaMu on 16 Mar 2012
In the vision.optical flow, How can I plot the vector direction. Quiver draw the vector into image and i have video player. It also requires block size. Here is the code that i have (it is the same one in the example):
-------
hvfr = vision.VideoFileReader('MyVid.mov', ...
'ImageColorSpace', 'Intensity', ...
'VideoOutputDataType', 'uint8');
hidtc = vision.ImageDataTypeConverter;
hof = vision.OpticalFlow('ReferenceFrameDelay', 2);
hof.OutputValue = 'Horizontal and vertical components in complex form';
hmean1 = vision.Mean;
hsi = vision.ShapeInserter('Shape','Lines','BorderColor','Custom', 'CustomBorderColor', 255);
hvp = vision.VideoPlayer('Name', 'Motion Vector');
ii=0;
while ~isDone(hvfr)&&ii<1000
frame = step(hvfr);
im = step(hidtc, frame);
of = step(hof, im);
lines = videooptflowlines(of, 20); % generate coordinate points
if ~isempty(lines)
out = step(hsi, im, lines); % draw lines to indicate flow
step(hvp, out);%show it on the video player
end
ii=ii+1;
end
release(hvp);
release(hvfr);
--------
Thanks

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!