verslag.tex 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. \documentclass[a4paper]{article}
  2. \usepackage{hyperref}
  3. \title{Using local binary patterns to read license plates in photographs}
  4. % Paragraph indentation
  5. \setlength{\parindent}{0pt}
  6. \setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
  7. \begin{document}
  8. \maketitle
  9. \section*{Project members}
  10. Gijs van der Voort\\
  11. Richard Torenvliet\\
  12. Jayke Meijer\\
  13. Tadde\"us Kroes\\
  14. Fabi\'en Tesselaar
  15. \tableofcontents
  16. \setcounter{secnumdepth}{1}
  17. \section{Problem description}
  18. License plates are used for uniquely identifying motorized vehicles and are
  19. made to be read by humans from great distances and in all kinds of weather
  20. conditions.
  21. Reading license plates with a computer is much more difficult. Our dataset
  22. contains photographs of license plates from various angles and distances. This
  23. means that not only do we have to implement a method to read the actual
  24. characters, but given the location of the license plate and each individual
  25. character, we must make sure we transform each character to a standard form.
  26. This has to be done or else the local binary patterns will never match!
  27. Determining what character we are looking at will be done by using Local Binary
  28. Patterns. The main goal of our research is finding out how effective LBP's are
  29. in classifying characters on a license plate.
  30. In short our program must be able to do the following:
  31. \begin{enumerate}
  32. \item Use a perspective transformation to obtain an upfront view of license
  33. plate.
  34. \item Reduce noise where possible to ensure maximum readability.
  35. \item Extracting characters using the location points in the xml file.
  36. \item Transforming a character to a normal form.
  37. \item Creating a local binary pattern histogram vector.
  38. \item Matching the found vector with a learning set.
  39. \item And finally it has to check results with a real data set.
  40. \end{enumerate}
  41. \section{Language of choice}
  42. The actual purpose of this project is to check if LBP is capable of recognizing
  43. license plate characters. We knew the LBP implementation would be pretty simple.
  44. Thus an advantage had to be its speed compared with other license plate
  45. recognition implementations, but the uncertainity of whether we could get some
  46. results made us pick Python. We felt Python would not restrict us as much in
  47. assigning tasks to each member of the group. In addition, when using the correct
  48. modules to handle images, Python can be decent in speed.
  49. \section{Implementation}
  50. Now we know what our program has to be capable of, we can start with the
  51. implementations.
  52. \subsection{Transformation}
  53. A simple perspective transformation will be sufficient to transform and resize
  54. the plate to a normalized format. The corner positions of license plates in the
  55. dataset are supplied together with the dataset.
  56. \subsection{Reducing noise}
  57. Small amounts of noise will probably be suppressed by usage of a Gaussian
  58. filter. A real problem occurs in very dirty license plates, where branches and
  59. dirt over a letter could radically change the local binary pattern. A question
  60. we can ask ourselves here, is whether we want to concentrate ourselves on these
  61. exceptional cases. By law, license plates have to be readable. Therefore, we
  62. will first direct our attention at getting a higher score in the 'regular' test
  63. set before addressing these cases. Considered the fact that the LBP algorithm
  64. divides a letter into a lot of cells, there is a good change that a great
  65. number of cells will still match the learning set, and thus still return the
  66. correct character as a best match. Therefore, we expect the algorithm to be
  67. very robust when dealing with noisy images.
  68. \subsection{Extracting a letter}
  69. Because we are already given the locations of the characters, we only need to
  70. transform those locations using the same perspective transformation used to
  71. create a front facing license plate. The next step is to transform the
  72. characters to a normalized manner. The size of the letter W is used as a
  73. standard to normalize the width of all the characters, because W is the widest
  74. character of the alphabet. We plan to also normalize the height of characters,
  75. the best manner for this is still to be determined.
  76. \begin{enumerate}
  77. \item Crop the image in such a way that the character precisely fits the
  78. image.
  79. \item Scale the image to a standard height.
  80. \item Extend the image on either the left or right side to a certain width.
  81. \end{enumerate}
  82. The resulting image will always have the same size, the character contained
  83. will always be of the same height, and the character will alway be positioned
  84. at either the left of right side of the image.
  85. \subsection{Local binary patterns}
  86. Once we have separate digits and characters, we intent to use Local Binary
  87. Patterns to determine what character or digit we are dealing with. Local Binary
  88. Patters are a way to classify a texture based on the distribution of edge
  89. directions in the image. Since letters on a license plate consist mainly of
  90. straight lines and simple curves, LBP should be suited to identify these.
  91. To our knowledge, LBP has yet not been used in this manner before. Therefore,
  92. it will be the first thing to implement, to see if it lives up to the
  93. expectations. When the proof of concept is there, it can be used in the final
  94. program.
  95. Important to note is that due to the normalization of characters before
  96. applying LBP. Therefore, no further normalization is needed on the histograms.
  97. Given the LBP of a character, a Support Vector Machine can be used to classify
  98. the character to a character in a learning set. The SVM uses
  99. \subsection{Matching the database}
  100. Given the LBP of a character, a Support Vector Machine can be used to classify
  101. the character to a character in a learning set. The SVM uses the collection of
  102. histograms of an image as a feature vector. The SVM can be trained with a
  103. subsection of the given dataset called the ''Learning set''. Once trained, the
  104. entire classifier can be saved as a Pickle object\footnote{See
  105. \url{http://docs.python.org/library/pickle.html}} for later usage.
  106. \section{Implementation}
  107. In this section we will describe our implementations in more detail, explaining
  108. choices we made.
  109. \subsection{Licenseplate retrieval}
  110. In order to retrieve the license plate from the entire image, we need to
  111. perform a perspective transformation. However, to do this, we need to know the
  112. coordinates of the four corners of the licenseplate. For our dataset, this is
  113. stored in XML files. So, the first step is to read these XML files.\\
  114. \\
  115. \paragraph*{XML reader}
  116. \paragraph*{Perspective transformation}
  117. Once we retrieved the cornerpoints of the license plate, we feed those to a
  118. module that extracts the (warped) license plate from the original image, and
  119. creates a new image where the license plate is cut out, and is transformed to a
  120. rectangle.
  121. \subsection{Noise reduction}
  122. The image contains a lot of noise, both from camera errors due to dark noise
  123. etc., as from dirt on the license plate. In this case, noise therefore means
  124. any unwanted difference in color from the surrounding pixels.
  125. \paragraph*{Camera noise and small amounts of dirt}
  126. The dirt on the license plate can be of different sizes. We can reduce the
  127. smaller amounts of dirt in the same way as we reduce normal noise, by applying
  128. a Gaussian blur to the image. This is the next step in our program.\\
  129. \\
  130. The Gaussian filter we use comes from the \texttt{scipy.ndimage} module. We use
  131. this function instead of our own function, because the standard functions are
  132. most likely more optimized then our own implementation, and speed is an
  133. important factor in this application.
  134. \paragraph*{Larger amounts of dirt}
  135. Larger amounts of dirt are not going to be resolved by using a Gaussian filter.
  136. We rely on one of the characteristics of the Local Binary Pattern, only looking
  137. at the difference between two pixels, to take care of these problems.\\
  138. Because there will probably always be a difference between the characters and
  139. the dirt, and the fact that the characters are very black, the shape of the
  140. characters will still be conserved in the LBP, even if there is dirt
  141. surrounding the character.
  142. \subsection{Character retrieval}
  143. The retrieval of the character is done the same as the retrieval of the license
  144. plate, by using a perspective transformation. The location of the characters on
  145. the license plate is also available in de XML file, so this is parsed from that
  146. as well.
  147. \subsection{Creating Local Binary Patterns and feature vector}
  148. \subsection{Classification}
  149. \section{Finding parameters}
  150. Now that we have a functioning system, we need to tune it to work properly for
  151. license plates. This means we need to find the parameters. Throughout the
  152. program we have a number of parameters for which no standard choice is
  153. available. These parameters are:\\
  154. \\
  155. \begin{tabular}{l|l}
  156. Parameter & Description\\
  157. \hline
  158. $\sigma$ & The size of the Gaussian blur.\\
  159. \emph{cell size} & The size of a cell for which a histogram of LBPs will
  160. be generated.\\
  161. $\gamma$ & Parameter for the Radial kernel used in the SVM.\\
  162. $c$ & The soft margin of the SVM. Allows how much training
  163. errors are accepted.
  164. \end{tabular}\\
  165. \\
  166. For each of these parameters, we will describe how we searched for a good
  167. value, and what value we decided on.
  168. \subsection{Parameter $\sigma$}
  169. The first parameter to decide on, is the $\sigma$ used in the Gaussian blur. To
  170. find this parameter, we tested a few values, by checking visually what value
  171. removed most noise out of the image, while keeping the edges sharp enough to
  172. work with. By checking in the neighbourhood of the value that performed best,
  173. we where able to 'zoom in' on what we thought was the best value. It turned out
  174. that this was $\sigma = ?$.
  175. \subsection{Parameter \emph{cell size}}
  176. The cell size of the Local Binary Patterns determines over what region a
  177. histogram is made. The trade-off here is that a bigger cell size makes the
  178. classification less affected by relative movement of a character compared to
  179. those in the learning set, since the important structure will be more likely to
  180. remain in the same cell. However, if the cell size is too big, there will not
  181. be enough cells to properly describe the different areas of the character, and
  182. the feature vectors will not have enough elements.\\
  183. \\
  184. In order to find this parameter, we used a trial-and-error technique on a few
  185. basic cell sizes, being ?, 16, ?. We found that the best result was reached by
  186. using ??.
  187. \subsection{Parameters $\gamma$ \& $c$}
  188. The parameters $\gamma$ and $c$ are used for the SVM. $c$ is a standard
  189. parameter for each type of SVM, called the 'soft margin'. This indicates how
  190. exact each element in the learning set should be taken. A large soft margin
  191. means that an element in the learning set that accidentally has a completely
  192. different feature vector than expected, due to noise for example, is not taken
  193. into account. If the soft margin is very small, then almost all vectors will be
  194. taken into account, unless they differ extreme amounts.\\
  195. $\gamma$ is a variable that determines the size of the radial kernel, and as
  196. such blablabla.\\
  197. \\
  198. Since these parameters both influence the SVM, we need to find the best
  199. combination of values. To do this, we perform a so-called grid-search. A
  200. grid-search takes exponentially growing sequences for each parameter, and
  201. checks for each combination of values what the score is. The combination with
  202. the highest score is then used as our parameters, and the entire SVM will be
  203. trained using those parameters.\\
  204. \\
  205. We found that the best values for these parameters are $c=?$ and $\gamma =?$.
  206. \section{Results}
  207. The goal was to find out two things with this research: The speed of the
  208. classification and the accuracy. In this section we will show our findings.
  209. \subsection{Speed}
  210. Recognizing license plates is something that has to be done fast, since there
  211. can be a lot of cars passing a camera in a short time, especially on a highway.
  212. Therefore, we measured how well our program performed in terms of speed. We
  213. measure the time used to classify a license plate, not the training of the
  214. dataset, since that can be done offline, and speed is not a primary necessity
  215. there.\\
  216. \\
  217. The speed of a classification turned out to be blablabla.
  218. \subsection{Accuracy}
  219. Of course, it is vital that the recognition of a license plate is correct,
  220. almost correct is not good enough here. Therefore, we have to get the highest
  221. accuracy score we possibly can.\\
  222. \\ According to Wikipedia
  223. \footnote{
  224. \url{http://en.wikipedia.org/wiki/Automatic_number_plate_recognition}},
  225. commercial license plate recognition software score about $90\%$ to $94\%$,
  226. under optimal conditions and with modern equipment. Our program scores an
  227. average of blablabla.
  228. \section{Workload distribution}
  229. The first two weeks were team based. Basically the LBP algorithm could be
  230. implemented in the first hour, while some talked and someone did the typing.
  231. Some additional 'basics' where created in similar fashion. This ensured that
  232. every team member was up-to-date and could start figuring out which part of the
  233. implementation was most suited to be done by one individually or in a pair.
  234. \subsection{Who did what}
  235. Gijs created the basic classes we could use and helped the rest everyone by
  236. keeping track of what required to be finished and whom was working on what.
  237. Tadde\"us and Jayke were mostly working on the SVM and all kinds of tests
  238. whether the histograms were mathing and alike. Fabi\"en created the functions
  239. to read and parse the given xml files with information about the license plates.
  240. Upon completion all kinds of learning and data sets could be created.
  241. %Richard je moet even toevoegen wat je hebt gedaan :P:P
  242. %maar miss is dit hele ding wel overbodig. Ik dacht dat Rein het zei tijdens gesprek van ik wil weten
  243. %hoe het ging enzo
  244. \subsection{How it went}
  245. Sometimes one cannot hear the alarm bell and wake up properly. This however was
  246. not a big problem as no one was affraid of staying at Science Park a bit longer
  247. to help out. Further communication usually went through e-mails and replies
  248. were instantaneous! A crew to remember.
  249. \section{Conclusion}
  250. Awesome
  251. \end{document}