Title: How to find Pivot Point from a 2x3 Matrix from a Euclidean Transformation in OpenCV
Tags: opencv;math
Question: I have two images:
Using cv2.findTransformECC (im1,im2,warp_matrix, warp_mode, criteria) I get this transformation matrix:
[[   0.70637488    0.781.575.7008.60842133]
[  -0.70783788    0.70637488  137.01171875]]
How do I find the point about which the image pivots, using that matrix?
Here is what the matrix represents:
I understand that I can use the hypotenuse of the X, Y translation, as well as the angle of rotation to calculate an isosceles triangle.  But how can I use that isosceles triangle (red) to find the X and Y (green) of the center of the translation?  Is trigonometry the only way to find the pivot point?
Comment: @BeyelerStudios - Thanks for the comment.  I am not sure I understand what you are says.  I am looking for the point around which the translation is pivoting.  For example, in the drawing, there are two black squares (lets say they are 10x10).  One of the black squares was rotated  45degrees with 5x 5y as the pivit point.
Opencv gives me the translation (green) and the angle, how do I find that pivot point?

Comment: @BeyelerStudios - I understand that, I will try to explain what I am looking for a little better.  The drawing was something I created and I rotated the black square 45 degrees with 5x 5y as the pivit point.
What I want to do is compare two images, and then find the center as I did in my drawing, using the matrix give by openCV

Comment: @BeyelerStudios Thanks for the reply.  I want to compare two images of the same object.  In one picture the object will be rotated.  Then I want to use the matrix from findTransformECC to discover the point at which it pivoted.  I don't think I described the problem well in my question.

Comment: The origin of the rotation (and of the whole transformation) is wherever the origin of the input images is defined, wherever (0,0) in the image lies: `[x' y']^T := W * [x y 1]^T` http://docs.opencv.org/3.0-beta/modules/video/doc/motion_analysis_and_object_tracking.html#findtransformecc

Comment: No, it was rotated around `(0, 0)` and THEN translated.

Comment: Yes but your pivot is totally arbitrary and has nothing to do with the transformation. Do you mean you want to know the pure rotation of the actual object represented in the image (without the translation component)?

Here is the accepted answer: So you have a transformation matrix
/ a b  tx \
\ c d  ty /
And you want to convert this to a representation of a rotation about some pivot. A rotation about a pivot (px, py) can be expressed as
T = T(p) R T(-p)
If you expand this, you get
/ a b  tx \  =      / a b  px-apx-bpy \
\ c d  ty /         \ c d  py-cpx-dpy /
The first 2x2 matrix is already equal if you choose the same rotation. The last column gives you a linear system of equations. The general solution of this is (disregarding special cases):
px = (tx - d tx + b ty) / (a + b c + d - a d - 1)
py = (ty + c tx - a ty) / (a + b c + d - a d - 1)
For your matrix, this gives:
px = 121.842
py = 172.899
Comment for this answer: Thank you very much!  This is exactly what I was looking for.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 6, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:08/31/16', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<opencv><math>', 'Title': 'How to find Pivot Point from a 2x3 Matrix from a Euclidean Transformation in OpenCV', 'ViewCount': 479, 'id': 39253968, 'user_AboutMe': "<p>I really have no idea what I'm doing. Kinda scary that I have up votes </p>\n", 'user_AccountId': 4322002.0, 'user_DisplayName': 'Jake', 'user_Reputation': 575.0, 'user_Views': 36.0, 'user_id': 3814307.0}}