afriscic / BarcodeScanning.Native.Maui

Barcode scanning library for .NET MAUI
https://www.nuget.org/packages/BarcodeScanning.Native.Maui
MIT License
186 stars 35 forks source link

I have a question. Please help me.. #24

Closed yunri91 closed 9 months ago

yunri91 commented 9 months ago

Hello. I am writing to you because I have a question.

The project is implementing a camera barcode scan, I've tried to test the barcode scanning function, but no matter how many cameras I put on the barcode, the value is 0 or null in 'CameraView_OnDetectionFinished'. What's the reason?

`<barcode:CameraView AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1" OnDetectionFinished="CameraView_OnDetectionFinished" CaptureQuality="High" ForceInverted="False" TapToFocusEnabled="True" BarcodeSymbologies="All" CameraEnabled="True"

                        x:Name="Barcode"/>

private void CameraView_OnDetectionFinished(object sender, OnDetectionFinishedEventArg e) {

if (e.BarcodeResults.Count > 0)
{
    //
}

var barcodeResults = e.BarcodeResults;
if (barcodeResults.Count > 0)
{

}
foreach (var result in e.BarcodeResults)
{

}
_drawable.barcodeResults = e.BarcodeResults;
Graphics.Invalidate();

}

Is the modal method the problem? Above is the part that I call in my Main Page.

` var barcodeScan = new BarcodeScan(); barcodeScan.OnValueScanned += (sender, value) => { if (value != null && value != "") { string valueFromPopup = value;

}

}; await Navigation.PushModalAsync(barcodeScan); `

yunri91 commented 9 months ago

@afriscic I'm sorry! Fortunately, I checked that the scan value came in normally, The CameraView_OnDetectionFinished method seems to have values coming in successively, so I think I just need to check that part! Thank you for providing me with a good library!

afriscic commented 9 months ago

Hello.

Sorry, I don't really understand your question but looks like you figured it out. CameraView_OnDetectionFinished triggering is by design. OnDetectionFinished is called every time BarcodeAnalyzer finishes processing, if everything works well multiple times a second. This is to enable continuous feedback of the scanning process.

As everything seems OK I'll close the issue.