اسکن بارکد
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.

با API اسکن بارکد ML Kit، می توانید داده های کدگذاری شده را با استفاده از اکثر فرمت های بارکد استاندارد بخوانید. اسکن بارکد در دستگاه انجام می شود و نیازی به اتصال شبکه ندارد.
بارکدها راهی مناسب برای انتقال اطلاعات از دنیای واقعی به برنامه شما هستند. به طور خاص، هنگام استفاده از فرمتهای دو بعدی مانند کد QR، میتوانید دادههای ساختاریافته مانند اطلاعات تماس یا اعتبار شبکه WiFi را رمزگذاری کنید. از آنجایی که ML Kit میتواند بهطور خودکار این دادهها را شناسایی و تجزیه کند، برنامه شما میتواند به صورت هوشمندانه زمانی که کاربر بارکد را اسکن میکند، پاسخ دهد.
برای کاربرانی که به رابط کاربری سفارشی نیاز ندارند، توصیه میکنیم از اسکنر کد Google استفاده کنند. API اسکنر کد از همان مدل استنباط با API استاندارد اسکن بارکد استفاده میکند، اما تنها متمرکزترین بارکد را برای تجربه سریعتر و سازگارتر برمیگرداند. اسکنر کد گوگل نیز ایمن تر و بدون مجوز است و نیازی به پیاده سازی یا مجوزهای مرتبط با دوربین ندارد.
iOS Android اسکنر کد گوگل
قابلیت های کلیدی
- اکثر فرمت های استاندارد را می خواند
- فرمت های خطی: Codabar، کد 39، کد 93، کد 128، EAN-8، EAN-13، ITF، UPC-A، UPC-E
- فرمت های دو بعدی: آزتک، ماتریس داده، PDF417، کد QR
- تشخیص فرمت خودکار
- همه فرمتهای بارکد پشتیبانیشده را بهطور همزمان بدون نیاز به تعیین فرمت مورد نظر اسکن کنید، یا با محدود کردن آشکارساز به قالبهایی که به آنها علاقه دارید، سرعت اسکن را افزایش دهید.
- داده های ساخت یافته را استخراج می کند
- داده های ساخت یافته ای که با استفاده از یکی از فرمت های 2 بعدی پشتیبانی شده ذخیره می شوند، به طور خودکار تجزیه می شوند. انواع اطلاعات پشتیبانی شده شامل آدرسهای اینترنتی، اطلاعات تماس، رویدادهای تقویم، آدرسهای ایمیل، شماره تلفن، پیامهای پیام کوتاه، ISBN، اطلاعات اتصال WiFi، موقعیت جغرافیایی و اطلاعات درایور استاندارد AAMVA است.
- با هر جهتی کار می کند
- بارکدها بدون توجه به جهت آنها شناسایی و اسکن می شوند: سمت راست به بالا، وارونه، یا پهلو.
- روی دستگاه اجرا می شود
- اسکن بارکد به طور کامل بر روی دستگاه انجام می شود و نیازی به اتصال به شبکه ندارد.
توجه داشته باشید که این API بارکدها را در این اشکال شناسایی نمی کند:
- بارکدهای 1 بعدی تنها با یک کاراکتر
- بارکدهایی در قالب ITF با کمتر از شش کاراکتر، و این قالب به دلیل عدم وجود چکسوم، پوسته پوسته است.
- بارکدهای کدگذاری شده با FNC2، FNC3 یا FNC4
- کدهای QR تولید شده در حالت ECI
این 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;; | اطلاعات وای فای | SSID | SB1 Guest | کلمه عبور | 12345 | تایپ کنید | WEP |
|
|
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[[["\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 | | |"]]