You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm migrating from Xamarin to .NET7 and have a WInUI3 Application which uses a QR Code Reader. In WinUI3 there is no CaptureElement for the Preview Stream of the Camera. But there is now a possibility to get the Camera Stream and every Frame. I tried to decode a frame with the Barcode Reader Object but it does not detect any QR Code.
Do You have any idea why? Here is the code snippet for getting every MediaPlayer frame
privatevoidMediaFrameReader_FrameArrived(MediaFrameReadersender,MediaFrameArrivedEventArgsargs){varmediaframeReader=senderasMediaFrameReader;if(mediaframeReader!=null){varmfr=mediaframeReader.TryAcquireLatestFrame();varvideoMediaFrame=mfr?.VideoMediaFrame;varsoftwareBitmap=videoMediaFrame?.SoftwareBitmap;if(softwareBitmap==null){return;}Debug.WriteLine($"SoftwareBitMap:{BitConverter.ToString(EncodedBytes(softwareBitmap,BitmapEncoder.JpegEncoderId).Result)}");if(softwareBitmap.BitmapPixelFormat!=BitmapPixelFormat.Bgra8||softwareBitmap.BitmapAlphaMode!=BitmapAlphaMode.Premultiplied){softwareBitmap=SoftwareBitmap.Convert(softwareBitmap,BitmapPixelFormat.Bgra8,BitmapAlphaMode.Premultiplied);}// From this point on, follow Microsoft's 'CameraFrames' universal sample to process the frame and do what you want with it: https://github.com/microsoft/Windows-universal-samplesvarformats=newList<BarcodeFormat>{BarcodeFormat.DATA_MATRIX,BarcodeFormat.QR_CODE};varbarcodeReader=newBarcodeReader(){//AutoRotate = true,//TryInverted = true};barcodeReader.Options.PossibleFormats=formats;// Create our luminance sourcevarluminanceSource=newSoftwareBitmapLuminanceSource(softwareBitmap);Debug.WriteLine(BitConverter.ToString(luminanceSource.Matrix,0,50));varresult=barcodeReader.Decode(luminanceSource);if(result!=null){Debug.WriteLine($"Result Format:{result.BarcodeFormat}");}// Check if a result was foundif(result!=null&&!string.IsNullOrEmpty(result.Text)){Debug.WriteLine($"ScanResult is Text: {result.Text}");}softwareBitmap?.Dispose();mfr?.Dispose();}}
The text was updated successfully, but these errors were encountered:
I'm migrating from Xamarin to .NET7 and have a WInUI3 Application which uses a QR Code Reader. In WinUI3 there is no
CaptureElement
for the Preview Stream of the Camera. But there is now a possibility to get the Camera Stream and every Frame. I tried to decode a frame with theBarcode Reader
Object but it does not detect any QR Code.Do You have any idea why? Here is the code snippet for getting every
MediaPlayer
frameAnd here is the Eventhandler:
The text was updated successfully, but these errors were encountered: