Scansione di codici a barre
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.

Con l'API di scansione dei codici a barre di ML Kit, puoi leggere i dati codificati utilizzando
la maggior parte dei formati di codici a barre standard. La scansione dei codici a barre viene eseguita sul dispositivo e non
richiede una connessione di rete.
I codici a barre sono un modo pratico per passare informazioni dal mondo reale alla tua app. In particolare, se utilizzi formati 2D come i codici QR, puoi codificare dati strutturati come i dati di contatto o le credenziali della rete Wi-Fi. ML Kit è in grado di riconoscere e analizzare automaticamente questi dati, pertanto la tua app può rispondere in modo intelligente quando un utente esegue la scansione di un codice a barre.
Per gli utenti che non richiedono un'interfaccia utente personalizzata, consigliamo di utilizzare lo scanner di codici di Google. L'API
di scansione del codice utilizza lo stesso modello di inferenza dell'API standard di scansione dei codici a barre,
ma restituisce solo il codice a barre più centralizzato per un'esperienza
più rapida e coerente. Lo scanner di codici Google è inoltre più sicuro e senza autorizzazioni e non richiede autorizzazioni o implementazioni correlate alla fotocamera.
iOS
Android
Scanner di codici di Google
Funzionalità chiave
- Legge la maggior parte dei formati standard
- Formati lineari: Codabar, Code 39, Code 93, Code 128, EAN-8, EAN-13, ITF, UPC-A, UPC-E
- Formati 2D: Aztec, Data Matrix, PDF417, QR Code
- Rilevamento automatico del formato
- Scansiona tutti i formati di codici a barre supportati contemporaneamente senza dover specificare il formato desiderato oppure aumenta la velocità di scansione limitando il rilevatore ai soli formati che ti interessano.
- Estrae dati strutturati
- I dati strutturati archiviati utilizzando uno dei formati 2D supportati vengono analizzati automaticamente. I tipi di informazioni supportati includono URL, dati di contatto, eventi di calendario, indirizzi email, numeri di telefono, richieste di messaggi SMS, codici ISBN, informazioni sulla connessione Wi-Fi, posizione geografica e informazioni sul driver standard AAMVA.
- Compatibile con qualsiasi orientamento
- I codici a barre vengono riconosciuti e scansionati indipendentemente dal loro orientamento:
a destra, capovolti o lateralmente.
- Esecuzione sul dispositivo
- La scansione dei codici a barre viene eseguita completamente sul dispositivo e non richiede una connessione di rete.
Tieni presente che questa API non riconosce i codici a barre nei seguenti formati:
- Codici a barre 1D con un solo carattere
- Codici a barre in formato ITF con meno di sei caratteri. Questo formato è noto per essere irregolare a causa dell'assenza di checksum
- Codici a barre codificati con FNC2, FNC3 o FNC4
- Codici QR generati in modalità ECI
Questa API riconosce non più di 10 codici a barre per chiamata API.
Risultati di esempio
|
Risultato |
Angoli |
(49.125), (172.125), (172.160), (49.160) |
Valore non elaborato |
2404105001722 |
|
|
Risultato |
Angoli |
(87.87) (612.87) (612.612) (87.612) |
Valore non elaborato |
WIFI:S:SB1Guest;P:12345;T:WEP;; |
Informazioni sul Wi-Fi |
SSID |
SB1Guest |
Password |
12345 |
Digitare |
WEP |
|
|
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-29 UTC.
[null,null,["Ultimo aggiornamento 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 | | |"]]