Barcode Scanner
using VoxelBusters.EasyMLKit;
using VoxelBusters.CoreLibrary;Create Instance
private BarcodeScanner CreateBarcodeScanner()
{
BarcodeScanner scanner = new BarcodeScanner();
return scanner;
}Prepare
private IImageInputSource CreateImageInputSource(Texture2D texture)
{
return new ImageInputSource(texture);
}
private IImageInputSource CreateLiveCameraInputSource()
{
IImageInputSource inputSource = new LiveCameraInputSource()
{
EnableFlash = false,
IsFrontFacing = false
};
return inputSource;
}
private BarcodeScannerOptions CreateBarcodeScannerOptions()
{
BarcodeScannerOptions.Builder builder = new BarcodeScannerOptions.Builder();
builder.SetScannableFormats(BarcodeFormat.QR_CODE);//BarcodeFormat.QR_ALL;
return builder.Build();
}
private void Prepare()
{
IImageInputSource inputSource = CreateImageInputSource(TEXTURE);// Pass "readable" texture here.
BarcodeScannerOptions options = CreateBarcodeScannerOptions();
Debug.Log("Starting prepare...");
scanner.Prepare(inputSource, options, OnPrepareComplete);
}
private void OnPrepareComplete(BarcodeScanner scanner, Error error)
{
Debug.Log("Prepare complete..." + error);
if (error == null)
{
Debug.Log("Prepare completed successfully!");
}
else
{
Debug.Log("Failed preparing Barcode scanner : " + error.Description);
}
}Process
Close
Last updated