Closed msi-matthew closed 5 years ago
Sorry, but this is not a support forum. Please in the future ask such questions on a platform like StackOverflow.
In your case, simply no barcode is being detected I guess, so you're iterating over an empty array. If this.$.pic
is an <img>
, then it doesn't have a toDataURL()
function, which explains the error in your second attempt. The <img>
itself should work. Try testing it with a different image, or on a different platform (Chrome on Android works best from my limited experience).
As an aside, the barcode detection module seems to be broken on macOS Chrome (Version 72.0.3626.109 (Official Build) (64-bit)).
The demo at (https://shape-detection-demo.glitch.me/) is returning an empty array for the QR code, and in my project I get the same behavior when trying to scan a Code 128
barcode.
QR Demo is working on Chrome Android and Canary Android.
There was a regression regarding barcodes on macOS Chrome (71 or 72, don’t remember exactly), it has been fixed since.
OK.
Thank you for all your help this week and the excellent demos you put together!
I have a canvas that gets populated with "image" data for lack of a better term, and am trying to run a barcode scan on it.
Using
this.$.pic
nothing is logged to the console (I would expectnull
,undefined
, or a result.When I try
this.$.pic.toDataURL("image/png")
I get the following error:What data type or DOM attribute must be passed into
barcodeDetector.detect()
to parse the image?I'm not sure what form
HTMLImageElement
orHTMLCanvasElement
take.