## Scale of extracted parameters (projecting matrix)

Moderator: Computer Vision

runaway
Erstie
Beiträge: 21
Registriert: 20. Apr 2006 18:06

### Scale of extracted parameters (projecting matrix)

Hello,

we are having some problems with the scale of our extracted parameters of the projecting matrix P.
As mentioned in the exercise slides, we are using the SVD on P because of the equation PC=0 to get C.

By plotting the result of the projected 3D X -Points using the parameters, we get the same image as with the original projection-matrix except of the scale.

What do we overlook?

Christoph Vogel
Erstie
Beiträge: 20
Registriert: 30. Mär 2010 17:38

### Re: Scale of extracted parameters (projecting matrix)

At first sight I am not sure what your problem is, therefore I ask some questions first.

1) When only the scale of the points is wrong here, you are probably very close to the solution. Is your conversion from homogeneous to cartesian coordinates doing the right thing? Your cartesian coordinates are the first three components of the homogeneous vector, with the fourth component equal to one.

2) Did you reconstruct the Projection matrix by using extracted parameters: K, R and C? How is the reconstructed projection matrices related to the original ? If only the scale is different, your reconstruction is correct.

Please describe the problem in more detail, if none of my questions is related to the problem.

Best regards,
Christoph

Marc Schmitt
Neuling
Beiträge: 7
Registriert: 29. Apr 2010 12:12

### Re: Scale of extracted parameters (projecting matrix)

Hi,

we calculated the calibration matrix K but captured weird results.
In our case the coefficent alpha_y = -alpha_x.

If we account that in backprojection we got the correct result. How could it that alpha_x = -alpha_y? Is that some problem with the RQ-decomposition as the RQ-Decomposition is not unique?

Thanks,
Zuletzt geändert von Marc Schmitt am 30. Jun 2010 16:47, insgesamt 2-mal geändert.

runaway
Erstie
Beiträge: 21
Registriert: 20. Apr 2006 18:06

### Re: Scale of extracted parameters (projecting matrix)

Yes. We reconstructed the projection matrix with our extracted parameters and used it for the projection of the 3d points. Our transformations (homogeneous <-> cartesian) should also be correct. If our fourth component does not equal 1, we divide the components by that value and then take the first three entries, right?

Our original matrix is:
cameraMatrix =
-0.0026 0.0071 -0.0114 -0.4893
-0.0120 0.0035 0.0066 0.8719
-0.0000 -0.0000 -0.0000 0.0025

The reconstructed one is:
P =
-0.0026 0.0071 -0.0114 -0.4893
-0.0120 0.0035 0.0066 0.8719
-0.6428 -0.7660 -0.0000 200.0000

We determined the parameter C in the same manner as we calculated P with the SVD of the Matrix A, except that this time we used SVD from P.
Besides the differing matrix values, the resulting plot looks correct, but is very small scaled.

Thanks.

Christoph Vogel
Erstie
Beiträge: 20
Registriert: 30. Mär 2010 17:38

### Re: Scale of extracted parameters (projecting matrix)

This is an answer to both questions.

At first the rq-decomposition is not uniquely defined.
As in the slides, if M = K*R, the following is also a valid decomposition:

K * D * D^-1 R

with D = (+- 1 0 0; 0 +-1 0; 0 0 +-1).

Since if K is an upper triangle, so is K * D.
If R is a unitary matrix, so is D * R. (R^t*R = Identity, R^t*D^t*D*R = Identity and D^t*R^t*R*D = Identity) as one can easily see.

Now we want to be consistent with the focal length. We assume that we have a positive focal length everywhere.
So both entries should be positive - in contrast to your decomposition.
(Both entries negative would also be ok, but we defined f to be positive at the start of the lecture)

So you should compensate that here.

Now the question of runaway.

the last row of your rebuild projection matrix has a different scale than the other two rows.
As a result, when converting back to cartesian coordinates, your projected points receive a different 'scale.'

Did you multiply the last row of K with a different factor than the other rows? You should not do that.

Best regards,
Christoph

Marc Schmitt
Neuling
Beiträge: 7
Registriert: 29. Apr 2010 12:12

### Re: Scale of extracted parameters (projecting matrix)

@Christoph
Thanks for clearing - it works.

@runaway
We got the same results as you did if we remove our normalization. You have to normalize your projection matrix P to the euclidean norm of the last row of M (see http://de.wikipedia.org/wiki/Projektion ... ionsmatrix for more details).

Hope we could help

JanEisklar
Mausschubser
Beiträge: 48
Registriert: 18. Okt 2007 13:29
Kontaktdaten:

### Re: Scale of extracted parameters (projecting matrix)

We also have the same problem and tried normalization.

This is our reconstructed matrix $$\mathbf{P}$$:
$$\mathbf{P}=\begin{bmatrix}0.0026 & -0.0071 & 0.0114 & 0.4893 \\0.0055 & -0.0112 & -0.0066 & 1.1354 \\-0.6428 & -0.7660 & 0 & 200\end{bmatrix}$$

The way I understood the wikipedia entry you posted we are supposed to compute the norm of $$m_3$$ and divide $$\mathbf{P}$$ by it.

$$m_3=\begin{bmatrix}-0.6428 & -0.7660 & 0\end{bmatrix}$$

$$||m_3||=\displaystyle\sqrt{\sum_im_{3,i}^2}=\displaystyle\sqrt{\sum\begin{bmatrix}0.4132 & 0.5868 & 0\end{bmatrix}}=\sqrt{1}=1$$

In other words the matrix that we get(which is similar to runaway's) is already normalized.

Obviously we are doing something wrong as the image we are seeing is badly scaled and rotated by 90° to the right.

Marc Schmitt
Neuling
Beiträge: 7
Registriert: 29. Apr 2010 12:12

### Re: Scale of extracted parameters (projecting matrix)

@JanEisklar

Sorry, I think you misunderstand me. It looks like you tried to normalize the reconstructed projection matrix P (from make_camera.m), but I've meaned that you have to normalize the computed projection matrix P before applying RQ-decomposition.

Sincerly,

Christoph Vogel
Erstie
Beiträge: 20
Registriert: 30. Mär 2010 17:38

### Re: Scale of extracted parameters (projecting matrix)

You do not have to do that before, you can also do the re-scaling after the rq-decomposition. I will shortly explain why that re-scaling is equivalent to the early re-scaling of P and why the re-scaling is helpful to get the principal point.

Rescaling is equivalent:

The reason is that the third row of K', the upper triangular matrix received from the rq-decomposition, is 0 except for the last entry K(3,3). So the last row of M, the first 3x3 Matrix of the projection matrix P, will be the last row of R, the orthonormal matrix received from the rq-decompostion times that last entry of K'.
So dividing P by the norm of the last row of M is equivalent to dividing K by the last entry of K, since the norm of the last row of R is 1 by definition of an orthonormal matrix.

Now you can read the principal point from the last column of K.

So you do not have to do the re-scaling before the rq-decomposition.

Christoph Vogel.

cdn
Mausschubser
Beiträge: 55
Registriert: 13. Dez 2008 13:54

### Re: Scale of extracted parameters (projecting matrix)

I am still not sure, what constraints we should assume to get rid of the ambiguity of the RQ-decomposition used in cameraParameters.m.
I suppose we should return a calibration matrix K with
$$K = \begin{bmatrix} f & 0 & p_x \\ 0 & f & p_y \\ 0 & 0 & 1 \end{bmatrix}$$, where $$f > 0$$.
Additionally a rotation matrix $$R$$ should be returned which holds $$P = \lambda\cdot K\cdot R$$ for some arbitrary $$\lambda \neq 0$$, since the scale of P is arbitrary.
To do that, is not a problem for me.
However what is about the thing with the right-handedness of $$R = \begin{bmatrix} r_1 & r_2 & r_3 \\ r_4 & r_5 & r_6 \\ r_7 & r_8 & r_9 \end{bmatrix}$$? Does that mean that the R we return should satisfy
$$\bigg( \begin{bmatrix}r_1 \\ r_4 \\ r_7 \end{bmatrix} \times \begin{bmatrix}r_2 \\ r_5 \\ r_8 \end{bmatrix}\bigg) \cdot \begin{bmatrix}r_3 \\ r_6 \\ r_9 \end{bmatrix} > 0$$? In my opinion this is not useful and additionally it is not possible for any valid Projection Matrix $$P$$ without violating one of the contraints above.
I really hope someone could clear things up for me

Christoph Vogel
Erstie
Beiträge: 20
Registriert: 30. Mär 2010 17:38

### Re: Scale of extracted parameters (projecting matrix)

You should return the orientation matrix, not the rotation. But that does not solve your problem here.

We have the knowledge that we have a right handed system.
Therefore we can verify that this is the case in our decomposition.

The rq-decomposition does not guarantee that the second matrix is a rotation matrix, but only that it is orthonormal.

Best regards,
Christoph Vogel

Ondori
Mausschubser
Beiträge: 89
Registriert: 28. Okt 2006 19:50

### Re: Scale of extracted parameters (projecting matrix)

We calculated the same matrices as runaway, so our norm is either 0 (calculated from last row of m before recronstruction) or 1 (after reconstruction)...I'm lost, help?