Better UI for camera preview in a QR Code reader sample using MediaCapture RRS feed

  • Question

  • Hello,

    I'm new to Windows Phone 8.1 SDK and I'm doing an app that should read qr code.

    But many samples are designed for Windows Phone 8 SDK unfortunately.

    Right now I'm using WP8.1 SDK, ZXing.net library to parse the image and a MediaCapture object to capture and a there is a Timer that calls a method that scan the image.

    I'm capturing the photo like this:

    // grab a camera snapshot
                    InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream();
                    await Camera.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream);

    In that way, the shutter sounds goes on and the CaptureElement object for previewing freezes for a little time and then continue showing the camera preview.

    but my goal is to avoid the shutting sound and the freezing of the CaptureElement.

    Is there a better way to achieve that? And, is there a QR Code Sample USING WINDOWS PHONE 8.1 SDK.

    Thanks in advance,

    Wednesday, October 22, 2014 8:16 AM


  • Unfortunately the MediaCapture API currently doesn't provide easy access to preview frames. You could implement a custom Sink to feed the preview stream into but that would disable preview to screen (unless you rendered the preview frame to a writeableBitmap afterwards).

    The best solution would be to write a custom MFT and insert that into the preview pipeline to extract the data for ZXing.net. So far I know of no one who has done so and published it (I also don't know anyone who implemented it).

    When you do your App using Silverlight 8.1 you can use the old Camera API and implement everything the way it was done in 8.0. If the QR code scanning is a central part of your App's experience and you don't feel comfortable implementing a custom MFT in native code then switching over to the old API is likely to be the best approach.

    PS: I have to say: it's an issue that comes up very often right now - so I hope that either the preview API will be improved in the next version of Windows or that someone implements such a MFT and publishes it.
    Wednesday, October 22, 2014 8:54 AM