Reputation: 2955
Here are two images, one captured before an action has been made by the surgeon and the other afterwards.
Difference: (After - Before) + 128. (The addition of 128 is just to have a better image)
As pointed to by 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 two images or two 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.
Upvotes: 4
Views: 1347
Reputation: 5027
You are looking for a dense optical flow algorithm:
The result for
cv::calcOpticalFlowFarneback(img1, img2, flowField, 0.5, 3, 10, 5, 5, 1.1)
is the following flow field where you clearly see the changes:
As for the global motion detection:
Upvotes: 2