Updates
commit
0cab0e9e0c
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QrcodeDecoder - Camera</title>
|
||||
</head>
|
||||
<body>
|
||||
<button id="start">Start</button> <button id="stop">Stop</button><br />
|
||||
<span id="result">Click start to scan qrcode.</span><br />
|
||||
<hr />
|
||||
<video id="video" autoplay></video>
|
||||
|
||||
<script src="./index.aio.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function main() {
|
||||
var qr = new QrcodeDecoder();
|
||||
var video = document.querySelector('#video');
|
||||
var start = document.querySelector('#start');
|
||||
var stop = document.querySelector('#stop');
|
||||
var result = document.querySelector('#result');
|
||||
async function startScan() {
|
||||
if (!qr.isCanvasSupported()) {
|
||||
alert("Your browser doesn't match the required specs.");
|
||||
throw new Error('Canvas and getUserMedia are required');
|
||||
}
|
||||
|
||||
let code = await qr.decodeFromCamera(video);
|
||||
console.log('code', code);
|
||||
result.innerText = "Result: " + code.data;
|
||||
}
|
||||
start.onclick = startScan;
|
||||
|
||||
stop.onclick = function() {
|
||||
qr.stop();
|
||||
};
|
||||
}
|
||||
main();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QrcodeDecoder - Image</title>
|
||||
</head>
|
||||
<body>
|
||||
<button id="decode">Decode!</button><br>
|
||||
<span id="result"></span><br>
|
||||
<img src="./assets/qrcode.png" alt="qr code" />
|
||||
<script src="./index.aio.min.js"></script>
|
||||
<script type="module">
|
||||
function main() {
|
||||
var qr = new QrcodeDecoder();
|
||||
|
||||
var btn = document.querySelector('button#decode');
|
||||
var img = document.querySelector('img');
|
||||
var result = document.querySelector('#result');
|
||||
|
||||
btn.onclick = async () => {
|
||||
// you can also decode from image path
|
||||
// const code = await qr.decodeFromImage('./assets/qrcode.png');
|
||||
const code = await qr.decodeFromImage(img);
|
||||
console.log(code);
|
||||
result.innerText = code.data;
|
||||
};
|
||||
}
|
||||
main();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>QrcodeDecoder</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>QrcodeDecoder</h1>
|
||||
<h2>Examples</h2>
|
||||
<ul>
|
||||
<li><a href="image.html">Image</a></li>
|
||||
<li><a href="video.html">Video</a></li>
|
||||
<li><a href="camera.html">Camera</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QrcodeDecoder - Video</title>
|
||||
</head>
|
||||
<body>
|
||||
<button id="start">Start</button> <button id="stop">Stop</button><br />
|
||||
<span id="result">Click start to scan qrcode.</span><br />
|
||||
|
||||
<video src="./assets/qrcode-video.mp4"></video>
|
||||
|
||||
<script src="./index.aio.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
function main() {
|
||||
var video = document.querySelector('video');
|
||||
var result = document.querySelector('#result');
|
||||
var start = document.querySelector('#start');
|
||||
var stop = document.querySelector('#stop');
|
||||
var qr = new QrcodeDecoder();
|
||||
|
||||
start.onclick = startScan;
|
||||
|
||||
stop.onclick = function() {
|
||||
qr.stop();
|
||||
video.pause();
|
||||
};
|
||||
|
||||
async function startScan() {
|
||||
video.play();
|
||||
const code = await qr.decodeFromVideo(video);
|
||||
console.log('code', code);
|
||||
result.innerText = 'Result: ' + code.data;
|
||||
}
|
||||
}
|
||||
main();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue