條碼掃描
透過集合功能整理內容
你可以依據偏好儲存及分類內容。

您可以透過 ML Kit 的條碼掃描 API 讀取使用大多數標準條碼格式編碼的資料。條碼掃描功能是在裝置端進行,因此不需要網路連線。
條碼是將現實世界中的資訊傳送到應用程式的方法,特別是使用 QR code 等 2D 格式時,您可以將結構化資料 (例如聯絡資訊或 Wi-Fi 網路憑證) 編碼。由於 ML Kit 可自動辨識及剖析這項資料,因此應用程式可以在使用者掃描條碼時聰明回應。
如果使用者不需要自訂 UI,我們建議使用 Google 程式碼掃描器。程式碼掃描器 API 使用與標準條碼掃描 API 相同的推論模型,但只會傳回最集中的條碼,藉此提供更快速且更一致的體驗。Google 程式碼掃描器也較安全且無權限,不需要相關的相機實作或權限。
iOS
Android
Google 圖碼掃描器
主要功能
- 讀取大部分標準格式
- 線性格式:Codabar、Code 39、Code 93、Code 128、EAN-8、EAN-13、ITF、UPC-A、UPC-E
- 2D 格式:Aztec、資料矩陣、PDF417、QR Code
- 自動格式偵測
- 一次掃描所有支援的條碼格式,不必指定所需格式,也可以限制偵測工具僅傳回您需要的格式,藉此提高掃描速度。
- 擷取結構化資料
- 系統會自動剖析使用其中一種支援的 2D 格式儲存的結構化資料。支援的資訊類型包括網址、聯絡資訊、日曆活動、電子郵件地址、電話號碼、簡訊提示、ISBN、Wi-Fi 連線資訊、地理位置,以及 AAMVA 標準驅動程式資訊。
- 支援任何方向
- 無論方向為何,系統都會辨識並掃描條碼:右側、向上、上下或側邊。
- 在裝置上執行
- 條碼掃描功能會完全在裝置上執行,不需要網路連線。
請注意,這個 API 無法辨識下列形式的條碼:
- 只有一個字元的 1D 條碼
- ITF 格式的條碼少於 6 個字元,且由於缺少總和檢查碼,因此這種格式相當不穩定
- 使用 FNC2、FNC3 或 FNC4 編碼的條碼
- ECI 模式產生的 QR code
這個 API 在每個 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 |
|
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-05 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-09-05 (世界標準時間)。"],[[["ML Kit's Barcode Scanning API reads data from most standard barcode formats, including linear and 2D formats, without needing an internet connection."],["It automatically detects and parses structured data like contact info, WiFi credentials, and more from supported 2D formats, enabling intelligent app responses."],["The API works offline, recognizing barcodes in any orientation, and the Google Code Scanner offers a faster, safer, and permissionless option for basic scanning needs."],["While 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."]]],["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"]]