All Projects → JimmyPun610 → Barcodescanner.xf

JimmyPun610 / Barcodescanner.xf

Licence: mit
Barcode Scanner using GoogleVision API for Xamarin Form

Projects that are alternatives of or similar to Barcodescanner.xf

barcode-server
Barcode Server for Barcode Client-Server android application
Stars: ✭ 40 (-51.22%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
QRManager
This is an example that uses ZXing.Net.Mobile for Forms. See more information here:
Stars: ✭ 19 (-76.83%)
Mutual labels:  xamarin, qrcode, xamarin-forms, qrcode-scanner
barcode scan2
[reborned barcode_scan] A flutter plugin for reading 2D barcodes and QR codes.
Stars: ✭ 43 (-47.56%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
Zxinglite
🔥 ZXing的精简版,优化扫码和生成二维码/条形码,内置闪光灯等功能。扫描风格支持:微信的线条样式,支付宝的网格样式。几句代码轻松拥有扫码功能 ,ZXingLite让集成更简单。(扫码识别速度快如微信)
Stars: ✭ 2,117 (+2481.71%)
Mutual labels:  qrcode-scanner, barcode-scanner, qrcode, barcode
Scannermapp
A QR-code and barcode acanner app built in Delphi using ZXing and TFrameStand
Stars: ✭ 65 (-20.73%)
Mutual labels:  qrcode-scanner, barcode-scanner, qrcode, barcode
BarcodeReader
Simple multi-format barcode reader for Windows
Stars: ✭ 26 (-68.29%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
React Native Qrcode Scanner
A QR code scanner component for React Native.
Stars: ✭ 1,796 (+2090.24%)
Mutual labels:  qrcode-scanner, camera, qrcode, barcode
android-zbar-sdk
🔗 android-zbar-sdk, provide jni source, so file and jar file used alone, gradle/maven remote dependencies.
Stars: ✭ 311 (+279.27%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
Efqrcode
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.
Stars: ✭ 4,121 (+4925.61%)
Mutual labels:  qrcode-scanner, barcode-scanner, qrcode, barcode
barcode-detector
Spec compliant polyfill of the Barcode Detection API 🤳
Stars: ✭ 31 (-62.2%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
Qr Code Scanner
📠 A simple, fast and useful progressive web application
Stars: ✭ 982 (+1097.56%)
Mutual labels:  qrcode-scanner, barcode-scanner, qrcode, barcode
Quagga2
An advanced barcode-scanner written in Javascript and TypeScript - Continuation from https://github.com/serratus/quaggajs
Stars: ✭ 198 (+141.46%)
Mutual labels:  barcode-scanner, camera, barcode
Nbzxing
🔥 2020年最好用的开源扫码,全方位优化,强烈推荐!! 支持多种常规zxing无法扫出的码,用就完了!! 🔥
Stars: ✭ 184 (+124.39%)
Mutual labels:  camera, qrcode, barcode
Barcode To Pc App
Barcode to PC app
Stars: ✭ 121 (+47.56%)
Mutual labels:  qrcode-scanner, barcode-scanner, barcode
flutter scan
scanner qrcode in widget tree & decoder qrcode from image
Stars: ✭ 63 (-23.17%)
Mutual labels:  camera, qrcode, qrcode-scanner
Qzxing
Qt/QML wrapper library for the ZXing library. 1D/2D barcode image processing library
Stars: ✭ 401 (+389.02%)
Mutual labels:  barcode-scanner, qrcode, barcode
Swiftscan
A barcode and qr code scanner( 二维码/条形码扫描、生成,仿微信、支付宝)
Stars: ✭ 293 (+257.32%)
Mutual labels:  qrcode-scanner, qrcode, barcode
Cordova Plugin Qrscanner
A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
Stars: ✭ 485 (+491.46%)
Mutual labels:  qrcode-scanner, camera, qrcode
Czxing
C++ port of ZXing and ZBar for Android.
Stars: ✭ 854 (+941.46%)
Mutual labels:  qrcode-scanner, qrcode, barcode
Qrcodereader.swift
Simple QRCode reader in Swift
Stars: ✭ 1,202 (+1365.85%)
Mutual labels:  qrcode-scanner, qrcode

BarcodeScanner.XF

Powerful barcode scanning library for Xamarin Forms using GoogleVision API.

Works on iOS 10+ and Android (MonoAndroid10.0 and MonoAndroid11.0)

For Android, it use Xamarin.GooglePlayServices.Vision For iOS, it use GoogleMobileVision under MLKit library

Please feel free to improve my source code.

Current Version

5.0.0.0 for Xamarin Forms 5.0.0.1905

4.8.2 for Xamarin Forms 4.8.0.1687+

4.8.1.1 for Xamarin Forms 4.8.0.1541+, Removed MonoAndroid 9 support, please make sure the target framework is Android 10 or 11

4.7.0.2 for Xamarin Form 4.7.0.968+

4.6.1 for Xamarin Form 4.6.0.772+, Please notice the assembly name is changed. (See sample xaml)

Release notes

https://github.com/JimmyPun610/BarcodeScanner.XF/tree/master/ReleaseNotes

App Center Build

Android Build status
iOS Build status

Installation

  1. Install Nuget package to Forms, Android and iOS project
Install-Package BarcodeScanner.XF

Android setup

  1. Manifest.xml
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.CAMERA" />
  1. Init the library in MainActivity.cs
  base.OnCreate(savedInstanceState);
...
  GoogleVisionBarCodeScanner.Droid.RendererInitializer.Init();
...
  global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
  LoadApplication(new App());
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
    Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

iOS Setup

  1. Edit Info.plist, add camera rights
	<key>NSCameraUsageDescription</key>
	<string>Require to use camera</string>
  1. Create an project in Google Firebase Console, download GoogleService-Info.plist https://console.firebase.google.com/

  2. Put GoogleService-Info.plist into Resources folder of iOS project, set Build Action as BundleResource

  3. Init project and firebase on AppDelegate.cs

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());
            ....
            GoogleVisionBarCodeScanner.iOS.Initializer.Init();
            // Temporary work around for bug on Firebase Library
	    // https://github.com/xamarin/GoogleApisForiOSComponents/issues/368
	    Firebase.Core.App.Configure();
	    _ = Firebase.RemoteConfig.RemoteConfig.SharedInstance;
            ....
            return base.FinishedLaunching(app, options);
  1. Set Linker Behavior to Link SDK assemblies only

Scan from Camera

1. Set support barcode format (Default is all), call it before you start to init CameraView

GoogleVisionBarCodeScanner.Methods.SetSupportBarcodeFormat(BarcodeFormats.QRCode);

2. It is all about the camera view, use it on the page.xaml. For now, it will spend your whole width of the screen and the height will be equal to width.

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:gv="clr-namespace:GoogleVisionBarCodeScanner;assembly=BarcodeScanner.XF"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="SampleApp.Page1">
   <ContentPage.Content>
     <ScrollView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
	 <!--VirbationOnDetected: Indicate the device will vibrate or not when detected barcode, default is True
		 DefaultTorchOn: Indicate the torch will on or not when the view appear, default is False
		 AutoStartScanning : Indicate whether the device will start scanning after it is opened, default is True
		 RequestedFPS: Affect Android only, leave it if you want a default value (https://developers.google.com/android/reference/com/google/android/gms/vision/CameraSource.Builder.html#public-camerasource.builder-setrequestedfps-float-fps)
		 -->
             <gv:CameraView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" OnDetected="CameraView_OnDetected" Grid.Row="1"
                            DefaultTorchOn="True" VibrationOnDetected="False" AutoStartScanning="True" RequestedFPS="30"/>
     </ScrollView>
   </ContentPage.Content>
</ContentPage>

3. Once barcode detected, "OnDetected" event will be triggered, do the stuff you want with the barcode, it will contains type and display value

   private async void CameraView_OnDetected(object sender, GoogleVisionBarCodeScanner.OnDetectedEventArg e)
        {
            List<GoogleVisionBarCodeScanner.BarcodeResult> obj = e.BarcodeResults;

            string result = string.Empty;
            for(int i = 0; i < obj.Count; i++)
            {
                result += $"{i + 1}. Type : {obj[i].BarcodeType}, Value : {obj[i].DisplayValue}{Environment.NewLine}";
            }
            Device.BeginInvokeOnMainThread(async() =>
            {
                await DisplayAlert("Result", result, "OK");
		//If you want to stop scanning, you can close the scanning page
                await Navigation.PopModalAsync();
		//if you want to keep scanning the next barcode, do not close the scanning page and call below function
		//GoogleVisionBarCodeScanner.Methods.SetIsScanning(true);
            });
            
        }

4. To use torch, please call

   GoogleVisionBarCodeScanner.Methods.ToggleFlashlight();

5. To ask for permission

bool allowed = await GoogleVisionBarCodeScanner.Methods.AskForRequiredPermission();

6. To check the condition of torch

   GoogleVisionBarCodeScanner.Methods.IsTorchOn();

7. Restart scanning

//Old method, you can use the new one.
//GoogleVisionBarCodeScanner.Methods.Reset();
GoogleVisionBarCodeScanner.Methods.SetIsScanning(true);

Scan from Image

1. Get the image byte array by your method.

//Used MediaPlugin in sample for example
 var file = await CrossMedia.Current.PickPhotoAsync();
Stream stream = file.GetStream();
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
stream.Seek(0, SeekOrigin.Begin);

2. Analyze the image and wait for result

List<GoogleVisionBarCodeScanner.BarcodeResult> obj = await GoogleVisionBarCodeScanner.Methods.ScanFromImage(bytes);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].