This project has moved. For the latest updates, please go here.

QR reader for windowsphone 8.1

Jan 13, 2015 at 9:05 PM
Hi,
I am really new on this and I need to create a "WindowsPhone 8.1 App" ( not a Silverlight project) for Reading QR

I 've found the WindowsRTDemo and I'm trying to copy paste the code in my winPhone App, it finally compiles after adding some "using"
Now I lunch the program on my Lumia920 and I get "Access Denied" as error, I got no Idea why

The code is from the WindowsRTDemo:

protected override async void OnNavigatedTo(NavigationEventArgs e)
    {
        try
        {
            var cameras = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);
            if (cameras.Count < 1)
            {
                Error.Text = "No camera found, decoding static image";
                await DecodeStaticResource();
                return;
            }
            MediaCaptureInitializationSettings settings;
            if (cameras.Count == 1)
            {
                settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[0].Id }; // 0 => front, 1 => back
            }
            else
            {
                settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[1].Id }; // 0 => front, 1 => back
            }

            await _mediaCapture.InitializeAsync(settings);
            VideoCapture.Source = _mediaCapture;
            await _mediaCapture.StartPreviewAsync();

            while (_result == null)
            {
                var photoStorageFile = await Windows.Storage.KnownFolders.PicturesLibrary.CreateFileAsync("scan.jpg", CreationCollisionOption.GenerateUniqueName);
                await _mediaCapture.CapturePhotoToStorageFileAsync(ImageEncodingProperties.CreateJpeg(), photoStorageFile);

                var stream = await photoStorageFile.OpenReadAsync();
                // initialize with 1,1 to get the current size of the image
                var writeableBmp = new WriteableBitmap(1, 1);
                writeableBmp.SetSource(stream);
                // and create it again because otherwise the WB isn't fully initialized and decoding
                // results in a IndexOutOfRange
                writeableBmp = new WriteableBitmap(writeableBmp.PixelWidth, writeableBmp.PixelHeight);
                stream.Seek(0);
                writeableBmp.SetSource(stream);

                _result = ScanBitmap(writeableBmp);

                await photoStorageFile.DeleteAsync(StorageDeleteOption.PermanentDelete);
            }

            await _mediaCapture.StopPreviewAsync();
            VideoCapture.Visibility = Visibility.Collapsed;
            CaptureImage.Visibility = Visibility.Visible;
            ScanResult.Text = _result.Text;
        }
        catch (Exception ex)
        {
            Error.Text = ex.Message;
        }

    }

I got the Access denied exception on the line "await _mediaCapture.InitializeAsync(settings);"

Is there a tutorial? or video or something to learn how to use ZXing??? I am sure my error is beacuse I dont have Idea about how to make the programing with zxing.net

thanks for any help, code, tutorial, example

thnks!!!
Coordinator
Jan 14, 2015 at 8:50 PM
Please take a look at the following stackoverflow question:
http://stackoverflow.com/questions/25492350/capturing-video-in-wp-8-1-preview-back-with-universal-apps
Perhaps you have the same problem.

There are no official tutorials or videos.
You can only look at the different sample apps.