\small \texttt{tomik.musil@gmail.com}}
\date{\small summer 2012}
+\newcommand{\pclass}[2]{\subsection*{#1}
+ #2
+}
+
+\newcommand{\pfunc}[4]{
+ \begin{center}
+ \begin{tabular*}{0.8\textwidth}{ll}
+ \multicolumn{2}{l}{{\bf function} #1} \\
+ {\bf input} #2 & {\bf output} #3 \\
+ \multicolumn{2}{p{0.8\textwidth}}{#4} \\
+ \end{tabular*}
+ \end{center}
+}
+
\begin{document}
\maketitle
\paragraph{}
The program will be written mainly in Python, performance-critical parts later refactored in C. It will be distributed under a free (but not copyleft) license.
It will be platform independent.
-The grid detection algorhitm will be based on a method described in~\cite{thirsima05}.
-Since this grid-finding algorhitm does not work on boards filled with stones, another algorhitm will be deviced for these. It will be based on further research.
+The grid detection algorithm will be based on a method described in~\cite{thirsima05}.
+Since this grid-finding algorithm does not work on boards filled with stones, another algorithm will be devised for these. It will be based on further research.
\section{User interface specification}
-As the process should be as authomatic as possible, there will be very few options. Therefore there is no need for a GUI (with exceptions mentioned below) and all the options (output format etc.) will be specified on the command line.
+As the process should be as automatic as possible, there will be very few options. Therefore there is no need for a GUI (with exceptions mentioned below) and all the options (output format etc.) will be specified on the command line.
\paragraph{Single image processing}
-Ideally, user would suply an image and get a position representation in specified output format right away, no further questions asked.
-Should the authomatic grid-findig system fail, the user will be prompted to run a simple GUI and point out corners of the grid.
+Ideally, user would supply an image and get a position representation in specified output format right away, no further questions asked.
+Should the automatic grid-finding system fail, the user will be prompted to run a simple GUI and point out corners of the grid.
\paragraph{Multiple images processing}
-It will be possible to process a set of images as a game record. The grid will be found in the first picture and remebered for following ones (assuming the camera position had not changed in between) or found in each picture separately. When player's hand or other object hides part of the board, Imago will try to infer the position from previous and following pictures. If it fails to do so, it will ask the user to open a simple GUI, look at the pictures and fill in the move.
+It will be possible to process a set of images as a game record. The grid will be found in the first picture and remembered for following ones (assuming the camera position had not changed in between) or found in each picture separately. When player's hand or other object hides part of the board, Imago will try to infer the position from previous and following pictures. If it fails to do so, it will ask the user to open a simple GUI, look at the pictures and fill in the move.
\paragraph{Output formats}
-The ASCII output will be similar to the {\em GNU Go} command-line mode output. Each situation will be desribed by 19 rows of 19 characters each, with the respective symbol ('.', 'X', 'O') being used for empty intersection, black stone and white stone.
+The ASCII output will be similar to the {\em GNU Go} command-line mode output. Each situation will be described by 19 rows of 19 characters each, with the respective symbol ('.', 'X', 'O') being used for empty intersection, black stone and white stone.
It will be possible to export both single positions and complete game records to {\em Smart Game Format} (its specification can be found at~\cite{sgf}).
\paragraph{Supporting scripts}
There will be a script to capture images from a web camera. It will be capable of taking pictures periodically or running a go clock and taking picture with every clock-press.
\section{Technical specification}
\paragraph{Image processing}
-Imago will first try to find the grid based on visible lines. The procedure used here relies on the Hough transform and is similar to the method described~\cite{thirsima05}. If it fails to do so, it will try to locate sufficient number of stones to infere the grid position. Algorhitm for finding stones will be subject to further research. If neither of aforementioned methods succedes, it will promt the user to open a GUI and locate corners of the grid manually. When it has the grid, it figures out stones position and color based on the color around each intersection.
+Imago will first try to find the grid based on visible lines. The procedure used here relies on the Hough transform and is similar to the method described~\cite{thirsima05}. If it fails to do so, it will try to locate sufficient number of stones to infer the grid position. Algorithm for finding stones will be subject to further research. If neither of aforementioned methods succeeds, it will prompt the user to open a GUI and locate corners of the grid manually. When it has the grid, it figures out stones position and color based on the color around each intersection.
-Multiple images processing is essentially the above mentioned proccess repeated, possibly without the grid-locating part, which could be omitted after the first picture. Methods for infering missing moves will be based on further research.
+Multiple images processing is essentially the above mentioned process repeated, possibly without the grid-locating part, which could be omitted after the first picture. Methods for inferring missing moves will be based on further research.
\paragraph{Programming languages and libraries}
-Most of the program will be written in Python 2.7.
+Most parts of the program will be written in Python 2.7.
{\em Python Imaging Library} (PIL, ~\cite{pil}) will be used for basic image manipulation. {\em Pygame} will be used for the GUI-related stuff. Web camera will be accessed using {\em openCV} on unix and {\em VideoCapture} module (\cite{vidcap}) on Windows.
-\paragraph{Code architecture}
+\section{Code architecture}
The code will be divided into following modules and corresponding classes:
-\begin{description}
- \item[camera] accesing the web camera
- \item[capture] capturing images
- \item[filters] graphic filters
- \item[grid] grid finding
- \item[hough] hough transform and related functions
- \item[imago] the main program
- \item[output] for output to different formats
- \item[record] game record proccessing
- \item[stones] stone finding
- \item[timer] go clock with image capture
-\end{description}
+\pclass{camera}
+{accessing the web camera}
+\pclass{capture}
+{capturing images}
+\pclass{filters}
+{graphic filters}
+ \pfunc{components}
+ {grayscale image}{binary image}
+ {Returns an image where each pixel of value 1 represents center of one connected component in the input image.}
+ \pfunc{edge\_detection}
+ {grayscale image}{grayscale image}
+ {Provides some method of edge detection.}
+ \pfunc{high-pass}
+ {grayscale image, threshold}{binary image}
+ {High pass filter.}
+ \pfunc{peaks}
+ {grayscale image}{grayscale image}
+ {Finds peaks in the image.}
+\pclass{grid}
+{grid finding}
+ \pfunc{find}
+ {list of lines}{two lists of 19 lines each}
+ {Given the lines found by Hough transform, tries to find the grid.}
+\pclass{hough}
+{Hough transform and related functions}
+ \pfunc{all\_lines}
+ {binary image}{list of lines}
+ {Gets (filtered) result of the Hough transform. Returns a list of lines represented by angle and distance from the center of the image.}
+ \pfunc{transform}
+ {binary image}{grayscale image}
+ {Hough transform of the image.}
+\pclass{imago}
+{the main program}
+\pclass{output}
+{output to different formats}
+\pclass{record}
+{game record processing}
+\pclass{stones}
+{stone finding}
+ \pfunc{stone\_color}
+ {image, coordinates}{char}
+ {Returns a character representing stone color or empty intersection on given coordinates in the given image.}
+\pclass{timer}
+{go clock with image capture}
\begin{thebibliography}{9}