Warp images using motion maps generated by optical FlowLKDoG (Matlab 2015A)

This question is based on modified Matlab code from online documentation for optical flow system objects in 2015a version as shown in opticalFlowLK class

clc; clearvars; close all;
inputVid = VideoReader('viptraffic.avi');
opticFlow = opticalFlowLKDoG('NumFrames',3);
inputVid.currentTime = 2;
k = 1;
while inputVid.currentTime<=2 + 1/inputVid.FrameRate
 frameRGB{k} = readFrame(inputVid);
 frameGray{k} = rgb2gray(frameRGB{k});    
 flow{k} = estimateFlow(opticFlow,frameGray{k});
 k = k+1;
end

      

Let's look at stream {2} .Vx and stream {2}. We get U and V motion maps that describe motion from frameGray {1} to frameGray {2}.

I want to use stream {2} .Vx and stream {2}. Directly onto the data in frameGray {1} to convert frameGray {1}, which visually resembles frameGray {2}.

I tried this code:

[x, y] = meshgrid(1:size(frameGray{1},2), 1:size(frameGray{1},1));
frameGray1Warped = interp2(double(frameGray{1}) , x-flow{2}.Vx , y-flow{2}.Vy);

      

But it doesn't seem to do anything at all other than ruining the image quality (but objects do not display any real movement in relation to their locations in frameGray {2}.

I added 3 images showing 2 original frames, followed by frame 1 distorted using a motion field similar to frame 2:

frame 1

frame 2

frame 1 warped to 2

It is easy to see that frame 1, deformed to 2, is essentially frame 1 of degraded quality, but the machines did not move at all. That is - the location of the cars is the same: look at the car closest to the camera relative to the road dividing line next to it; it is practically the same as in frame 1, and frame 1, distorted to 2, but in frame 2 is completely different.

+3
image-processing matlab matlab-cvst opticalflow


source to share


No one has answered this question yet

Check out similar questions:

1518
Image processing: improvement of the algorithm for the recognition of "Coca-Cola Can"
eleven
simple case of optical flow
3
How to determine spiral optical flow using Matlab?
3
Resolving conflicts when using OpenCV on iPad
1
Detecting Rotating Objects Using MATLAB
1
Determining if an object is part of a moving object from a rarefied optical stream (KLT)
1
Kinect maps color image to depth image in MATLAB
1
Calculation of motion vectors
1
Splitting color image in MATLAB
1
Recovering motion from optical flow information



All Articles
Loading...
X
Show
Funny
Dev
Pics