Im looking for a solution to read a QRCode on a webpage.
Lets say I've generated with PHP and some library (zxing or something else) a QRCode and its printed on a piece of paper, ok?
What i would like to do now, is to read it back with tablet/smartphone throught a web-page. I browse to that page, it asks me to aim the QRCode with the camera, and then the scanned content is sent back to the page that decodes it.
There's something out there to handle this without the need to use an Android/iOS app? It could be another type of 2D barcode aswell, not exclusively a QRCode.
TY
I have once worked with Lazarsoft's jsqrcode
It worked fine in the browser, and I know he made a demo to test on a phone with camera.
Here is his repository: https://github.com/LazarSoft/jsqrcode
For camera support: use the CamCanvas API: http://www.taboca.com/p/camcanvas/
You can read QR Codes using instascan.
Copy instascan.min.js from the releases page and load with:
<script type="text/javascript" src="instascan.min.js"></script>
Sample code to read QR Code.
<!DOCTYPE html>
<html>
<head>
<title>QR Code Reader using Instascan</title>
<script type="text/javascript" src="instascan.min.js"></script>
</head>
<body>
<video id="preview"></video>
<script type="text/javascript">
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
scanner.addListener('scan', function (content) {
console.log(content);
});
Instascan.Camera.getCameras().then(function (cameras) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error('No cameras found.');
}
}).catch(function (e) {
console.error(e);
});
</script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With