I am developing a posture assessment system from a planar marker (using Matlab). To do this, I find a rectangle in the image captured by the webcam, get the coordinates of the four corner points and calculate the homography between these corner points in uniform coordinates, for example.
58 46 75 90 M = 67 108 133 89 1 1 1 1
where the first row is vertical and the second is horizontal.
I compute homography with DLT (using several different homography functions that I found on the Internet, as well as Matlab cp2tform, which ALL give the same results) between these points and anchor points, since I know that the marker is a square,
1 1 100 100 m = 1 100 100 1 1 1 1 1
[ Edit : they are both sorted in counter - clockwise, so I'm sure they match.]
Then I draw the reprogramming of these breakpoints.
m* = H*m
back to the webcam image to see how well homography fits.
The results are beautiful as LONG, as I rotate (that is, hold it in front of the webcam and manually tilt it) the marker around the z axis (= marker normal vector); redesigned points are projected almost exactly onto the previously detected corner points of the marker, and the decomposed z-axis angle is calculated just fine.
However, if I rotate the marker around the x and / or y axis, the reprogrammed points are increasingly disabled. Then I realized that the calculated homography matrix H is almost affine, i.e. H =
0.2339 -0.0967 57.8362 H = 0.1339 0.4714 66.3639 -0.0010 0.0005 1.0000
(the elements h31 and h32 are almost zero, regardless of how much I tilt the marker), which can be confirmed by looking at the reprogrammed points, which always look like the result of an affine transformation, and not projective. It is not surprising that the decomposed angles for the x and y axis are almost zero / equal to zero.
Obviously, the functions that I found on the Internet cannot all correctly compute homographic calculations, nor can there be Matlab cp2tform, but, unfortunately, I do not see or understand what my error is. This should be in the use of pixel coordinates, but looking at many explanations regarding homography and searching for a “homography score”, they didn’t give any results, I would be very happy if someone could point me in the right direction.
Thanks.