please how can I get the flow vectors from this code

2 views (last 30 days)
Dear all,
I implemented the code that is found in the file exchange in mathwork website ( real time optical flow ) to find out the optical flow.
the code is working properly but there is only just one x and y flow vector for the whole video, the writer of this code mentioned about getsavedflow () to save the flow of all frames. but there is always error says no saved session initialized when I use this command.
I want to get the flow vectors to compute the histogram of optical flow.
clear in;
% This script sets up the call to the function 'vidProcessing'.
% The source of video to process.
in.movieType = 'person01_walking_d1_uncomp.avi';
%in.method = @FlowLK; %Lucas and Kanade
in.method = @Flow1; %Locally regularized and vectorized method
%in.method = @FlowHS; %Horn and Schunk, variational (global regularization)
% in.method = 'synthetic'; %Ground truth optical flow (synthetic sequence only)
%%Argument bRecordFlow
in.bRecordFlow = 1; %record the video (and flow if available)
%%Arguments vidRes and flowRes
% resolution of video and flow field [Height Width]:
in.vidRes = [128 128]; %video resolution, does not affect file-input(avi or saved-folder)
in.flowRes = [24 24]; %flow resolution
%%argument 'tIntegration'
% the amount of temporal integration. tIntegration should be in the
% range [0,1). If tIntegration = 0, then no integration in time occurs.
% in.tIntegration = 0.2;
in.bDisplayGT = 0; %display groundtruth flow, if available
%%Argument syntSettings
%Use "in.syntSettings" to
% to specify the contents of the synthetic
% video. For example:
in.syntSettings.backWeight = 0.7; %background edge
in.syntSettings.edgeTiltSpd=-2*pi/10000; %speed of rotation of background edge
% in.syntSettings.noiseWeight = 0.2; %signal to noise weight (in range [0,1])
in.pathToSave = 'GroundTruthData'; %define directory for saving
% in.pathToSave ='TestLK';
% in.startingTime = 50;
in.endingTime = 1000;
% in.endingTime = 'eof';
in.targetFramerate = 20;
pathToSave = vidProcessing(in);
flowPlayBack('GroundTruthData')
[im, u, v, macroDat] = getSavedFlow();
%%%After finishing with the session, you can view recorded data by:
%FancyFlowPlayer(in.pathToSave);
%%%... then access the data of the frame:
%%%im is the video frame
subplot(1,2,1);imagesc(im); colormap gray;
axis image;title('video frame');
%%u and v are the components of the flow
subplot(1,2,2);imagesc(sqrt(u.^2+v.^2));colormap gray;
axis image; title('Motion magnitude(groundtruth)')
%%argument 'MaxIterations' %%%%%%%%%%%%%%
% the number of iterations performed for iterative algorithms
% in.MaxIterations = 10;
% NOTE 1: vidProcessing make use of the global workspace through a single
% global variable "g".
% NOTE 2: with high res optical flow, there may be some quantization errors
% when saving. Flow is saved in 8 bit(for u and v each) preciscion only when
% high res. Play around with the parameter:
% in.rm = 5;
% rm is the upper bound of how high the output flow may be (for high res
% flow only). If you increase it, you loose quantization preciscion, but
% that may be preferrable from having your data be corrupted by truncation
  1 Comment
Mammo Image
Mammo Image on 29 Aug 2016
every time I post a question there is no answer .. why? I followed your instructions , mentioned the problem, the code and the question. why always there is no answer .. is there a problem with my questions?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!