1 / 14

AS3 で画像処理して    QR コードを読んだ話

AS3 で画像処理して    QR コードを読んだ話. 自己紹介. 名前:上野 賢一. 所属:ロゴスウェア株式会社. Twitter : @keno42. 今日の内容. 大まかな手順. カメラ画像 → ビット配列(画像処理) ビット配列 → 文字列(デコード) 参考:  JIS X 0510:2004. 画像処理 1. グレー化 ColorMatrixFilter. var conGray:Array = [constnum*0.3, constnum*0.59, constnum*0.11];

jaxon
Download Presentation

AS3 で画像処理して    QR コードを読んだ話

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AS3で画像処理して   QRコードを読んだ話

  2. 自己紹介 • 名前:上野 賢一 • 所属:ロゴスウェア株式会社 • Twitter:@keno42

  3. 今日の内容

  4. 大まかな手順 • カメラ画像 → ビット配列(画像処理) • ビット配列 → 文字列(デコード) • 参考: JIS X 0510:2004

  5. 画像処理 1 • グレー化 ColorMatrixFilter var conGray:Array = [constnum*0.3, constnum*0.59, constnum*0.11]; var cmfGray:ColorMatrixFilter = new ColorMatrixFilter( [conGray[0], conGray[1], conGray[2], 0, 0, conGray[0], conGray[1], conGray[2], 0, 0, conGray[0], conGray[1],conGray[2], 0, 0, 0, 0, 0, 0, 255] ); bmp_dst.applyFilter( bmp_src, rect, point, cmfGray );

  6. 画像処理 2 • 2値化 BitmapData.threshold bmp.threshold(bmp, bmp.rect, new Point(0, 0), "<", threshold, 0xFF000000, 0xFFFFFFFF ); bmp.threshold(bmp, bmp.rect, new Point(0, 0), ">=", threshold, 0xFFFFFFFF, 0xFFFFFFFF );

  7. 画像処理 3 • ラベリング BitmapData.getColorBoundRect BitmapData.copyPixels BitmapData.floodFill var rect:Rectangle = bmp.getColorBoundsRect( 0xFFFFFFFF, pickcolor ); while ((rect.width > 0) && (rect.height> 0)){ var tempBmp:BitmapData = new BitmapData( rect.width, 1 ); tempBmp.copyPixels( bmp, new Rectangle(rect.topLeft.x, rect.topLeft.y, rect.width, 1 ), new Point(0, 0) ); var rect2:Rectangle = tempBmp.getColorBoundsRect( 0xFFFFFFFF, pickcolor ); bmp.floodFill( rect2.topLeft.x + rect.topLeft.x, rect2.topLeft.y + rect.topLeft.y, fillcolor ); _fillColor --; rect = bmp.getColorBoundsRect( 0xFFFFFFFF, pickcolor ); }

  8. 画像処理 4 • 切り出しシンボルを探す  ラベリングした矩形の中央を縦横に走査し、     黒:白:黒:白:黒=1:1:3:1:1  になっていたら当たり

  9. 画像処理 5 • コードを切り出して向きを直す Math.atan Matrix.translate Matrix.rotate matrix2.translate( - topLeftObj.topleft.x, -topLeftObj.topleft.y ); var theta:Number = 0.0; if ( tempPoint1.x != 0.0 ) { theta = -Math.atan( tempPoint1.y / tempPoint1.x ); } matrix2.rotate( theta ); matrix2.translate( 10, 10 );

  10. 画像処理 6 • タイミングパターンからバージョン検出 BitmapData.copyPixels BitmapData.getPixels  白と黒のパターン数をがんばって読む  縦横のパターン数が一致したらOK

  11. 画像処理 7 • 位置合わせパターンを使ってグリッド作成 BitmapData.getPixel BitmapData.getColorBoundRect BitmapData.floodfill  正方形からのズレは線形に補間する

  12. 画像処理 8 • いざ読み取り BitmapData.getPixel  →デコーダーへ

  13. 完成品サンプル • labs.logosware.com

  14. ご清聴ありがとうございました

More Related