compute global motion opencv 2.4.x C++

asked 2016-01-19 11:17:56 -0500

maystroh10 gravatar image

updated 2016-01-20 08:50:48 -0500

Here are 2 images, one captured before an action has been made by the surgeon and the other afterwards.

BEFORE:

image description

AFTER:

image description

Difference: (After - Before) + 128. (The addition of 128 is just to have a better image)

image description

As pointed the white arrows, there has been a global motion affecting all the objects. So, I need to estimate it in order to get more valuable information on what's happening in the scene. I already knew that OpenCV 3.0 helps in this context where it's implemented some methods that estimate the dominant motion between 2 images or 2 list of points. But I'm using so far OpenCV 2.4.x because I have dependencies with libraries already installed on my machine so I'm looking for alternative solutions or any other code that does what I want.

Optical Flow:

image description

So as you can see above, I can't differentiate between motions after computing the optical flow.

Thanks in advance.

edit retag flag offensive close merge delete

Comments

How about using an optical flow filter with a custom build grid?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 04:57:08 -0500 )edit

@StevenPuttemans, Can you just clarify what you said? just because I don't need to ask dump questions

maystroh10 gravatar imagemaystroh10 ( 2016-01-20 06:32:02 -0500 )edit

Optical Flow looks how pixels move in between frames. I think it must be possible to tell it which points to track instead of all pixels. The explanation of optical flow is here and the optical flow implementation is here.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 06:45:16 -0500 )edit

Even if I can do so? how can I get what I want? didn't get it..

maystroh10 gravatar imagemaystroh10 ( 2016-01-20 08:14:50 -0500 )edit

IF you the optical flow or the movement from each pixel, then you can classify what has happened right?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 08:17:22 -0500 )edit

@StevenPuttemans, Edited question

maystroh10 gravatar imagemaystroh10 ( 2016-01-20 08:51:42 -0500 )edit

Wow wait, you can now look at the local deformation of the optical flow, which tells you which object moved alot and what is the average direction right? Secondly you could combine this with background subtraction to see what objects have actually disappeared or re-entered the image.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-20 09:03:31 -0500 )edit

what do you mean by local deformation? For better understanding of the problem, you can check this link

maystroh10 gravatar imagemaystroh10 ( 2016-01-20 13:41:42 -0500 )edit

I will not go cross forums to get your problem solved. What I mean is that the optical flow gives a direction and a size of movement. SO you can model that and try to look for areas with a minimum deformation.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-21 03:17:42 -0500 )edit