\documentclass[12pt,a4paper]{article}

\usepackage{amstext}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{stmaryrd}
\usepackage{enumerate}
\usepackage{alltt}
\usepackage[latin1]{inputenc}
\usepackage{cancel}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{wasysym}
\usepackage{rotating}
\usepackage{pifont}

\title{}
\author{}
\date{}

\pagestyle{fancy}

\lhead{Assignment 8}
\chead{}
\rhead{}
\lfoot{COPCV}
\cfoot{Page \thepage}
\rfoot{SS 2009}

\begin{document}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\newcommand{\exercise}[1]{\subsection{#1}}
\renewcommand{\theenumi}{\textbf{\alph{enumi}}}

\newcommand{\AND}{\ensuremath{\wedge}}
\newcommand{\OR}{\ensuremath{\vee}}
\newcommand{\SetR}{\ensuremath{\mathbb{R}}}
\newcommand{\SetN}{\ensuremath{\mathbb{N}}}
\newcommand{\SetC}{\ensuremath{\mathbb{C}}}
\newcommand{\SetZ}{\ensuremath{\mathbb{Z}}}
\newcommand{\SetQ}{\ensuremath{\mathbb{Q}}}
\newcommand{\SetB}{\ensuremath{\mathbb{B}}}
\newcommand{\QED}{\ensuremath{\hspace*{\fill}\square}}
\newcommand{\FLASH}{\ensuremath{\hspace*{\fill}\lightning}}
\newcommand{\OnotO}{\ensuremath{\mathcal{O}}}
\newcommand{\bild}[2]{
	\begin{figure}[htpb]
		\centering
			\includegraphics[#1]{#2}\\[0.2cm]
	\end{figure}
	}

\newcommand{\m}[1]{\begin{pmatrix}#1\end{pmatrix}}
\newcommand{\+}{\phantom{-}}
\newcommand{\f}{\frac}

\newcommand{\XMARK}{\ding{56}}
\newcommand{\CMARK}{\ding{52}}

%\maketitle

%\thispagestyle{empty}

%\newpage
\setcounter{page}{1}
\setcounter{section}{8}

\exercise{Fundamental Matrix}
We have the epipolar constraint:
$$\tilde{m_2} F \tilde{m_1} = 0 = \left(\begin{array}{c}u_2 \\ v_2 \\ 1\end{array}\right)^\top F \left(\begin{array}{c}u_1 \\ v_1 \\ 1\end{array}\right).$$
Reformulating this, we get
\begin{eqnarray*}
		0 & = & \left(\begin{array}{c}2 \hat{u_2} \\ 2 \hat{v_2} \\1\end{array}\right)^\top F \left(\begin{array}{c}2 \hat{u_1} \\ 2 \hat{v_1} \\ 1\end{array}\right) \\
		& = & \left(\left(\begin{array}{ccc}2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1\end{array}\right)\left(\begin{array}{c}\hat{u_2} \\ \hat{v_2} \\ 1\end{array}\right)\right)^\top F \left(\left(\begin{array}{ccc}2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1\end{array}\right)\left(\begin{array}{c}\hat{u_1} \\ \hat{v_1} \\ 1\end{array}\right)\right) \\
		& = & \left(\begin{array}{c}\hat{u_2} \\ \hat{v_2} \\ 1\end{array}\right)^\top \left(\begin{array}{ccc}2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1\end{array}\right)^\top F \left(\begin{array}{ccc}2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1\end{array}\right) \left(\begin{array}{c}\hat{u_1} \\ \hat{v_1} \\ 1\end{array}\right) \\
		& = & \left(\begin{array}{c}\hat{u_2} \\ \hat{v_2} \\ 1\end{array}\right)^\top \underbrace{\left(\begin{array}{ccc}4 f_{11} & 4 f_{12} & 2 f_{13} \\ 4 f_{21} & 4 f_{22} & 2 f_{23} \\ 2 f_{31} & 2 f_{32} & f_{33}\end{array}\right)}_{\hat{F}} \left(\begin{array}{c}\hat{u_1} \\ \hat{v_1} \\ 1\end{array}\right)
\end{eqnarray*}
We also know
$$F = A_{int,2}^{-\top} [t]_\times R A_{int,1}^{-1}$$
with
$$A_{int} = \left(\begin{array}{ccc}k_u & -k_u \cot \varphi & u_0 \\ 0 & k_v / \sin \varphi & v_0 \\ 0 & 0 & 1\end{array}\right).$$
Remark: $k_u$ and $k_v$ are measured in $\frac{pix}{m}$. \\
With $\hat{k_u} = \frac{1}{2} k_u$ and $\hat{k_v} = \frac{1}{2} k_v$, we get
\begin{eqnarray*}
		\hat{A_{int}} & = & \left(\begin{array}{ccc}\hat{k_u} & -\hat{k_u} \cot \varphi & \hat{u_0} \\ 0 & \hat{k_v} / \sin \varphi & \hat{v_0} \\ 0 & 0 & 1\end{array}\right) \\
		& = & \left(\begin{array}{ccc}\frac{1}{2} k_u & -\frac{1}{2} k_u \cot \varphi & \frac{1}{2} u_0 \\ 0 & \frac{1}{2} k_v / \sin \varphi & \frac{1}{2} v_0 \\ 0 & 0 & 1\end{array}\right) \\
		& = & \left(\begin{array}{ccc}\frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{2} & 0 \\ 0 & 0 & 1\end{array}\right) A_{int} \\
		\hat{A_{int}}^{-1} & = & \left(\left(\begin{array}{ccc}\frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{2} & 0 \\ 0 & 0 & 1\end{array}\right) A_{int}\right)^{-1} \\
		& = & A_{int}^{-1} \left(\begin{array}{ccc}2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1\end{array}\right)
\end{eqnarray*}

\exercise{Stereo Reconstruction}
\begin{enumerate}
	\item We have
		\begin{eqnarray*}
			A_1^{int} = A_2^{int} & = & \left(\begin{array}{cc|c}1 & 0 & 10 \\ 0 & 1 & 0 \\ \hline 0 & 0 & 1\end{array}\right) \\[0.3cm]
			\left(A_1^{int}\right)^{-1} = \left(A_2^{int}\right)^{-1} & = & \left(\begin{array}{cc|c}1 & 0 & -10 \\ 0 & 1 & 0 \\ \hline 0 & 0 & 1\end{array}\right) \\[0.3cm]
			A_1^{ext} & = & \left(\begin{array}{ccc|c}1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ \hline 0 & 0 & 0 & 1\end{array}\right) \\[0.3cm]
			A_2^{ext} & = & \left(\begin{array}{ccc|c}\frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 0 & -4 \\ \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 & 0 \\ 0 & 0 & 1 & 0 \\ \hline 0 & 0 & 0 & 1\end{array}\right)
		\end{eqnarray*}
		In general, it holds:
		\begin{eqnarray*}
			A & = & \left(\begin{array}{c|c}R^{3 \times 3} & t^3 \\ \hline 0^{3^\top} & 1\end{array}\right) \\[0.3cm]
			A^{-1} & = & \left(\begin{array}{c|c}R^{-1} & R^{-1} t \\ \hline 0^{3^\top} & 1\end{array}\right)
		\end{eqnarray*}
		It follows from this fact
		$$\left(A_2^{ext}\right)^{-1} = \left(\begin{array}{ccc|c}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 & \frac{4}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 & -\frac{4}{\sqrt{2}} \\ 0 & 0 & 1 & 0 \\ \hline 0 & 0 & 0 & 1\end{array}\right)$$
	\item The "roadmap" looks as follows:
		\begin{center}
		\begin{tabular}{cl}
			3-D world coordinates \\
			$\downarrow$ & extrinsic parameters \\
			3-D camera coordinates \\
			$\downarrow$ & projection step \\
			2-D image coordinates \\
			$\downarrow$ & intrinsic parameters \\
			2-D pixel coordinates
		\end{tabular}
		\end{center}
		Given 2-D Euclidean coordinates
		\begin{eqnarray*}
			x_1 & = & (10.5, 0.5)^\top \\
			x_2 & = & \left(9.5, \frac{1}{\sqrt{2}}\right)^\top
		\end{eqnarray*}
		we have to go to 2-D homogeneous coordinates
		\begin{eqnarray*}
			\hat{x_1} & = & (10.5, 0.5, 1)^\top \\
			\hat{x_2} & = & \left(9.5, \frac{1}{\sqrt{2}}, 1\right)^\top
		\end{eqnarray*}
		\begin{eqnarray*}
			\left(A_1^{int}\right)^{-1} \hat{x_1} & = & \left(\begin{array}{ccc}1 & 0 & -10 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{array}\right) \left(\begin{array}{c}10.5 \\ 0.5 \\ 1\end{array}\right) \\
			& = & \left(\begin{array}{c}0.5 \\ 0.5 \\ 1\end{array}\right) \\
			\left(A_2^{int}\right)^{-1} \hat{x_2} & = & \left(\begin{array}{ccc}1 & 0 & -10 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{array}\right) \left(\begin{array}{c}9.5 \\ \frac{1}{\sqrt{2}} \\ 1\end{array}\right) \\
			& = & \left(\begin{array}{c}-0.5 \\ \frac{1}{\sqrt{2}} \\ 1\end{array}\right)
		\end{eqnarray*}
		Let's go to the 3-D camera coordinates ($\rightarrow$ 3-D Euclidean coordinates):
		\begin{eqnarray*}
			X_1 & = & \lambda_1 \left(\begin{array}{c}0.5 \\ 0.5 \\ 1\end{array}\right) \quad , \lambda_1 \in \SetR \quad \quad \leftarrow \text{seen from first camera} \\
			X_2 & = & \lambda_2 \left(\begin{array}{c}-0.5 \\ \frac{1}{\sqrt{2}} \\ 1\end{array}\right) \quad , \lambda_2 \in \SetR \quad \; \leftarrow \text{seen from the second camera}
		\end{eqnarray*}
		Remark: Do not intersect these two points! They live in different coordinate systems!
	\item Let's go to 3-D homogeneous coordinates:
		\begin{eqnarray*}
			\hat{X_1} & = & (0.5 \lambda_1, 0.5 \lambda_1, \lambda_1, 1)^\top \\
			\hat{X_2} & = & \left(-0.5 \lambda_2, \frac{1}{\sqrt{2}} \lambda_2, \lambda_2, 1\right)^\top
		\end{eqnarray*}
		Now, we can go to 3-D world coordinates:
		\begin{eqnarray*}
			\left(A_1^{ext}\right)^{-1} \hat{X_1} & = & \left(\begin{array}{cccc}1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{array}\right) \left(\begin{array}{c}0.5 \lambda_1 \\ 0.5 \lambda_1 \\ 1\end{array}\right) \\
			& = & \left(\begin{array}{c}0.5 \lambda_1 \\ 0.5 \lambda_1 \\ \lambda_1 \\ 1\end{array}\right) \\
			\left(A_2^{ext}\right)^{-1} \hat{X_2} & = & \left(\begin{array}{cccc}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 & \frac{4}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 & -\frac{4}{\sqrt{2}} \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{array}\right) \left(\begin{array}{c}-0.5 \lambda_2 \\ \frac{1}{\sqrt{2}} \lambda_2 \\ \lambda_2 \\ 1\end{array}\right) \\
			& = & \left(\begin{array}{c}\frac{2 - \sqrt{2}}{4} \lambda_2 + 2 \sqrt{2} \\ \frac{2 + \sqrt{2}}{4} \lambda_2 - 2 \sqrt{2} \\ \lambda_2 \\ 1\end{array}\right)
		\end{eqnarray*}
	\item 3-D Euclidean is now
		\begin{eqnarray*}
			L_1 & = & \lambda_1 \left(\begin{array}{c}0.5 \\ 0.5 \\ 1\end{array}\right) \quad , \lambda_1 \in \SetR \\
			L_2 & = & \lambda_2 \left(\begin{array}{c}\frac{2 - \sqrt{2}}{4} \\ \frac{2 + \sqrt{2}}{4} \\ 1\end{array}\right) + \left(\begin{array}{c}2 \sqrt{2} \\ -2 \sqrt{2} \\ 0\end{array}\right) \quad , \lambda_2 \in \SetR
		\end{eqnarray*}
		These two lines can now be intersected since they live in the same coordinate system:
		\begin{eqnarray*}
			\lambda_1 \left(\begin{array}{c}0.5 \\ 0.5 \\ 1\end{array}\right) & = & \lambda_2 \left(\begin{array}{c}\frac{2 - \sqrt{2}}{4} \\ \frac{2 + \sqrt{2}}{4} \\ 1\end{array}\right) + \left(\begin{array}{c}2 \sqrt{2} \\ -2 \sqrt{2} \\ 0\end{array}\right) \begin{array}{l} \\ \\ \leftarrow \text{ tells } \lambda_1 = \lambda_2\end{array} \\
			\lambda_1 \left(\begin{array}{c}\frac{\sqrt{2}}{4} \\ -\frac{\sqrt{2}}{4} \\ 0\end{array}\right) & = & \left(\begin{array}{c}2 \sqrt{2} \\ -2 \sqrt{2} \\ 0\end{array}\right) \\
			\Rightarrow \lambda_1 = \lambda_2 & = & 8
		\end{eqnarray*}
		$M_w = (4,4,8)^\top$: The depth of this point is 8.
\end{enumerate}

\end{document}
