Question
I have an ellipsoid described by a covariance matrix $\Sigma \in \mathbb{R}^{3\times3}$ and its centroid location $\mu \in \mathbb{R}^{3}$ (yes; notation from statistics as I want to interpret it as a Gaussian later). I want to obtain the projection of it in a geometry given by the projective mapping $P \in \mathbb{R}^{3\times4}$. Within the constraint geometrical setup detailed later, i believe the conic projection should be an ellipse again and that should be expressable with a 2D ($\Sigma, \mu$).
Available as Notebook.
Approach so far
I followed this answer but had no luck transferring the approach to a non-parrallel projection using a quadric where the translation is non-zero.
homogenous represention of quadric
I start by expressing the ellipsoid as a quadric following the answer in [4]. A quadric is described by a symmetrical $4\times4$ matrix $Q$:
$$\hat{\mathbf x}^T\mathtt Q\hat{\mathbf x} = \begin{bmatrix}\mathbf x&1\end{bmatrix} \begin{bmatrix}\mathtt A & \mathbf b \\ \mathbf b^T & c\end{bmatrix} \begin{bmatrix}\mathbf x\\1\end{bmatrix} = 0.$$
I plug in the covariance and mean vector for the respective variables in $Q$ to yield:
$$\mathtt Q = \begin{bmatrix}\mathtt \Sigma & \mathbf \mu \\ \mathbf \mu^T & -1\end{bmatrix}.$$
construction of projection matrix
I want to create projection matrices that describe a projective geometry given by the focal length $f$, the pierce point $(p_x, p_y)$ the source position $C$ and a camera rotation $R_c$. I obtain the projection matrix $P$ following [1]:
$$ P= \begin{bmatrix} f & 0 & p_{x} \\ 0 & f & p_{y} \\ 0 & 0 & 1 \end{bmatrix} \times \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0 \end{bmatrix} \times \begin{bmatrix} \mathtt R_{c}^T & -R_{c}^TC \\ \mathtt 0 & 1 \end{bmatrix} $$
projection of quadric
I followed the answer in [4] which quotes the book [2] Hartley Zisserman chapter 8.3 to get this simple formula for the projection of the quadric $Q$ onto the conic $C$:
$$\mathtt C^*=\mathtt P\mathtt Q^*\mathtt P^T$$
The dual-forms (asterisk) are obtained by the use of the inverse ($C^{*}=C^{-1}$):
$$C = (PQ^{-1}P^T)^{-1}$$
Example
The projective geometry is given by $f=3718$, $C=[0, 0, -1987]^T$, $R=I$. This describes a camera looking into positive z-direction sitting at some point on the z-axis.
I define an ellipsoid aligned with the coordinate axis with dimensions $(300, 100, 100)$ and position $(255.5, 255.5, 255.5)$:
$$\mathtt Q = \begin{bmatrix} 300 & 0 & 0 & 255.5 \\ 0 & 100 & 0 & 255.5 \\ 0 & 0 & 100 & 255.5 \\ 255.5 & 255.5 & 255.5 & -1 \end{bmatrix},$$
To verify the formulation of the quadric, I generate a set of points on the unit-sphere and multiply them with the quadric $\hat{x}'=Q\hat{x}$. The set of points traces out the desired ellipsoid nicely.
To verify the projection matrices, I project these points onto the detector. The resulting scatter plot looks convincing.
To test if the computed Conic is valid, I create points on the unit-circle and multiply them with the conic $\hat{u}'=C\hat{u}$. This however looks false. I observe, that the Covariance of the projected conic is almost zer0.
Does someone have a clue what could be going wrong? Is the theory consistent, or am I missing something important?
Sources
[1]: Construct Projection Matrix, https://ksimek.github.io/2012/08/22/extrinsic/
[2]: Hartley & Zisserman, Multiple View Geometry In Computer Vision, 2004
[3]: Project Quadric onto Conic, https://math.stackexchange.com/a/2757064
[4]: Construct Quadric from Cov and mean, https://math.stackexchange.com/a/3201266/1018514