BlinkIDDirectAPIDemo.MainPage.photoChooserTask_Completed C# (CSharp) Method

photoChooserTask_Completed() private method

When user chooses a photo starts the recognition process
private photoChooserTask_Completed ( object sender, PhotoResult e ) : void
sender object
e PhotoResult
return void
        void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK) {
                SetScanInProgress();
                BitmapSource image = new BitmapImage();
                image.SetSource(e.ChosenPhoto);

                // setup direct API
                Recognizer directRecognizer = Recognizer.GetSingletonInstance();
                // register event handlers
                if (directRecognizer.CurrentState == RecognizerDirectAPIState.OFFLINE) {
                    directRecognizer.OnScanningDone += mRecognizer_OnScanningDone;
                    // unlock direct API
                    try {
                        directRecognizer.LicenseKey = "Add license key here";
                    }
                    catch (InvalidLicenseKeyException exception) {
                        MessageBox.Show("Could not unlock API! Invalid license key!\nThe application will now terminate!");
                        Application.Current.Terminate();
                    }
                }
                // add MRTD recognizer settings
                if (directRecognizer.CurrentState == RecognizerDirectAPIState.UNLOCKED) {
                    directRecognizer.Initialize(new GenericRecognizerSettings(), new Microblink.IRecognizerSettings[] { new Microblink.MRTDRecognizerSettings() });
                }
                // start recognition
                directRecognizer.Recognize(image);
            }
        }