Suppose you have a pinhole camera (no lens) with known position and orientation with respect to the world.
Now with this camera, you take an image of a triangle that has known side lengths of arbitrary position/orientation in space.
The camera has a known focal length.
Can you determine the coordinates of the vertices of the triangle, using only the image and the position/orientation of the camera together with its focal length ?
Is there more than one possible set of coordinates for the vertices ?
My approach:
I'll assume that the projection plane lies between the projection center of the camera. Set up a coordinate system for the camera with its origin at the projection center, and with its $X$ axis pointing from the center of the image to the right of the image, and its $Y$ axis pointing from the center of the image to the top of the image. The $Z$ axis follows from that (using the right hand rule).
Let $z_0$ be the focal length (which is known). The equation of this plane in the coordinates of the camera coordinate frame that we just set up is $ Z = - z_0 $
Therefore, the coordinates of the three image points in this coordinate system are
$ P_1 = \begin{bmatrix} Q_1 \\ - z_0 \end{bmatrix} $
$ P_2 = \begin{bmatrix} Q_2 \\ - z_0 \end{bmatrix} $
$ P_3 = \begin{bmatrix} Q_3 \\ - z_0 \end{bmatrix} $
where $Q_1, Q_2, Q_3$ are the coordinates of the three vertices in the image (they are two-dimensional vectors).
Now construct rays from the origin of the camera coordinate system to $P_1, P_2, P_3$. These rays will be
$ p_1(t_1) = t_1 P_1 $
$p_2 (t_2) = t_2 P_2 $
$p_3 (t_3) = t_3 P_3 $
Now we know the side lengths, so let $a = \overline{V_1 V_2} $, $b = \overline{V_2 V_3} $ and $c = \overline{V_1 V_3} $, then
$ ( p_1 - p_2 ) \cdot (p_1 - p_2) = a^2 $
$ (p_2 - p_3) \cdot (p_2 - p_3) = b^2 $
$ (p_1 - p_3) \cdot (p_1 - p_3) = c^2 $
This is a system of three quadratic equations in the unknowns $t_1, t_2, t_3$.
It can be solved by Mathematica, (or WolframAlpha.com) or other mathematical software.
Since I'm not subscribed to Mathematica or WolframAlpha.com and I don't know the Mathematica script language, and the fact that I've already developed code for solving three quadratic equations in three unknowns, that's what I used to solve the system.
This code that I've developed is included in this Excel file which contains the source code for the functions "solve_rd_system" (that solves the system $A x = b$, where $A$ is $ m \times n$), and the function "intersect_three_quadrics" which solves a system of three quadratic equations in three unknowns, and also other functions that solve a system of two quadratic equations in two unknowns. These are included in this file as macros (VBA script). Click on the link, to open the online file, then click on "Editing" and choose "Open in Desktop App". This will open the file in your desktop Excel program. Click "View" then select "Macros".
This solves my problem.
A very simple part remains, which is as follows: having determined $t_1, t_2, t_3$, we now have $p_1, p_2, p_3$ as coordinates of the three vertices relative to the camera coordinate frame. To convert these into world coordinates, we use the given position and orientation of the camera. If the world position is $E$ and the orientation is specified by rotation matrix $R$ , then the coordinates of the three vertices are
$ V_1 = E + R p_1 $
$ V_2 = E + R p_2 $
$ V_3 = E + R p_3 $
I look forward to your input (remarks) concerning this simple straightforward method that I've explained above.
Alternative solutions are welcome and highly appreciated.