# Calculating measurement covariance matrix for Kalman filter

I want to use a bayesian framework to correct the pose of a vehicle described by the following state vector $$X=\begin{bmatrix} x\\ y\\ \theta \end{bmatrix}$$

where $x$ and $y$ are the coordinates in the $XY$ plane and $\theta$ is the heading angle.

The measurement is acquired by a place recognition algorithm, where an online acquired image is compared to a set of database images and the best match is returned. Each image in the database is associated with a pose $(x,y,\theta)$ where this image has been acquired. So for any image, the algorithm will return an image from the database of index $1\leq j \leq N$, $N$ is the number of database images. I want to associate a covariance matrix to the measurement (pose $(x_{j},y_{j},\theta_{j})$ associated to image $j$).

Could the covariance be calculated using the deviation matrix where we consider each pose associated to an image as an observation as follows

$$Z = \begin{matrix} x & y & \theta\\ z_{1} 0.0052 & 0.7068 & 0.0104\\ z_{2} 0.0052 & 0.7068 & 0.0104\\ z_{3}0.7063 & 0.0050 & 0.0305\\ \vdots &\vdots &\vdots\\ z_{N}0.0113 & 0.0168 & 0.0002\\ \end{matrix}$$ or the covariance has to be in the following form? $$C = \begin{bmatrix} \sigma_{x}^2 & 0 & 0\\ 0 & \sigma_{y}^2 &0\\ 0 &0 & \sigma_{\theta}^2 \end{bmatrix}$$