Pergunta

I am developing a pose estimation system from a planar marker (using Matlab). In order to do that, I detect a rectangle in an image captured with a webcam, get the coordinates of the 4 corner points and compute the homography between these corner points in homogeneous coordinates, e.g.

     58     46     75     90
 M = 67    108    133     89
      1      1      1      1

where the first row are the vertical and the second row are the horizontal coordinates.

I compute the homography with DLT (using several different homography calculation functions I've found on the web, as well as Matlab's cp2tform, which ALL give the same results) between these points and the reference points as I know that the marker is a square,

     1     1   100   100
 m = 1   100   100     1
     1     1     1     1

[Edit: They both are sorted in counter-clockwise order, so I make sure they match.]

I then plot the reprojection of these reference points

 m* = H*m

back into the webcam image in order to see how well the homography is fitting.

The results are fine AS LONG as I only rotate (i.e. holding it in front of the webcam and manually tilting it) the marker around the z-axis (=the norm vector of the marker); the reprojected points are projected almost exactly onto the earlier detected marker corner points and the decomposed z-axis angle is computed just fine.

However, if I rotate the marker around the x- and/or y-axis, the reprojected points are increasingly off by quite a bit. What I then realized is that the calculated homography matrix H is almost an affine one, e.g. H=

    0.2339   -0.0967   57.8362
H = 0.1339    0.4714   66.3639
   -0.0010    0.0005    1.0000

(elements h31 and h32 are almost zero no matter how much I tilt the marker) which can be confirmed by looking at the reprojected points which always look like the result of an affine transformation, not a projective one. Unsurprisingly the decomposed angles for x- and y-axis are almost zero/equal to zero.

Obviously the functions I found on the web cannot all get the homography calculation wrong, neither can Matlab's cp2tform, but unfortunately I do not see or understand what my mistake is. It must be in the usage of the pixel coordinates but as looking at many homography explanations and searching for 'homography estimation result affine' did not yield any results, I'd be very glad if someone could point me in the right direction.

Thanks.

Foi útil?

Solução

As I could see from the values @mmpg provided in the comments, my y- and x-axis were still switched to match Matlab's coordinate system for images (y first, x second) which turned out to be the problem. I didn't think of such a fundamental issue since the Homography I got was quite close to the correct one in a big range of angles.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top