LoginSignup
3
4

More than 5 years have passed since last update.

Mobile Vision API / Firebase ML Kit で認識できるBarcodeの種別

Posted at

はじめに

  • Mobile Vision API / Firebase ML Kitで認識できるBarcodeの種別は12種類
  • QRコード読取りアプリを作成した際に、それぞれの種類のBarcode(QRコード)のサンプル画像があまりなく動作確認が大変だったので残しておくことにしました

Barcodeの種類

Mobile Vision API : Barcode.valueFormat
Firebase ML Kit : FirebaseVisionBarcode#getValueType()
で種別を取得することができます。

取得できる種別は以下の12種類です。

  • Text
  • URL
  • Email
  • Phone
  • SMS
  • WiFi
  • Geo-location (latitude and longitude)
  • Contact information (VCARD, etc.)
  • Calendar event
  • ISBN
  • Product
  • AAMVA driver license/ID

Barcodeの作成

Barcodeに含まれる文字情報に応じて、返却される種別が変わります。
コードからはrawValueとして取得することができます。
Mobile Vision API : Barcode.rawValue
Firebase ML Kit : FirebaseVisionBarcode#getRawValue()

各種別の形式と例

Text

barcode_text.png
(テキストテスト)

  • rawValueの形式が特別でない場合は、Textになります

Url

qr_url.png

(MEBKM:URL:https://google.com;TITLE:Google;)

Email

qr_mailto.png
(mailto:bob@example.org,john@example.com?subject=baz&body=buzz)

  • メールアドレスのみ
    • @マークが含まれ、@マーク以降の文字列に.が含まれるとメールアドレスとするようです
    • (例)123@456.com
  • mailto
    • mailto:{メールアドレス}?subject={件名}&body={本文}
    • 上記の形式でメールアドレス、件名、本文を含んだBarcodeができます
    • メールアドレスはカンマ区切りで複数のtoを指定することができます
    • (例)mailto:bob@example.org,john@example.com?subject=baz&body=buzz
  • MATMSG
    • MATMSG:TO:{メールアドレス};SUB:{件名};BODY:{本文};;
    • 上記の形式でメールアドレス、件名、本文を含んだBarcodeができます
    • (例)MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;
  • smtp
    • smtp:{メールアドレス}:{件名}:{本文}
    • 上記の形式でメールアドレス、件名、本文を含んだBarcodeができます
    • (例)smtp:srowen@example.org:foo:bar

Phone

image.png
(tel:1234567)

  • tel
    • tel:{電話番号}
    • 上記の形式で電話番号を含んだBarcodeができます
    • (例)tel:1234567

SMS

image.png
(smsto:123456:test)

  • smsto
    • smsto:{電話番号}:{本文}
    • 上記の形式で電話番号、本文を含んだBarcodeができます
    • (例)smsto:123456:test

Wifi

image.png
(WIFI:S:TenChars;P:0123456789;T:WEP;;)

  • WIFI
    • WIFI:S:{SSID};P:{パスワード};T:{タイプ};;
    • 上記の形式でSSID、パスワード、タイプ(WEP/WAP/OPEN)を含んだBarcodeができます
    • タイプの指定をしないとOPENになります
    • (例)WIFI:S:TenChars;P:0123456789;T:WEP;;

Geo-location

image.png
(geo:-20.33,132.3344)

  • geo
    • geo:{緯度},{経度}
    • 上記kの形式で緯度、経度を含んだBarcodeができます
    • geo:-20.33,132.3344

Contact information

image.png
(MECARD:N:Foo Bar;ORG:Company;TEL:5555555555;EMAIL:foo.bar@xyz.com;ADR:City, 10001;NOTE:This is the memo.;;)

  • MECARD
    • MECARD:N:{名前};ORG:{所属};TEL:{電話番号};EMAIL:{メールアドレス};ADR:{住所};NOTE:{メモ};;
    • 上記の形式で、名前、所属、電話番号、メールアドレス、住所、メモを含んだBarcodeができます
    • (例)MECARD:N:Foo Bar;ORG:Company;TEL:5555555555;EMAIL:foo.bar@xyz.com;ADR:City, 10001;NOTE:This is the memo.;;
  • vCard
    • BEGIN:VCARD
      VERSION:3.0
      N:{名前}
      ORG:{所属}
      TITLE:{タイトル}
      TEL:{電話番号}
      URL:{URL}
      EMAIL:{メールアドレス}
      ADR:{住所}
      NOTE:{メモ}
      END:VCARD
    • 上記の形式で、名前、所属、タイトル、電話番号、URL、メールアドレス、住所、メモを含んだBarcodeができます
    • (例)
      BEGIN:VCARD
      VERSION:3.0
      N:Bob
      ORG:Sample Company
      TITLE:Test title
      TEL:0001234567
      URL:http://sample.com
      EMAIL:test@oo.com
      ADR:test address test address2
      NOTE:test memo
      END:VCARD

Calendar event

image.png
(BEGIN:VEVENT
SUMMARY:sample event
DTSTART:20180812T051200Z
DTEND:20180813T061200Z
LOCATION:test location
DESCRIPTION:sample event
END:VEVENT
)

  • VEVENT
    • BEGIN:VEVENT
      SUMMARY:{概要}
      DTSTART:{開始時刻}
      DTEND:{終了時刻}
      LOCATION:{場所}
      DESCRIPTION:{詳細}
      END:VEVENT
    • 上記の形式で、概要、開始時刻、終了時刻、場所、詳細を含んだBarcodeができます
    • (例)
      BEGIN:VEVENT
      SUMMARY:sample event
      DTSTART:20180812T051200Z
      DTEND:20180813T061200Z
      LOCATION:test location
      DESCRIPTION:sample event
      END:VEVENT

ISBN

image.png
(9781234567897)

  • ISBN文字列
    • EAN-13やJAN-13などのフォーマットで、ISBNの規格の文字列の場合、ISBNとなります
    • (例)9781234567897

Product

image.png
(1234512345123)

  • Product文字列
    • EAN-13/JAN-13/UPC-A/UPC-8などのフォーマットの文字列の場合、Productとなります
    • (例)1234512345123

AAMVA driver license/ID

  • どのような形式で取得できるかわかりませんでした。

参考

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4