\documentclass[a4paper,12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{graphicx} %BIlder einbinden
\usepackage{amsmath} %erweiterte Mathe-Zeichen
\usepackage{amsfonts} %weitere fonts
\usepackage[utf8]{inputenc} %Umlaute & Co
\usepackage{hyperref} %Links
\usepackage{ifthen} %ifthenelse
\usepackage{enumerate}
\usepackage{pdfpages}
\usepackage{algpseudocode} %Pseudocode
\usepackage{dsfont} % schöne Zahlenräumezeichen
\usepackage{amssymb, amsthm} %noch stärker erweiterte Mathe-Zeichen
\usepackage{tikz} %TikZ ist kein Zeichenprogramm
\usetikzlibrary{trees,automata,arrows,shapes}

\pagestyle{empty}


\topmargin-50pt

\newcounter{aufgabe}
\def\tand{&}

\newcommand{\makeTableLine}[2][0]{%
  \setcounter{aufgabe}{1}%
  \whiledo{\value{aufgabe} < #1}%
  {%
    #2\tand\stepcounter{aufgabe}%
  }
}

\newcommand{\aufgTable}[1]{
  \def\spalten{\numexpr #1 + 1 \relax}
  \begin{tabular}{|*{\spalten}{p{1cm}|}}
    \makeTableLine[\spalten]{A\theaufgabe}$\Sigma$~~\\ \hline
    \rule{0pt}{15pt}\makeTableLine[\spalten]{}\\
  \end{tabular}
}

\def\header#1#2#3#4#5#6#7{\pagestyle{empty}
\begin{minipage}[t]{0.47\textwidth}
\begin{flushleft}
{\bf #4}\\
#5
\end{flushleft}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{flushright}
#6 \vspace{0.5cm}\\
%                 Number of Columns    Definition of Columns      second empty line
% \begin{tabular}{|*{5}{C{1cm}|}}\hline A1&A2&A3&A4&$\Sigma$\\\hline&&&&\\\hline\end{tabular}\\\vspace*{0.1cm}
\aufgTable{#7}
\end{flushright}
\end{minipage}
\vspace{1cm}
\begin{center}
{\Large\bf Assignment #1}

{(Hand-in date #3)}
\end{center}
}



%counts the exercisenumber
\newcounter{n}

%Kommando für Aufgaben
%\Aufgabe{AufgTitel}{Punktezahl}
\newcommand{\Aufgabe}[2]{\stepcounter{n}
\textbf{Exercise \arabic{n}: #1} (#2 Punkte)\\}




\begin{document}
    %\header{BlattNr}{Tutor}{Abgabedatum}{Vorlesungsname}{Namen}{Semester}{Anzahl Aufgaben}
    \header{6}{}{2015-06-16}{Mobile Robots}{
    	\textit{Jan-Peter Hohloch}\\ \textit{Maximus Mutschler}
    }{SS 15}{3}
    \vspace{1cm}

	\Aufgabe{Essential Matrix}{8}
	\begin{enumerate}[(a)]
		\item  $^LT_R= \begin{pmatrix}
		0.9811 &-0.1736 &0.0858& 0.1000\\
		0.1730 &0.9848 &0.0151& 0\\
		-0.0872& 0 &0.9962& 0\\
		0 &0 &0 &1.0000
		\end{pmatrix}\\
		R=	\begin{pmatrix}
		0.9811 &-0.1736 &0.0858\\
		0.1730 &0.9848 &0.0151\\
		-0.0872& 0 &0.9962\\
		\end{pmatrix}\\
		t=\begin{pmatrix}
		0.1&0&0
		\end{pmatrix}\\
		\left[t\right] = \begin{pmatrix}
		0&0&0\\
		0&0&-0.1\\
		0&0.1&0
		\end{pmatrix}\\
		E= \left[t\right] \times R= \begin{pmatrix}
		0&0&0\\
		0.00872&0&-0.09962\\
		0.01730&0.09848&0.00151\\
		\end{pmatrix}
		$
		\item match if $p^T_L\cdot E\cdot p_R=0\\
		p_L= \begin{pmatrix}
		0.46&0.27&1.00
		\end{pmatrix}
		$\begin{itemize}
		\item $p_{R,1}\rightarrow \begin{pmatrix}
		0.46&0.27&1.00
		\end{pmatrix}
	\begin{pmatrix}
	0&0&0\\
	0.00872&0&-0.09962\\
	0.01730&0.09848&0.00151\\
	\end{pmatrix}
		\begin{pmatrix}
		0.30\\0.20\\1.00
		\end{pmatrix}
		=0.0020492\rightarrow$ match\\
		\item $p_{R,2}\rightarrow p_l\cdot E
		 \begin{pmatrix}
		 0.26\\0.21\\1.0
		 \end{pmatrix}=0.00040354
		\rightarrow$ match\\
	\item $p_{R,3}\rightarrow  p_l\cdot E
			 \begin{pmatrix}
			 -0.25\\-0.10\\1.00
			 \end{pmatrix}=-0.040149
			\rightarrow$  no match\end{itemize}

	\item $(K^{-1} v_R)^T\cdot E\cdot K^{-1}v_L = v_R^{T}\cdot \left(K^{-1}\right)^T\cdot E\cdot K^{-1} \cdot v_L\\
	E= K^T\cdot F\cdot K	\\
	F= \left(K^{-1}\right)^T\cdot E\cdot K^{-1}$\\
	K = calibration matrix of the cameras
	\item
	$
	K=\begin{pmatrix}
	500&0&320\\
	0&500&240\\
	0&0&1
	\end{pmatrix}
	$\\$
	c_{R0}= K\cdot \begin{pmatrix}
		0.3&0.2&1.0
	\end{pmatrix}^T = \begin{pmatrix}
	470\\
	340\\
	1
	\end{pmatrix}\\
	c_{R1}= K\cdot \begin{pmatrix}
		0.26&0.21&1.0
	\end{pmatrix}^T= \begin{pmatrix}
	450\\
	345\\
	1
	\end{pmatrix}\\
	c_{R2}=K\cdot \begin{pmatrix}
		-0.25&-0.1&1.0
	\end{pmatrix}^T = \begin{pmatrix}
	195\\
	190\\
	1
	\end{pmatrix}
	$
	Epipolar Line: $ 
	c_{L}^T\cdot F \cdot c_{R}=0\\
	\Leftrightarrow \begin{pmatrix}
		a&b&c
	\end{pmatrix} \cdot \begin{pmatrix}
		x \\y\\1
	\end{pmatrix}=0\\
	\Leftrightarrow
	y=-\dfrac{a}{b}x-\dfrac{c}{b}\\
	y=-0.2x+432.761\\
	$
	Figure look at Figure \ref{fig:points}
	\begin{figure}[!htb]
		\centering
		\includegraphics[width=0.7\linewidth]{points}
		\caption{coordinate points and epipolar line}
		\label{fig:points}
	\end{figure}

	\end{enumerate}
	\Aufgabe{RANSAC}{4}
	\begin{enumerate}[(a)]
		\item  $
		k=\dfrac{log(1-p)}{log(1(1-\epsilon)^s)}\\
		p=0.99\\
		s_1=4, s_2=6, s_3=7\\
		\begin{tabular}{c||llllllllll}
			 outlier ratio  & 0.1  &0.2  &0.3  &0.4  &0.5  &0.6  &0.7  &0.8  &0.9    \\ \hline
			s1=4& 5 & 9 & 17 & 34 & 72 & 178 & 567  & 2876  & 4650     \\
			s2=5 & 6 & 12 &26  &57  &146  &448  &1893  &14389  &460515    \\
			s3=7 & 8 &20  & 54 &163  &588  &2809  &21055  &359777  &46051700
		\end{tabular}
		$
		\item A: 4 datapoints 150ns a iteration\\
		B: 5 datapoints 40ns a iteration\\
		$p=0.99\\
		\eta = 0.7\\
		k_A= 567\\
		k_B=1893\\
		k_A\cdot t_A=567\cdot 140ns=79380ns\\
        k_B\cdot t_B=1893\cdot 40ns= 75720ns$\\
        So the time for computation of B is smaller even with more points needed. So we choose B because of a faster computation time. If we are short for points however we should use A even though it takes more time.

	\end{enumerate}
	\Aufgabe{Stereo Vision}{8}
	\begin{enumerate}[(a)]
		\item  As $d_{max}$ increases $z_b$ decreases. So $d_{max}$ sets a lower bound. For $d$ approaching 0 $z_b$ approaches infinity, so there is no upper bound set by a fixed $d_{max}$\\
		$z_{p,min}=\frac{f\cdot b}{d_{max}}=\frac{512px\cdot10cm}{64px}=\frac{2^9}{2^6}\cdot10cm=80cm$
		\item
		$  d \sim N(d_{true},\sigma_d)$\\
		 $z_{p}(d)=\frac{f\cdot b}{d}$\\
		TaylorApprox:\\$z_p(d)=z(d_{true})+z'(d_{true})(d-d_{true})=\frac{f\cdot b}{d_{true}}- \frac{f\cdot b}{d_{true}^2}(d-d_{true})= \frac{2f\cdot b}{d_{true}}-\frac{f\cdot b}{d_{true}^2}\cdot d\\
		\sigma_z= |A|\cdot \sigma_d =  \frac{f\cdot b}{d_{true}^2}\cdot \sigma_d= \frac{f\cdot b}{\frac{f^2\cdot b^2}{z_p^2}}\cdot \sigma_d= \frac{z_p^2}{f\cdot b}\sigma_d  \\
	%	$faster: $\sigma = z'(d_{true})|\cdot \sigma_{alt}
		$
		\item see b)
		\item $f=512px \\
		b=5cm\\
		\sigma_d=0.5px\\
		z_p=500cm\\
		\sigma_z= \frac{500^2}{512\cdot5}\cdot 0.5=\frac{500^2}{512\cdot 2}\approx 244.1cm
		$
		\item $\sigma_{z}=5cm\\
		b=\frac{z_p^2}{f\cdot o_z}\sigma_d= \frac{500^2}{512\cdot5}\cdot \sigma_d= 97.65625\frac{cm}{px}\cdot\sigma_d$\\
        for $\sigma_d=0.5px:\ b=97.65625\frac{cm}{px}\cdot 0.5px=48.828125cm$
	\end{enumerate}
\end{document}

