text.hpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. By downloading, copying, installing or using the software you agree to this
  3. license. If you do not agree to this license, do not download, install,
  4. copy or use the software.
  5. License Agreement
  6. For Open Source Computer Vision Library
  7. (3-clause BSD License)
  8. Copyright (C) 2013, OpenCV Foundation, all rights reserved.
  9. Third party copyrights are property of their respective owners.
  10. Redistribution and use in source and binary forms, with or without modification,
  11. are permitted provided that the following conditions are met:
  12. * Redistributions of source code must retain the above copyright notice,
  13. this list of conditions and the following disclaimer.
  14. * Redistributions in binary form must reproduce the above copyright notice,
  15. this list of conditions and the following disclaimer in the documentation
  16. and/or other materials provided with the distribution.
  17. * Neither the names of the copyright holders nor the names of the contributors
  18. may be used to endorse or promote products derived from this software
  19. without specific prior written permission.
  20. This software is provided by the copyright holders and contributors "as is" and
  21. any express or implied warranties, including, but not limited to, the implied
  22. warranties of merchantability and fitness for a particular purpose are
  23. disclaimed. In no event shall copyright holders or contributors be liable for
  24. any direct, indirect, incidental, special, exemplary, or consequential damages
  25. (including, but not limited to, procurement of substitute goods or services;
  26. loss of use, data, or profits; or business interruption) however caused
  27. and on any theory of liability, whether in contract, strict liability,
  28. or tort (including negligence or otherwise) arising in any way out of
  29. the use of this software, even if advised of the possibility of such damage.
  30. */
  31. #ifndef __OPENCV_TEXT_HPP__
  32. #define __OPENCV_TEXT_HPP__
  33. #include "opencv2/text/erfilter.hpp"
  34. #include "opencv2/text/ocr.hpp"
  35. #include "opencv2/text/textDetector.hpp"
  36. /** @defgroup text Scene Text Detection and Recognition
  37. The opencv_text module provides different algorithms for text detection and recognition in natural
  38. scene images.
  39. @{
  40. @defgroup text_detect Scene Text Detection
  41. Class-specific Extremal Regions for Scene Text Detection
  42. --------------------------------------------------------
  43. The scene text detection algorithm described below has been initially proposed by Lukás Neumann &
  44. Jiri Matas @cite Neumann11. The main idea behind Class-specific Extremal Regions is similar to the MSER
  45. in that suitable Extremal Regions (ERs) are selected from the whole component tree of the image.
  46. However, this technique differs from MSER in that selection of suitable ERs is done by a sequential
  47. classifier trained for character detection, i.e. dropping the stability requirement of MSERs and
  48. selecting class-specific (not necessarily stable) regions.
  49. The component tree of an image is constructed by thresholding by an increasing value step-by-step
  50. from 0 to 255 and then linking the obtained connected components from successive levels in a
  51. hierarchy by their inclusion relation:
  52. ![image](pics/component_tree.png)
  53. The component tree may contain a huge number of regions even for a very simple image as shown in
  54. the previous image. This number can easily reach the order of 1 x 10\^6 regions for an average 1
  55. Megapixel image. In order to efficiently select suitable regions among all the ERs the algorithm
  56. make use of a sequential classifier with two differentiated stages.
  57. In the first stage incrementally computable descriptors (area, perimeter, bounding box, and Euler's
  58. number) are computed (in O(1)) for each region r and used as features for a classifier which
  59. estimates the class-conditional probability p(r|character). Only the ERs which correspond to local
  60. maximum of the probability p(r|character) are selected (if their probability is above a global limit
  61. p_min and the difference between local maximum and local minimum is greater than a delta_min
  62. value).
  63. In the second stage, the ERs that passed the first stage are classified into character and
  64. non-character classes using more informative but also more computationally expensive features. (Hole
  65. area ratio, convex hull ratio, and the number of outer boundary inflexion points).
  66. This ER filtering process is done in different single-channel projections of the input image in
  67. order to increase the character localization recall.
  68. After the ER filtering is done on each input channel, character candidates must be grouped in
  69. high-level text blocks (i.e. words, text lines, paragraphs, ...). The opencv_text module implements
  70. two different grouping algorithms: the Exhaustive Search algorithm proposed in @cite Neumann12 for
  71. grouping horizontally aligned text, and the method proposed by Lluis Gomez and Dimosthenis Karatzas
  72. in @cite Gomez13 @cite Gomez14 for grouping arbitrary oriented text (see erGrouping).
  73. To see the text detector at work, have a look at the textdetection demo:
  74. <https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/textdetection.cpp>
  75. @defgroup text_recognize Scene Text Recognition
  76. @}
  77. */
  78. #endif