hjam40 / Camera.MAUI

A CameraView Control for preview, take photos and control the camera options
MIT License
438 stars 69 forks source link

CameraView in .net MAUI taking too much time for scanning barcode and QR code #118

Open vplife1 opened 7 months ago

vplife1 commented 7 months ago

CameraView Performance Issue: Slow Barcode/QR Code Scanning

I am experiencing a significant performance issue with the CameraView in my .NET MAUI app when scanning barcodes and QR codes. The scanning process is taking much longer than expected, leading to delays in my application.

UI Code

Scan code `private void cameraView_CamerasLoaded(object sender, EventArgs e) { if (cameraView.Cameras.Count > 0) { cameraView.Camera = cameraView.Cameras.First(); MainThread.BeginInvokeOnMainThread(async () => { await cameraView.StopCameraAsync(); await cameraView.StartCameraAsync(); }); } }

private void cameraView_BarcodeDetected(object sender, Camera.MAUI.ZXingHelper.BarcodeEventArgs args)
{
    MainThread.BeginInvokeOnMainThread(() =>
    {
        barcodeResult.Text = $"{args.Result[0].BarcodeFormat}: {args.Result[0].Text}";
    });
}`

Steps to Reproduce Launch the .NET MAUI app. Navigate to the page containing the CameraView for barcode/QR code scanning. Attempt to scan a barcode or QR code. Observe the time it takes for the scanning process to complete.

Expected Behavior: I expect the barcode/QR code scanning process to be quick and responsive, providing results promptly.

Actual Behavior: The scanning process is noticeably slow, and there is a significant delay before the results are obtained.

programatix commented 7 months ago

Did you try Release build of your app? The Debug build is slower, perhaps due to the debug output it is generating.

sechabamot commented 7 months ago

Are you building for Android?

vplife1 commented 7 months ago

@sechabamot Yes

vplife1 commented 7 months ago

@programatix @sechabamot Anything found ?

programatix commented 7 months ago

@programatix @sechabamot Anything found ?

As mentioned, DEBUG build is indeed very slow. Try RELEASE build. For me, RELEASE build performs a lot better, about the same as other barcode scanning projects.

garcia252 commented 2 months ago

Did you find a solution to this @vplife1 ? We've been trying the latest version of 1.5.1 and it seems very slow. 1.2.1 looks better but how did you solve this?