OpenCV 3.0に果敢に挑戦し続けてみる

個人的な趣味の一環として、OpenCV 3.0がらみの情報をまとめてみる。「引用はいぃんよー、無断転載はあかんよー」ということで。

Scene Text Detectionしてみやう(OpenCV 3.0)

シーン内の文字列検出に興味あるよね?

http://docs.opencv.org/2.4.8/modules/objdetect/doc/objdetect.html

にはなくて、

http://docs.opencv.org/trunk/modules/objdetect/doc/objdetect.html

にある新機能として、「シーンテキスト検出」がありますと。

 

ざっくり翻訳

シーンテキスト検出アルゴリズムは、Lukás Neumann & Jiri Matas [Neumann12]によって最初に提案されました。Class-specific Extremal Regionsの基本的な考え方は、適切なExtremal Regions (ERs)を画像の全コンポーネント木から選択する点でMSERに似ています。しかしながら、この技術は、適切なERsを選択する際に文字検出の分類学習の連続性によって点でMSERと異なります。すなわち、MSERで求められていた安定性を犠牲にし、(必ずしも安定しない)領域のクラス分類を選択します。

 

イメージの構成要素の木は、0~255まで着実な増加する値によって二値化し、次に、それらの包含関係によって階層中の連続のレベルからの得られた連結成分をリンクすることにより構築されます:

 

コンポーネント木は前述したような単純な画像であっても多数の領域が含まれているだろう。この数は、1M pixelの画像でも1 × 10^6 領域に簡単に達する。効率的に適切な領域を検出するために、全てのERsに対して順次実行される2つの異なるステージの分類が用いられる。

 

In the first stage incrementally computable descriptors (area, perimeter, bounding box, and euler number) are computed (in O(1)) for each region r and used as features for a classifier which estimates the class-conditional probability p(r|character). Only the ERs which correspond to local maximum of the probability p(r|character) are selected (if their probability is above a global limit p_min and the difference between local maximum and local minimum is greater than a delta_min value).

In the second stage, the ERs that passed the first stage are classified into character and non-character classes using more informative but also more computationally expensive features. (Hole area ratio, convex hull ratio, and the number of outer boundary inflexion points).

This ER filtering process is done in different single-channel projections of the input image in order to increase the character localization recall.

After the ER filtering is done on each input channel, character candidates must be grouped in high-level text blocks (i.e. words, text lines, paragraphs, ...). The grouping algorithm used in this implementation has been proposed by Lluis Gomez and Dimosthenis Karatzas in [Gomez13] and basically consist in finding meaningful groups of regions using a perceptual organization based clustering analisys (see erGrouping()).

 

試すには

https://raw.github.com/Itseez/opencv/master/samples/cpp/textdetection.cpp

ここのコードと、

samples/cpp/trained_classifierNM1.xml

samples/cpp/trained_classifierNM2.xml

があればOK。

 

http://en.wikipedia.org/wiki/File:NYTimes-Page1-11-11-1918.jpg 

から、これが得られます。

f:id:anobiidae:20140223205903p:plain