<p>This is the <a href="https://en.wikipedia.org/wiki/Camera_resectioning" rel="nofollow noreferrer">Camera re-sectioning problem</a>. </p>

<p>We need to have a few points, like the end points of the walls, to take the roles of x<sub>w</sub>, y<sub>w</sub> and z<sub>w</sub> in the following equation:</p>

<p><a href="https://i.sstatic.net/qXr4W.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qXr4W.png" alt="enter image description here"></a></p>

<p>Here A is defined as:</p>

<p><a href="https://i.sstatic.net/Xs4BR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Xs4BR.png" alt="enter image description here"></a></p>

<p>These are the values of the camera itself.</p>

<p>R and T are defined as the Rotation and Translation matrices for the camera, and are the values we need to solve for. The position, C, of the camera expressed in world coordinates is C = -R<sup>-1</sup>T = -R<sup>T</sup> T .</p>

<p>The linked Wikipedia article mentions a few algorithms to solve these equations.</p>

<p>An example of a practical application of these is also found on <a href="https://math.stackexchange.com/questions/82602/how-to-find-camera-position-and-rotation-from-a-4x4-matrix">Math Stack Exchange</a>.</p>

<p>Another example, with some code samples that you may want to use, is found <a href="https://stackoverflow.com/questions/76134/how-do-i-reverse-project-2d-points-into-3d">Stack Overflow</a>.</p>

CC BY-SA 3.0
2015-08-13T12:25:00.457Z
2015-08-13T12:25:00.457Z
2017-05-23T12:39:19.850Z
S.L. Barth is on codidact.com
<p>Say I've got a photograph of a scene, and measurements for part of it (eg. a room where I know the dimensions of the walls).  Assuming a rectilinear lens, how would I go about setting up a virtual camera so that 3D objects are rendered as if they were in the physical scene?</p>

<rendering>
Matching a virtual camera to a physical camera
Mark
# Matching a virtual camera to a physical camera

(Asked by: username_0 on 2015-08-13)

Say I've got a photograph of a scene, and measurements for part of it (eg. a room where I know the dimensions of the walls). Assuming a rectilinear lens, how would I go about setting up a virtual camera so that 3D objects are rendered as if they were in the physical scene?

**Tags:** rendering


---

## 1 answers

### Answer by username_1 on 2015-08-13. Score: 5 | Accepted answer

This is the [Camera re-sectioning problem](https://en.wikipedia.org/wiki/Camera_resectioning).

We need to have a few points, like the end points of the walls, to take the roles of xw, yw and zw in the following equation:

[![enter image description here](https://i.sstatic.net/qXr4W.png)](https://i.sstatic.net/qXr4W.png)

Here A is defined as:

[![enter image description here](https://i.sstatic.net/Xs4BR.png)](https://i.sstatic.net/Xs4BR.png)

These are the values of the camera itself.

R and T are defined as the Rotation and Translation matrices for the camera, and are the values we need to solve for. The position, C, of the camera expressed in world coordinates is C = -R-1T = -RT T .

The linked Wikipedia article mentions a few algorithms to solve these equations.

An example of a practical application of these is also found on [Math Stack Exchange](https://math.stackexchange.com/questions/82602/how-to-find-camera-position-and-rotation-from-a-4x4-matrix).

Another example, with some code samples that you may want to use, is found [Stack Overflow](https://stackoverflow.com/questions/76134/how-do-i-reverse-project-2d-points-into-3d).


---

