Barcode Detection API: 用于检测图像中的条形码和二维码
// 创建新检测器
const barcodeDetector = new BarcodeDetector({
formats: ["qr_code"],
});
// 检查支持的类型
BarcodeDetector?.getSupportedFormats().then((supportedFormats) => {
supportedFormats.forEach((format) => console.log(format));
});
const barcodeDetector = new BarcodeDetector({
formats: ["qr_code"],
});
// 检测二维码
barcodeDetector
.detect(imageEl)
.then((barcodes) => {
barcodes.forEach((barcode) => console.log(barcode.rawValue));
})
.catch((err) => {
console.log(err);
});
标签:barcodeDetector,console,log,BarcodeDetector,Barcode,Detection,API
From: https://www.cnblogs.com/chlai/p/18168101