c++ - How to find the angle of rotation and translation using opencv if I know the homogeneous transformation matrix in 3d? -


I have received many posts about this topic, but no solution is using opencv.

I am thinking that OpenCV has a function or class which can help on this topic?

I have 4 * 4 affin changes in OpenCVI and I am looking to find rotation, translation assumes that scaling is 1 and there is no other change in the matrix.

Is there a function in OpenCV to help find these parameters?

The problem you are experiencing is known as the matrix decomposition problem.

You can retrieve your desired matrix in the following steps:

  1. By these values ​​the first three base vectors Divide (thus they are normalized)
  2. Left 3x3 part of upper-matrix now represents rotation (you can use it as this, or convert it to quaternion form )
  3. The fourth base vector of the matrix (punishment) The National coordinates - in the first three elements which are interested)

your case, your scaling factor is 1, you can skip the first two steps. To retrieve the rotation matrix axis and angle (in radians) I recommend you to port the following Java algorithm. OpenCV (source :).

  / ** In the form of input it requires pure rotation matrix 'm' * / public axangle toxisanganel (matrix m) {double angle, x, y, z; For the result // variable double Epicelon = 0.01; // Double apicylon 2 = 0.1 to allow margin rounding errors; // To change margin between 0 and 180 degree / alternate check that the input is pure rotation, 'isRotationMatrix' is defined: // http://www.euclideanspace.com/maths/algebra/matrix/orthogonal / Rotation / thrust IsRotationMatrix (m): not "valid rotation matrix" for debugging; // (for debugging) ((Math.Abus (M [0] [1] -M [1] [0])  yy) & amp; amp;; (xx> zz)) {// m [0] [0] is the largest diagonal term (xx  zz) {// m [1] [1] is the largest diagonal term (yy & lt; epsilon) {x = 0.7071; Y = 0; Z = 0.7071; } Else {y = Math.sqrt (yy); X = xy / y; Z = yz / y; }} Other {// m [2] [2] is the largest diagonal term, hence the base result if (zz  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -