How correct way to preview video and recognize QR (any codes with ZXing)?
In windows phone 8.1 i start preview with MediaCapture and with VideoEffect recognize QR code.
In Universal Windows VideoEffect not work.
Recognize by timer with CapturePhotoToStorageFileAsync is slowly.
So, my solution
Create new WinRT project "Windows Runtime Component (Universal Windows)
In WinRT create
class CaptureVideoEffect : IBasicVideoEffect (from Windows.Media.Effects)
await capture.AddEffectAsync(MediaStreamType.VideoPreview, typeof(CaptureVideoEffect).FullName, ...);
Now in CaptureVideoEffect.ProcessFrame(ProcessVideoFrameContext context) you get RealTime video output
In CaptureVideoEffect.ProcessFrame skip frame if previous not finish decoded
Get image as byte[]
var frameSize = inputFrameBitmap.PixelWidth * inputFrameBitmap.PixelHeight * 4;
var frameBuffer = new Windows.Storage.Streams.Buffer((uint)frameSize);
inputFrameBitmap.CopyToBuffer(frameBuffer);
byte[] bitmap = frameBuffer.ToArray();
result = barcodeReader.Decode(bitmap, inputFrameBitmap.PixelWidth, inputFrameBitmap.PixelHeight, BitmapFormat.RGB32);
public sealed class BarcodeReader
{
public Result Decode([ReadOnlyArray] byte[] rawRGB, int width, int height, BitmapFormat format);
}