I'm writing a piece of software that needs a kind of image recognition( think QR code ) to display 3d objects over the camera feed. The 'code' containing the information needed to display the model is a perfect square, but I need to somehow calculate it's 3d rotation. The data available is a constructed 2d quadrilateral based on the camera feed.
Calculating 3D rotation of predefined shape from 2D data ( image )
Members - Reputation: 455
Posted 06 October 2013 - 02:18 PM
I have never tried it, but it is interesting from mathematical point of view ;)
In 2D image you do not have the z position of the each point.
But, if the model is perfect square, then all edges shall be the same length (say L).
Each point p'=(x',y') on screen is representation of some point p=(x,y,z) in 3D space, that:
and you know that borders have
and across the polygon
I assumed that points are sorted.
So you have 14 equations for 13 unknown variables (x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3, L).
It is more than you need. I would try to solve it with some approximate, iterative method
(Newton or maybe least squares). From 3D model you may get the rotations, but,
you need to know which two points are the reference (e.g.. the square rotated by 90 deg around the center is looks as the same square ).
Edited by mawigator, 06 October 2013 - 02:33 PM.