## Revision 3784b728a96d70eff70af10000703e72c2e3ce4d (click the page title to view the current version)

# Distorted Space

**Briefing** Distorted Lecture

**Additional Reading** Chapter 9 in *OpenCV 3 Computer Vision with Python Cookbook* by Alexey Spizhevoy (author). Search for it in Oria. There is an e-book available.

# Exercises

## An Example of a Distorted space

### Step 1. Preliminaries.

- Consider a triangle in the object space, formed by the three vertices, \(A=(0,0,10)\), \(B=(20,0,10)\), and \((20,10,10)\).

Let- \(\alpha\) be the angle between the vectors \(\overrightarrow{AB}\) and \(\overrightarrow{AC}\).
- \(\beta\) be the angle between the vectors \(\overrightarrow{BA}\) and \(\overrightarrow{BC}\).
**Draw**a figure to show this information.

**Calculate**the angles \(\alpha\) and \(\beta\).- Consider an ideal perspective camera, posed such that the camera frame matches the world frame.

**Calculate**the image points corresponding to \(A\), \(B\), and \(C\). Assume that the image plane has \(z=1\).**Draw**an image to display this projection. **Calculate**the angles \(\alpha'\) and \(\beta'\) in the image, corresponding to \(\alpha\) and \(\beta\). Do they match the original angles?**Calculate**the lengths of the edges of the triangles in the image.- Make a new drawing of the image plane, displaying the quantities calculated in 4 and 5. Keep it for later reference.

Recall the formula for the angle \(\theta\) between two vectors \(u\) and \(v\) \[\theta = \cos^{-1}\frac{u\cdot v}{||u||\cdot||v||}.\] This is found in any elementary calculus book. You did not need this above, because the triangles had an orthogonal angle, but you will need it below.

### Step 2. Distortion.

Suppose the camera is not ideal, but instead has calibration matrix \[K = \begin{bmatrix} 2 & \frac1{\sqrt{3}} & 4 \\ 0 & 1 & 4 \\ 0 & 0 & 1 \end{bmatrix}\]

**Calculate**the image points corresponding to \(A\), \(B\), and \(C\), using the camera calibration matrix \(K\). (See Ma 2004:55)**Draw**the resulting image to scale.**Calculate**the lengths of the edges of the image of the triangle. For now, we use the familiar formulæ for vector norms.- Let \(\alpha'\) and \(\beta'\) be the images of the angles \(\alpha\) and \(\beta\).
**Calculate**these to image angles and add the information to you figure. - Compare your distorted image to the original image from Step 1.

### Step 3. The Distorted Inner Product Space

Recall the textbook’s definition of an inner product in distorted space \[\langle u,v\rangle_S = u^TSv \quad\text{where } S = K^{-T}K^{-1},\] for some `camera calibration’ matrix \(K\). We are going to redo Step 2, using this distorted inner product.

- [9] Calculate the edges (norms) of the triangle, using the distorted inner product to define the norm.
- [10] Calculate the angles \(\alpha'\) and \(\beta'\), using the distorted inner product and the formula \[\theta = \tan^{-1}\frac{u\cdot v}{||u||\cdot||v||}.\]
- Make a figure illustrating the quantities calculated.
- [11] Compare the edges and angles thus calculated with the calculations from Step 2 and from Step 1.

Reflect on your observations.

### Step 4. Reflection

Think through the following:

- What does this exercise tell you about camera distortion and inner product spaces?
- Is there anything you do not quite understand? Is there something missing in the exercise, something that should have been tested?

## From the Textbook

- Exercise 6.4

# Debrief

- Step 1
**TODO**Scan notes - Step 2(7-10)
**TODO**Scan notes - Step 2(11)
- Note how the \(x\)-axis is stretched, doubling the length of \(AB\).
- Not also how it is skewed, bending the angle \(\beta'\) from \(90°\) to \(120°\).