Hello,
unfortunately, I've found no evidence of a special function for calculation of Homography matrix decomposition into rotation-translation matrix H->[R|t]. I'm pretty sure it should be there, but either not on the public API (only used internally) or I missed it. Thanks in advance |
There is a one it is (Solvepnp)
but it is very slow so I recommend if you can implement your function by yourself ________________________________ From: lireweb <[hidden email]> To: [hidden email] Sent: Thursday, February 16, 2012 6:41 PM Subject: [OpenCV] Homography decomposition Hello, unfortunately, I've found no evidence of a special function for calculation of Homography matrix decomposition into rotation-translation matrix H->[R|t]. I'm pretty sure it should be there, but either not on the public API (only used internally) or I missed it. Thanks in advance |
> There is a one it is (Solvepnp)
> but it is very slow so I recommend if you canÂ implementÂ your function by yourself Correct me if I say something wrong but solvePnP() is not suitable for this problem (plus if users have to implement such a function by themselves, I don't see the point using OpenCV at all). A homography matrix H is the relation between two sets of points from two different projections of real-world points. The OpenCV's solvePnP() computes the pose from a set of projection points and the real-world points. You can't give it a homography matrix as input (or two sets of projected points) and obtain rvec and tvec as output. That's something that seriously is a miss in OpenCV right now. > ________________________________ > From: lireweb <slireweb@...> > To: [hidden email] > Sent: Thursday, February 16, 2012 6:41 PM > Subject: [OpenCV] Homography decomposition > > > Â > Hello, > > unfortunately, I've found no evidence of a special function for calculation of Homography matrix decomposition into rotation-translation matrix H->[R|t]. I'm pretty sure it should be there, but either not on the public API (only used internally) or I missed it. > > Thanks in advance |
thanks, spechard,
I actually imagined the situation very similar to your words, though I wouldn't say openCV is useless. Regarding the decomposition, it is a relatively simple algorithm well documented in several realizations, so writing it by myself won't be a problem. I would love to contribute it to openCV, but I use python, which is not a native language for the library. --- In [hidden email], "spechard" <spechard@...> wrote: > > > There is a one it is (Solvepnp) > > but it is very slow so I recommend if you canÂ implementÂ your function by yourself > > Correct me if I say something wrong but solvePnP() is not suitable for this problem (plus if users have to implement such a function by themselves, I don't see the point using OpenCV at all). A homography matrix H is the relation between two sets of points from two different projections of real-world points. The OpenCV's solvePnP() computes the pose from a set of projection points and the real-world points. You can't give it a homography matrix as input (or two sets of projected points) and obtain rvec and tvec as output. > That's something that seriously is a miss in OpenCV right now. > > > > ________________________________ > > From: lireweb <slireweb@> > > To: [hidden email] > > Sent: Thursday, February 16, 2012 6:41 PM > > Subject: [OpenCV] Homography decomposition > > > > > > Â > > Hello, > > > > unfortunately, I've found no evidence of a special function for calculation of Homography matrix decomposition into rotation-translation matrix H->[R|t]. I'm pretty sure it should be there, but either not on the public API (only used internally) or I missed it. > > > > Thanks in advance > |
In reply to this post by spechard
If the problem (as I think ) is pose estimation problem
the problem is to find the rotation & translation matrices of an object or the extrinsic camera parameters if we assumed that object is a planar object -Correct me if I am wrong- Solvepnp() : The function estimates the object pose given a set of object points, their corresponding image projections, as well as the camera matrix and the distortion coefficients. of-course not the homography matrix then solvepnp() can solve that problem (I tried it before in case of planar object) For this task solvepnp() was slow but when I implement that function of pose estimation by myself it was faster than it so I don't recommend to use it. If you have a different experiment plz share it with us :) ________________________________ From: spechard <[hidden email]> To: [hidden email] Sent: Friday, February 17, 2012 10:41 AM Subject: [OpenCV] Re: Homography decomposition > There is a one it is (Solvepnp) > but it is very slow so I recommend if you canÂ implementÂ your function by yourself Correct me if I say something wrong but solvePnP() is not suitable for this problem (plus if users have to implement such a function by themselves, I don't see the point using OpenCV at all). A homography matrix H is the relation between two sets of points from two different projections of real-world points. The OpenCV's solvePnP() computes the pose from a set of projection points and the real-world points. You can't give it a homography matrix as input (or two sets of projected points) and obtain rvec and tvec as output. That's something that seriously is a miss in OpenCV right now. > ________________________________ > From: lireweb <slireweb@...> > To: [hidden email] > Sent: Thursday, February 16, 2012 6:41 PM > Subject: [OpenCV] Homography decomposition > > > Â > Hello, > > unfortunately, I've found no evidence of a special function for calculation of Homography matrix decomposition into rotation-translation matrix H->[R|t]. I'm pretty sure it should be there, but either not on the public API (only used internally) or I missed it. > > Thanks in advance |
I believe that there are 2 things being discussed here: estimating a homography matrix from corresponding points in images (which OpenCV does support); and decomposing a homography matrix into translation and rotation vectors for the object in space (which OpenCV does not seem to support).
I think you have to look elsewhere, but there is plenty of material and sample code available on the internet so you can still be open source. One starting point I found: http://urbanar.blogspot.com/2011/04/from-homography-to-opengl-modelview.html --- In [hidden email], phars alnmr <phars_alnmr@...> wrote: > > If the problem (as I think ) is pose estimation problem > the problem is to find the rotation & translation matrices of an object orÂ > theÂ extrinsicÂ camera parameters if we assumed that object is a planar object > -Correct me if I am wrong- > > Solvepnp() :Â The function estimates the object pose given a set of object points, their corresponding image projections, as well > as the camera matrix and the distortion coefficients. > of-course not theÂ homographyÂ matrix > > then solvepnp() can solve that problem (I tried it before in case of planar object) > > For this task solvepnp() was slow but when IÂ implementÂ that function of pose estimation by myself it was faster than it so I don't recommend to use it. > If you have aÂ differentÂ experimentÂ plz share it with us :) > |
In reply to this post by lireweb
I think this is what you are looking for, as a disclaimer, its not my original solution, i found it somewhere in the past and stored it on a text file ;)
A 2D homography matrix looks like this : [R11,R12,T1] [R21,R22,T2] [ P , P , 1] where R represents a rotation matrix, T represents a translation, and P represents a perspective warp. And so a purely translational homography looks like this: [ 1 , 0 , x_offset] [ 0 , 1 , y_offset] [ 0 , 0 , 1 ] So just premultiply your homography by a matrix similar to the above, and your output image will be offset. --- In [hidden email], "lireweb" <slireweb@...> wrote: > > Hello, > > unfortunately, I've found no evidence of a special function for calculation of Homography matrix decomposition into rotation-translation matrix H->[R|t]. I'm pretty sure it should be there, but either not on the public API (only used internally) or I missed it. > > Thanks in advance > |
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Homography maps 2D homogeneous coordinates via a 3x3 matrix. That is
x2 x1 y2 ~ H y1 1 1 The coordinates doesn’t need to be the projections, they can be even the points in 3D where you set z=0 to indicate the fact that you deal with a plane in 3D. In this sense, solvePnP is what you may want. In practice Homography arises from many cases such as projection of plane points into a flat sensor, or projection of the same plane into two different sensors; a third case is a pure camera rotation with points projected from arbitrary 3D shapes (since same matching rays will be intersected by a sensor); the forth case is a zoom operation. Homographies are also used during image rectification. Let’s see how to decompose a homography in the first case: projection of a plane into the flat sensor. Other cases are quite similar (just imagine that instead of a plane in 3D you have another sensor). 1. Get rid of intrinsic parameters: H’ = A^-1 *H, where A is an intrinsic matrix; 2. Estimate the first two columns of a rotation matrix through SVD (see openCV SVD(FULL_UV)): h11 h12 h21 h22 = ULV' h31 h32 set the first two columns of rotation matrix to this (related to Orthogonal Procrustes problem): r11 r12 1 0 r21 r22 = U 0 1 V' r31 r32 0 0 and the third column is set as a vector product of the first two columns making it perpendicular and of length one; invert its sign, however, if the determinant of the resulting Rotation matrix is -1; 3. Estimate a scaling factor (it may be 1 in your case but nonetheless) scl = sum(Rmn/Hmn)/6 where the sum is over the first 2 columns 4. Estimate the translation as t = [h13, h23, h33]’/scl 5. Keep in mind that operations in homogeneous coordinates (unlike Cartesian ones) don’t optimize a correct objective function but rather minimize algebraic error in parameters. What you really want to minimize is not a parameter error but a squared error in pixels (in the presence of Gaussian noise). Thus above estimation of rotation and translation should only be used as an initial guess for a further non-linear optimization: argmin (sum ([y2i, x2i]’ - A*R|T * [x1i, y1i, 0]’)^2 ) R,T This can partially explain why a real algorithm may run slow. |
Free forum by Nabble | Edit this page |