ラベル AWS Rekognition の投稿を表示しています。 すべての投稿を表示
ラベル AWS Rekognition の投稿を表示しています。 すべての投稿を表示

2019年4月15日月曜日

Using MIT App Inventor AWS AI Services Extension

Modern AI image recognition allows us to recognize not only objects, but also the accompanying text (strings). Here we will try it using Amazon AWS Rekognition. Using the APIs provided there, we can create a variety of applications on our PC, but for more convenient use, the applications on our smartphone will be preferable.

Recently, I focused on the AWS AI Services Extension developed by Ceyhun Özgün. This is an Extension that allows MIT App Inventor applications to easily take advantage of such recognition features. References [1] and [2] provide descriptions and demo programs. I've created a simple smartphone application like Fig.1 below, using this useful information as a reference.


(Please click to enlarge)

Let me illustrate the recognition results in this diagram. Fig.1 (a) is an image of the US $2 bill. Immediately, “Money, Person, Dollar” was recognized. In addition, the text in the image was also recognized. In particular, the number “J045... 5A”, which is the id of the banknote, is also recognized precisely. Fig.1 (b), on the other hand, is an image of a notebook and books. It is recognized as “Book”, and the text of the titles of the books (although handwriting is also included) is almost accurate. I think it's great. These smartphone apps are fun to use wherever you take them!

The design part of this app is shown in Fig.2. Here, I used AppyBuilder. You can choose to take a picture now or use an image that you already have in your library. After that, recognition is performed automatically and the results of recognition of objects and text are displayed.


Next Fig.3 is the complete blocks of this app. Thanks to the Extension mentioned above, you will find that it has become a very concise program. In order to use this Extension, you need to set up an AWS account. In particular, be aware that you will give your AWS Services credentials on the first run. Details of this are also described in the literature [1]. Thanks to Ceyhun Özgün!


References
[1] https://hackernoon.com/your-kid-can-code-a-fruit-detector-with-this-mit-app-inventor-aws-ai-services-extension-231665c8bcdc
[2] https://github.com/ceyhunozgun/awsAIServicesAppInventorExtension/wiki

2019年4月12日金曜日

AIによる画像認識で紙幣の記番号を抽出してみる

 先のブログ記事でコインの識別について書いた後、麻生財務相による紙幣刷新の発表がありました。その狙いのひとつは、紙幣の偽造防止とのことです。そこで、紙幣の記番号の識別も意味があるかも知れない。なぜなら、過去に大量に出回った偽造紙幣の記番号は同一だった(コピーによるため)との情報があるからです。

 では、現在のAIによる画像認識技術で、記番号抽出は可能なのでしょうか。それを少しだけですが、確かめてみました。調査対象も少なく、説得力に欠けますが、実験結果として以下に記しておきます。ここでは、AIによる画像認識技術で最強の部類に入ると思われる、IBM Watson Visual RecognitionとAmazon AWS Rekognition(イメージ内テキスト)を使いました。特に自分でプログラミングしなくても、この程度のことであれば、簡単に使えるのは有り難いです。生徒の理科の実験やレポート作成にも使えるくらいです。

 まず、このWatson Visual Recognitionは、文字認識のための専用OCRソフトではありません。画像に何が写っているか分からないなかで、人の顔や動物、植物、日用品等々を認識するものであり、その一部として、文字列(テキスト)らしきものがあればそれも識別する、というものです。これに対して、Amazon AWS Rekognitionには、「イメージ内テキスト」検出というという専用オプションがあります。両者のコンセプトには違いがあるようです。ですから、一概にどちらが優れているなどという判断はしない方が良いでしょう。これを踏まえたうえで、以下の実験結果を示します。

 最初に、Watson Visual Recognitionを使います。対象画像の中に、辞書に載っている単語など、意味のある綴りがあれば、それは認識しやすいようです。実際、図1はそのことを示しています。この画像は過去のJava Oneというコンファレンスの際にもらった布製のバックパックです。それに、刺繍で幾つかの文字が縫われています。歪んだりしているのに、「java」や「diamond」「fuji」などが、見事に抽出されています。素晴らしい!



 次に、本題の紙幣の記番号の抽出を試行しますが、事前検討の結果から、こんどはAmazon AWS Rekognitionを使うことにしました。図2は米5ドル紙幣、図3は壱万円札、図4は10ユーロ紙幣です。結論から言いますと、いずれの記番号も完璧に認識(抽出)しているではありませんか!紙幣の場合は、記番号の背景に、微細で複雑な模様があるので、自動車のナンバープレートの識別などよりも難しいのではないかと思いましたが、難なく認識してしまいました。







 これらの結果を眺めていると、仮に偽造紙幣が出回っていて、その記番号がデータベースに登録されている場合、パソコンやスマホを使った安価な偽造紙幣検出アプリができてしまいそうです。例えば、大学の研究室で、学生や先生から、何とか1万円札を100枚(100万円)借りて集めます。それを、ScanSnapなどでスキャンして、スマホかPCのアプリで検出実験もできそうです。ただし、紙幣をスキャン(コピー)することは、通貨偽造に関する法律に抵触しそうなので、ご注意下さい。(下記、財務省見解参照)

 なお、紙幣の記番読取りは、すでに実用化されているという情報をいただきましたので、主な参考資料を追記しておきます。Deep Learningによる技術かどうかなどは不明ですが。
  • 現金管理の効率化と厳格化を実現するSmart Cash Stream ソリューション、日立評論2015-03, pp.38-42
  • 紙幣記番号読取装置および紙幣記番号読取方法、グローリー株式会社、特許公開番号2004-213560
----------------------------
【注】紙幣複写等に関する財務省見解
本記事は、下記の財務省見解を理解したうえで執筆しました。
----------------------------