バーコード スキャン
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。

ML Kit のバーコード スキャン API を使用すると、ほとんどの標準的なバーコード形式でエンコードされたデータを読み取ることができます。バーコード スキャンはデバイス上で行われ、ネットワーク接続は必要ありません。
バーコードは現実世界の情報をアプリに渡す便利な方法です。特に QR コードなどの 2D 形式を使用する場合は、連絡先情報や Wi-Fi ネットワーク認証情報などの構造化データをエンコードできます。ML Kit はこのデータを自動的に認識して解析できるため、ユーザーがバーコードをスキャンすると、アプリはインテリジェントに応答できます。
カスタム UI を必要としない場合は、Google コードスキャナを使用することをおすすめします。Code Scanner API は標準の Barcode Scan API と同じ推論モデルを使用しますが、より高速で一貫したエクスペリエンスを実現するために、最も一元化されたバーコードのみを返します。また、Google コードスキャナは安全性が高く、権限が不要であり、カメラ関連の実装や権限は必要ありません。
iOS
Android
Google コードスキャナ
主な機能
- ほとんどの標準形式の読み取り
- リニア形式: Codabar、Code 39、Code 93、Code 128、EAN-8、EAN-13、ITF、UPC-A、UPC-E
- 2D 形式: Aztec、Data Matrix、PDF417、QR コード
- フォーマットの自動検出
- 目的の形式を指定することなく、サポートされているすべてのバーコード形式を一度にスキャンできます。また、検出機能を目的の形式のみに制限することで、スキャンを高速化できます。
- 構造化データの抽出
- サポートされている 2D 形式で保存された構造化データは自動的に解析されます。サポートされている情報タイプには、URL、連絡先情報、カレンダーの予定、メールアドレス、電話番号、SMS メッセージ プロンプト、ISBN、Wi-Fi 接続情報、地理的位置、AAMVA 標準のドライバ情報などがあります。
- どの向きでも使用可能
- バーコードは向き(向き、上下)に関係なく認識され、スキャンされます。
- デバイスで実行する
- バーコード スキャンはデバイス上で完全に実行されます。ネットワーク接続は必要ありません。
この API は、以下の形式のバーコードを認識しません。
- 1 文字のみの 1D バーコード
- 6 文字未満の ITF 形式のバーコード。この形式ではチェックサムがないため不安定であることが知られています。
- FNC2、FNC3、または FNC4 でエンコードされたバーコード
- ECI モードで生成される QR コード
この API は、1 回の API 呼び出しで最大 10 個のバーコードを認識します。
検索結果の例
|
結果 |
コーナー |
(49,125)、(172,125)、(172,160)、(49,160) |
未加工の値 |
2404105001722 |
|
|
結果 |
コーナー |
(87,87)(612,87)(612,612)(87,612) |
未加工の値 |
WIFI:S:SB1Guest;P:12345;T:WEP;; |
Wi-Fi 情報 |
SSID |
SB1Guest |
パスワード |
12345 |
型 |
WEP |
|
|
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[[["\u003cp\u003eML Kit's Barcode Scanning API reads data from most standard barcode formats, including linear and 2D formats, without needing an internet connection.\u003c/p\u003e\n"],["\u003cp\u003eIt automatically detects and parses structured data like contact info, WiFi credentials, and more from supported 2D formats, enabling intelligent app responses.\u003c/p\u003e\n"],["\u003cp\u003eThe API works offline, recognizing barcodes in any orientation, and the Google Code Scanner offers a faster, safer, and permissionless option for basic scanning needs.\u003c/p\u003e\n"],["\u003cp\u003eWhile it supports a wide range of formats and data types, the API has limitations regarding certain 1D barcodes, ITF formats, and QR codes with specific encodings, recognizing a maximum of 10 barcodes per call.\u003c/p\u003e\n"]]],["ML Kit's barcode scanning API reads data from most standard barcode formats on the device without needing a network connection. It automatically detects and parses structured data from 2D formats like QR codes, recognizing information such as URLs, contact details, and WiFi credentials. The API supports various linear and 2D formats, works with any barcode orientation, and offers a Google code scanner option for a faster, safer, permission-less experience. It does not recognize some formats including some 1D and ITF barcodes.\n"],null,["With ML Kit's barcode scanning API, you can read data encoded using most\nstandard barcode formats. Barcode scanning happens on the device, and doesn't\nrequire a network connection.\n\nBarcodes are a convenient way to pass information from the real world to your\napp. In particular, when using 2D formats such as QR code, you can encode\nstructured data such as contact information or WiFi network credentials. Because\nML Kit can automatically recognize and parse this data, your app can respond\nintelligently when a user scans a barcode.\n\nFor users who don't require custom UI, we recommend using the\n[Google code scanner](/ml-kit/vision/barcode-scanning/code-scanner). The code\nscanner API uses the same inference model as the standard Barcode scanning API,\nbut returns only the most centralized barcode for a faster and more consistent\nexperience. Google code scanner is also safer and permission-less, and does not\nrequire camera-related implementation or permissions.\n\n[iOS](/ml-kit/vision/barcode-scanning/ios)\n[Android](/ml-kit/vision/barcode-scanning/android)\n[Google code scanner](/ml-kit/vision/barcode-scanning/code-scanner)\n\nKey capabilities\n\nReads most standard formats\n:\n - Linear formats: Codabar, Code 39, Code 93, Code 128, EAN-8, EAN-13, ITF, UPC-A, UPC-E\n - 2D formats: Aztec, Data Matrix, PDF417, QR Code\n\nAutomatic format detection\n: Scan for all supported barcode formats at once without having to specify\n the format you're looking for, or boost scanning speed by restricting the\n detector to only the formats you're interested in.\n\nExtracts structured data\n: Structured data that's stored using one of the supported 2D formats is\n automatically parsed. Supported information types include URLs,\n contact information, calendar events, email addresses, phone\n numbers, SMS message prompts, ISBNs, WiFi connection information,\n geographic location, and AAMVA-standard driver information.\n\nWorks with any orientation\n: Barcodes are recognized and scanned regardless of their orientation:\n right-side-up, upside-down, or sideways.\n\nRuns on the device\n: Barcode scanning is performed completely on the device, and doesn't\n require a network connection.\n\nNote that this API does not recognize barcodes in these forms:\n\n- 1D Barcodes with only one character\n- Barcodes in ITF format with fewer than six characters, and this format is known to be flaky due to absence of checksum\n- Barcodes encoded with FNC2, FNC3 or FNC4\n- QR codes generated in the ECI mode\n\nThis API recognizes no more than 10 barcodes per API call.\n\nExample results\n\n|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | | Result || |---------------|------------------------------------------| | **Corners** | (49,125), (172,125), (172,160), (49,160) | | **Raw value** | 2404105001722 | |\n\n|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | | Result || |----------------------|-----------------------------------------------------------------------------------------------------------------| | **Corners** | (87,87) (612,87) (612,612) (87,612) | | **Raw value** | `WIFI:S:SB1Guest;P:12345;T:WEP;;` | | **WiFi information** | |--------------|----------| | **SSID** | SB1Guest | | **Password** | 12345 | | **Type** | WEP | | |"]]