Click or drag to resize
Getting Started

Getting Started Guide for Scandit BarcodeScanner for Windows

This document show how to get started using the Scandit BarcodeScanner SDK. It first starts by showing how to run the samples and describes the steps to add the SDK to your Windows 8.1 or Windows 10 application.

Running the SDK Sample Applications

All samples are contained in two solutions: Scandit.SdkSamples.Win8.vs12.sln and Scandit.SdkSamples.Universal.vs14.sln. The former contains samples for targetting Windows 8.1 applications, the latter for targetting Windows 10 Universal Store apps.

The simple sample projects (SimpleSamplePhone, SimpleSampleWin8 in the Windows 8.1 case, SimpleSampleUniversal for Windows 10) show the basic usage of the barcode picker API, whereas the BarcodeScannerWin8 sample shows how the barcode scanner can be configured at run-time using a settings dialog.

Before running the samples, you will have to replace the Scandit Application Key placeholder with your own app key that is visible in your Scandit Account. For the SimpleSampleWin8 project, the application key has to be placed in MainPage.xaml.cs. The place holder looks like this:

C#
static string ScanditBarcodeScannerAppKey = "-- ENTER YOUR SCANDIT LICENSE KEY HERE --";
Similarly, you will have to replace the application key in the MainPageView.xaml.cs file of the other projects.

Integrate the Scandit BarcodeScanner into your App

This section describes the steps to use the Scandit BarcodeScanner in your Windows 8.1 or Windows 10 Application. A simple project example that illustrates how to do this is included in the SimpleSampleWin8 project included in Scandit.SdkSamples.Win8.vs12.sln.

Add Scandit.BarcodePicker Assembly to your project

The barcode scanner is bundled as a NuGet package and you can install it through the NuGet package manager. You can do this in the package manager console, or from the UI in Visual Studio. In the following the steps for adding the package from the Visual Studio UI are described:

  • Right-click on References and select "Manage NuGet Packages...".
  • You will need to add the directory that contains the barcode picker package as a package source. Click on settings (in some versions of Visual Studio, the settings are accessible by clicking the cogwheel icon) and add the folder that contains the Scandit.BarcodePicker.$version.nupkg as a new package source.
  • Close the settings dialog
  • Select the newly added package source and select Scandit.BarcodePicker from the list of available packages.
  • Click on Install.

Please note that when targetting Windows 8.1, the library only runs on x86, but not ARM or x64. Likewise, the Windows 8.1 Phone Library only runs on ARM, but no other architectures. The Windows 10 universal package supports all architectures (x86, ARM, x64). Also note that it is currently not possible build/run your project when the AnyCPU is selected. You will need to select the x86/ARM depending on your current target platform.

Update the App Manifest

You will need to make a few adjustments to the App Manifest.

  • Update the App manifest to include microphone and webcam capabilities. Without it you will get a null-pointer exception when trying to initialize scanner.
  • Update the app manifest XML to contain the following extension. This class is required for accessing the raw camera frames from the VideoInputRT dll.
    Add Extension Class to the App Manifest
    <Extensions>
        <Extension Category="windows.activatableClass.inProcessServer">
        <InProcessServer>
            <Path>VideoInputRT.dll</Path>
            <ActivatableClass ActivatableClassId="VideoInputRT.FrameAccess" ThreadingModel="both" />
        </InProcessServer>
        </Extension>
    </Extensions>

Instantiating the Barcode Picker

It is possible to instantiate the barcode picker directly in your application code. However, the simplest solution is to instantiate the barcode picker inside the xaml file as shown below:

Define the BarcodePicker in Xaml
<Page ... xmlns:scandit="using:Scandit.BarcodePicker">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <scandit:BarcodePicker x:Name="thePicker" />
    </Grid>
</Page>

Configuring the Barcode Picker

Before starting the scanning process, you must set the Scandit license key to the application key you obtained on the Scandit.com website. If you do not set the application key, you will not be able to scan any barcodes and an error message will be displayed on top of the camera stream. For versions prior to 4.12, the application would terminate upon instantiating the picker.

Setting the Application Key
ScanditLicense.AppKey = "-- ENTER YOUR SCANDIT LICENSE KEY HERE --";

The scanning process is configured through scan settings. Scan settings control the enabled symbologies (barcode types) and allow to fine-tune the recognition behavior. By default, scanning of all barcode symbologies is disabled and you must explicitly enable the symbologies you require in your application.

Configuring the BarcodePicker
var scanSettings = new ScanSettings();
// enable a bunch of symbologies for scanning. Note that it's best to 
// only enable barcode symbologies that you are actually going to use 
// in your application as every symbology adds a processing overhead.
var symbologiesToEnable = new BarcodeSymbology[]
{
    BarcodeSymbology.Ean13,
    BarcodeSymbology.Upca,
    BarcodeSymbology.Ean8,
    BarcodeSymbology.Upce,
};
foreach (var sym in symbologiesToEnable)
    scanSettings.EnableSymbology(sym);
// apply the settings to the picker
await picker.ApplySettingsAsync(scanSettings);

Registering the Delegates

To get informed when a new barcode has been recognized, add a DidScan delegate to the barcode picker. Additionally, it's good practice to also register a Failed delegate to get notified and react to failures of the picker.

Registering the Delegates
// gets called whenever the picker encounters an error, e.g. the camera 
// could not be initialized.
picker.Failed += PickerFailed;
// gets called whenever a new barcode has been recognized. This is where 
// you put your custom logic for handling barcode scan results.
picker.DidScan += OnCodeScanned;
Sample Code Scanned Delegate
private void OnCodeScanned(ScanSession session)
{
    foreach (var code in session.NewlyRecognizedCodes)
        Debug.WriteLine("{0}: {1}", code.SymbologyString, code.Data);
}

Starting and Stopping of the BarcodePicker

Before any codes can be scanned, the BarcodePicker muste be started. This can be done by calling OpenCameraAndStartScanningAsync(DeviceInformation).

Starting the Scanning
var camera = await CameraSelection.FindBackFacingCameraOrDefault();
await picker.OpenCameraAndStartScanningAsync(camera);

When your are done, make sure to close the camera and stop the scanning with StopScanningAndCloseCameraAsync.

Stopping the Scanning
await picker.StopScanningAndCloseCameraAsync();
GPU Acceleration

The GPU acceleration support of the Windows SDK requires the ANGLE framework to translate OpenGL ES calls to Direct3D. For licensing reasons the ANGLE dependency is not included by default and has to be added manually.

Currently GPU acceleration can only be used in UWP projects. Make sure you comply with the ANGLE software license. Add the ANGLE NuGet package version 2.1.13 or newer to your project using the NuGet package manager in Visual Studio. No additional actions are required. The Scandit SDK will detect the presence of ANGLE and enable GPU acceleration automatically.