Opencv image stabilization implementation, C ++

Today I have many questions, and I need some help, even in some parts of my question. These questions are really urgent to answer, so please try to do everything possible with me.

I am working on image stabilization using the optical flow method. This step was done correctly and gave good results, now I want to implement stabilization for the video, that I have 2 ways to do this: First way: I got the translation and rotation matrices between the features of the first frame and the next frame. Now my supervisor suggested that I do this: Make the canvas larger than the original frame, and copy the first frame in the middle. For each next frame, use the transformation I got to calculate the offset and rotation. Use these options and copy the next frame to the corrected position. This should fix the video.

So how to do this? and please help with features in openCV, if available.

Second way

I tried to do it my own way, and I tried to get the corrected video by deforming the image that I got with the homography matrix, but in any case this does not work with the cvWarpPerspective(). function cvWarpPerspective(). . to fix what I'm doing here to get a stabilized image or what do you suggest?

Question:

1- The homographic matrix gives negative values: right?

2 As I said above about the rotation and translation matrices that I have to do for this equation in order to return the evaluation attribute in the second frame to its place in the first frame

Y = rotation matrix * x + translation matrix

which sometimes gives almost perfect results, and sometimes gives very terrible results, which I get negative values ​​and far from the place where they should be, Why is this so?

Please answer what you can answer even if it is a sub question

Thank you very much.

+8
c ++ image image-processing opencv
source share
2 answers

It seems you might have incorrect matches that spoil your algorithm to restore global alignment (BTW, which algorithm are you using?). Trying to see what happens on a synthetic dataset with only a few matches can help.

+1
source share

The homographic matrix gives negative values: right?

Probably not. I guess this will require viewing the image from behind.

once again give very terrible results, which I get negative values ​​and far from the place they should be on, Why does it like that?

some ideas:

  • int overflow?
  • detected incorrectly?
  • If I remember correctly, homographic matrices only work when the translation is not NULL
-one
source share

Source: https://habr.com/ru/post/650726/


All Articles