Locate a pinhole camera using a fiducial marker 
Note: The superscript notation used refers to the frame of reference. There are three frames of reference:

*

*$w$, the world frame (in Euclidean 2-space),

*$c$, the camera frame (in Euclidean 2-space), and

*$i$, the image frame (in pixels).
Suppose we have:

*

*a 1-dimensional "tag", or "fiducial marker", $t$, defined by its boundaries, $t:=((0,-1)^w,(0,1)^w)$, existing at between $(0,-1)^w$ and $(0,1)^w$,

*a "camera" at $c^w∈ℝ^2$, focal length $f^i>0$, image plane with
width $w^i>0$ (whose center, $d^i:=w^i/2$, is $f^i$ units from $c$).

The optical axis is the line that includes the points $c$, $d$.  Let's define $q$ as the point where the optical axis intersects the $y$ axis.
Define $b^i$ and $c^i$ as the tag's boundaries projected onto the image plane; that is, they are scalars drawn from $[0,w]$ which give some distance along the image plane, such that:

*

*$b^i$ is the point intersecting the image plane of the line from $(0,1)^w$ to $c^w$ and

*$c^i$ is the point intersecting the image plane of the line from $(0,-1)^w$ to $c^w$.

Let's assume the tag is in view of the camera, that is, assume that $b^i,c^i∈[0,w]$.
Finally, let $R$ be a $2 \times 2$ rotation matrix such that the line with points $R[0,1]$, $R[0,-1]$ is perpendicular to the optical axis.
Note: $f^i$, $w^i$, $b^i$, $c^i$, and $d^i$ are expressed in pixels, not necessarily in the same unit scale as the x-y plane of the world frame and camera frame.
Problem: Given $f^i>0$, $w^i>0$, $b^i∈[0,w]$, $c^i∈[0,w]$, and $R∈ℝ^{2 \times 2}$, find:

*

*Camera position $c^w∈ℝ^2$ and

*A function mapping any point in world space into the camera image
plane: $$Ω:ℝ^2 → [0,w] : p^w → p^i$$
Bonus points:

*

*Generalize to any tag position $t$.

*Generalize to $n$ dimensions.

 A: First, it's convenient to refer to have a one-dimensional frame of reference originating from the center of the image plane $x^c = f$, rather than from the edge of it.  So define $d^i:=w^i/2$ and for all $p^i∈ℝ$, define $p_0^i:=p^i-d^i$ and $Ω_0(p^w):=Ω(p^w)-d^i$.
From another proof from Moving a pinhole camera we know that for some $p^w$ in world coordinates,
$Ω_0(p^w) = \dfrac{(0, 1) f R^T (p^w - c^w)} {(1, 0) R^T (p^w - c^w)}$.
Now that we have solved the second half of the problem, let's go back and solve the first half, that is, let's find $c^w$.
Let $R = 
\begin{bmatrix}
i & j\\
k & l
\end{bmatrix}$.  Since $R$ is a rotation matrix, $R^{-1}=R^T= 
\begin{bmatrix}
i & k\\
j & l
\end{bmatrix}$.
Plugging in $Ω_0((0,1)) = b_0^i$ and $Ω_0((0,-1)) = c_0^i$, we can solve for $c^w$:

*

*$b_0^i/f = \dfrac{jp_x^w-jc_x^w+lp_y^w-lc_y^w} {ip_x^w-ic_x^w+kp_y^w-kc_y^w}$ for $p^w = (0,1)$, and

*$c_0^i/f = \dfrac{jp_x^w-jc_x^w+lp_y^w-lc_y^w} {ip_x^w-ic_x^w+kp_y^w-kc_y^w}$ for $p^w = (0,-1)$
So,

*

*$b_0^i/f = \dfrac{-jc_x^w+l-lc_y^w} {-ic_x^w+k-kc_y^w}$

*$c_0^i/f = \dfrac{-jc_x^w-l-lc_y^w} {-ic_x^w-k-kc_y^w}$
So,

*

*$b_0^i * (-ic_x^w+k-kc_y^w) = f*(-jc_x^w+l-lc_y^w)$

*$c_0^i * (-ic_x^w-k-kc_y^w) = f*(-jc_x^w-l-lc_y^w)$
So,

*

*$-ib_0^ic_x^w+kb_0^i-kb_0^ic_y^w+jfc_x^w-lf+lfc_y^w=0$

*$-ic_0^ic_x^w-kc_0^i-kc_0^ic_y^w+jfc_x^w+lf+lfc_y^w=0$
So,

*

*$c_x^w(jf-ib_0^i)+c_y^w(lf-kb_0^i)+(kb_0^i-lf)=0$

*$c_x^w(jf-ic_0^i)+c_y^w(lf+kc_0^i)+(kc_0^i+lf)=0$
This is a system of linear equations which can be solved for $c_x^w$ and $c_y^w$ by standard methods.
QED.
Bonus:

*

*Using the above method we can plug in to $Ω_0$ arbitrary points bounding the tag which project to $b$ and $c$, respectively.

*For $n>2$ dimensions, the projection and tag are finite subsets of two $n-1$-dimensional affine hyperplanes, and $n$ points are required to define the tag which gives us $n$ equations to solve for the $n$ dimensions of the pinhole camera location, which yields a single solution if the setup is nondegenerate.

A: Let the normal of the image plane be
$\hat{n} =[\cos(\theta) , \sin(\theta), 0]^T $
Given the location of the pinhole $c = [c_x, c_y, 0]^T$ , we can construct
a frame attached to the camera, and with this frame
$ P = c + t R p $
where $p = [ p_x, p_y,  f]^T$  is the image coordinate vector with respect to this camera frame.
The matrix $R$ is given by
$R = \begin{bmatrix} 0 &&      -\sin \theta && \cos \theta \\
   0 &&        \cos \theta   &&  \sin \theta
\\      -1 &&             0  &&           0 \end{bmatrix}$
Following the derivation here
$p_i = \dfrac{1}{k^T R^T (P_i - c ) } f R^T (P_i - c)  $
so that
$(k^T R^T (P_i - c)) p_i = f R^T (P_i - c) $
where $k = [0, 0, 1]^T $
We're only concerned with the $y$ coordinates, hence
$ ( k^T R^T (P_i - c) ) j^T p_i = f j^T R^T (P_i - c) $
Hence,
$ R_3^T (P_i - c) (b_i) = f R_2^T (P_i - c) $
Where $R_k$ is the $k$-th column of $R$.  These are two linear equations in $c$, and given $\theta$ can be solved.
The linear system is
$ (f R_2^T - b_1 R_3^T) c = f R_2^T P_1 - R_3^T P_1 $
$ (f R_2^T - b_2 R_3^T) c = f R_2^T P_2 - R_3^T P_2 $
Using $P_1 = (0, 1, 0)$ and $P_2 = (0, -1, 0) $ and plugging in the components of $R_2$ and $R_3$, we get the linear system
$\begin{bmatrix} - f \sin(\theta) - b_1 \cos(\theta) && f \sin(\theta) - b_1 \sin(\theta) \\ - f \sin(\theta) - b_2 \cos(\theta ) && f \sin(\theta) - b_2 \sin(\theta) \end{bmatrix} \begin{bmatrix} c_x \\ c_y \end{bmatrix} = \begin{bmatrix} f \cos(\theta) - \sin(\theta) \\ -f\cos(\theta) + \sin(\theta) \end{bmatrix}$
As an explicit numerical example, suppose $\theta = 30^\circ$, and $ f = -1 $  (note that $f$ must be negative, see the figure attached to the question).  Also let the image of $P_1 = (0, 1, 0) $ be $p_1 = (0, 0.5, 0)$ and the image of $P_2 = (0, -1, 0) $ be $p_2 = (0, -0.1, 0) $
Then $b_1 = 0.5$ and $b_2 = -0.1$
Using these values in the above linear system, we get
$\begin{bmatrix} \sin(\theta) - 0.5 \cos(\theta) && - \sin(\theta) - 0.5 \sin(\theta) \\  \sin(\theta) +0.1 \cos(\theta ) && - \sin(\theta) + 0.1 \sin(\theta) \end{bmatrix} \begin{bmatrix} c_x \\ c_y \end{bmatrix} = \begin{bmatrix} - \cos(\theta) - \sin(\theta) \\ \cos(\theta) + \sin(\theta) \end{bmatrix}$
Using the values of $\sin(30^\circ) = \dfrac{1}{2} $ and $\cos(\theta) = \dfrac{\sqrt{3}}{2} $, the solution is
$ ( c_x , c_y ) = ( 4 , 2.178633 )$
