Skip to content

Commit

Permalink
decrease analysis resolution and use yuv
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-mh committed Jun 12, 2024
1 parent f0e5b8a commit a940a28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AuthenticatorPro.Droid/src/Activity/ScanActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected override async void OnCreate(Bundle savedInstanceState)

var analysis = new ImageAnalysis.Builder()
.SetBackpressureStrategy(ImageAnalysis.StrategyKeepOnlyLatest)
.SetOutputImageFormat(ImageAnalysis.OutputImageFormatRgba8888)
.SetOutputImageFormat(ImageAnalysis.OutputImageFormatYuv420888)
.Build();

var analyser = new QrCodeImageAnalyser();
Expand Down
5 changes: 3 additions & 2 deletions AuthenticatorPro.Droid/src/QrCode/QrCodeImageAnalyser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ namespace AuthenticatorPro.Droid.QrCode
public class QrCodeImageAnalyser : Java.Lang.Object, ImageAnalysis.IAnalyzer
{
public event EventHandler<string> QrCodeScanned;
public Size DefaultTargetResolution => new(1920, 1080);
public Size DefaultTargetResolution => new(640, 480);

private readonly ILogger _log = Log.ForContext<QrCodeImageAnalyser>();

private readonly QrCodeReader _qrCodeReader = new(new ReaderOptions
{
TryRotate = true,
TryHarder = true,
Binarizer = Binarizer.LocalAverage
});

Expand Down Expand Up @@ -48,7 +49,7 @@ private void AnalyseInternal(IImageProxy imageProxy)
var bytes = new byte[plane.Buffer.Capacity()];
plane.Buffer.Get(bytes);

using var imageView = new ImageView(bytes, imageProxy.Width, imageProxy.Height, ImageFormat.RGBA);
using var imageView = new ImageView(bytes, imageProxy.Width, imageProxy.Height, ImageFormat.Lum, plane.RowStride, plane.PixelStride);
string result;

try
Expand Down

0 comments on commit a940a28

Please sign in to comment.