\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{5}{}{2015-06-02}{Mobile Robots}{
    	\textit{Jan-Peter Hohloch}\\ \textit{Maximus Mutschler}
    }{SS 15}{2}
    \vspace{1cm}

	\Aufgabe{MATLAB}{10}
	\begin{enumerate}[(a)]
        \item Marlin F-033 specs from \url{https://www.alliedvision.com/cn/products/cameras/detail/f-033-1.html}:
            \begin{itemize}
                \item Resolution: 656x494
                \item Framerate: 73fps
                \item $73\frac{1}{s}\cdot 656\cdot 494\cdot 1$ Byte$=23656672\frac{\text{Byte}}{s}  =22,561\frac{\text{MB}}{s} $
            \end{itemize}
        \item We'd expect the principle point to be at (0,0) if this correspondents to the middle of the picture. So it should be in Pixel 162032. (Position (353;247))
        \item after optimization:
        \begin{itemize}
            \item focal length: [ 764.08776 ,  765.38354 ] \\Variance [ 23.27887  , 25.40916 ]
            \item Principle point: [ 361.64057 ,  143.47510 ] \\Variance [ 34.24946 ,  40.45983 ]
            \item distortion: [ -0.05504 ,  -0.17691 ,  -0.01918 ,  0.00475 , 0.00000 ] \\Variance [ 0.07945   0.20352 ,  0.01081  , 0.00827 , 0.00000 ]
            \item Pixel error:[ 0.79394,   0.91111 ]
           
           \item 
           picture width in x direction: 22.58 cm \\
           $\alpha= \frac{640}{225.8mm}=2.8346\frac{p}{mm}\\
           k_u = k_v = l\cdot \alpha = 764.08776mm\cdot2.8346\frac{p}{mm} = 2165.883p$\\
           calibration matrix:$ \\
           \begin{pmatrix}
           	k_u& 0& u_0\\0& k_v& v_0\\ 0&0&1
           \end{pmatrix} = \begin{pmatrix}
           2165.883& 0& 361.64057\\0& 2165.883& 143.47510\\ 0&0&1
        \end{pmatrix}$\\
            \item The pixel error ist the standard deviation of the reprojection error in x- and y-Direction
        \end{itemize}
        \item Expectation: (353,247)\\
        Found: (361.64057 ,  143.47510)\\
        \\The prinicpal point depends on how the lens is mounted over the sensor. In respect to the given sensor it is mounted on the center right.
        \item we supressed image 11,13,14,15 due to their reprojection errors' big variances.\\
      Old Pixel error:[ 0.79394,   0.91111 ]\\
      New Pixel Error:[ 0.39567,   0.30326 ]\\
      $\Delta Error$ [0.39827, 0.60785] \\
      \item 
      Distance: 2313.405920
      \\Translation Vector: $
      \begin{pmatrix}
     552.389076 \\	 -177.507678 \\	 2313.405920 
      \end{pmatrix} 
      $\\
      Rotation Matrix: $
      \begin{pmatrix}
      0.998247 	& 0.004348 	& -0.059025 \\
      0.011771 	 &-0.991961 &	 0.125999 \\
      -0.058003 &	 -0.126473& 	 -0.990273  \\ 
      \end{pmatrix} 
      $
      
        
	\end{enumerate}
    \Aufgabe{}{10}
        \begin{enumerate}[(a)]
            \item $n=\begin{pmatrix}
                \frac{u-u_0}{k_u}\\
                \frac{v-v_0}{k_v}\\
                1
            \end{pmatrix}$
            \item $n_c\approx\begin{pmatrix}
                0.236\\0.255\\1
            \end{pmatrix},\ n_b\approx\begin{pmatrix}
                0.245\\0.258\\1
            \end{pmatrix}$
            
            
            
            
            \item $\alpha =\tan^{-1}\left(d(n_c,n_b)\right)\approx\tan^{-1}\left(\sqrt{\left(0.236-0.245\right)^2+\left(0.255-0.258\right)^2}\right)\approx 0.00980$
            \item $Z_C=\frac{20mm }{d(n_c,n_b)}=\frac{20mm}{ \sqrt{\left(0.236-0.245\right)^2+\left(0.255-0.258\right)^2}}\approx \frac{20mm}{0.00949}\approx 2107mm$
             \begin{figure}[!htb]
             	
             	\centering
             	\includegraphics[width=0.6\textwidth]{Z.png}
             	\caption{\label{fig:z} How to calculate Z}
             	
             \end{figure}
             see figure \ref{fig:z}
            \item $Z_C\cdot n=N\Rightarrow P_C=\begin{pmatrix}
                Z_C\cdot 0.236\\Z_C\cdot 0.255\\ Z_C
            \end{pmatrix}\approx \begin{pmatrix}
                497.2\\537.3\\ 2107
            \end{pmatrix}mm$
           
            
            \item Depending on how many distortion parameters we want to know, the system of linear equations may be of high dimension. In addition we can't seperate by coordinates because the solutions for $x$ and $y$ depend on each other. Even for only computing radial distortion only up to the second degree we have to\\
            solve $\begin{pmatrix}
                x_d\\y_d
            \end{pmatrix}=\begin{pmatrix}
                x\\y
            \end{pmatrix}+k_1\left|\left|\begin{pmatrix}
                x\\y
            \end{pmatrix}\right|\right|_2^2+k_2\left|\left|\begin{pmatrix}
                x\\y
            \end{pmatrix}\right|\right|_2^4$ for $x$ and $y$.
        \end{enumerate}
        
        
\end{document}

