food/src/views/ScanQuagga.vue

68 lines
1.6 KiB
Vue
Raw Normal View History

2017-09-19 02:41:00 +02:00
<template>
<div>
<h2>Let's scan something!</h2>
<h2>Found: {{ barcode }}</h2>
2017-09-27 02:24:51 +02:00
<div id="interactive" class="viewport"></div>
2017-09-19 02:41:00 +02:00
<p v-if="!playing && error">{{ error }}</p>
</div>
</template>
<script>
import 'webrtc-adapter';
import Quagga from 'quagga';
export default {
data() {
return {
error: 'Video stream not available.',
playing: false,
barcode: 'Not found',
};
},
methods: {
handleBarcode(data) {
this.barcode = data.codeResult.code;
},
},
mounted() {
Quagga.init({
inputStream: {
type: 'LiveStream',
constraints: {
2017-09-27 02:24:51 +02:00
width: { min: 640 },
height: { min: 480 },
2017-09-19 02:41:00 +02:00
facingMode: 'environment',
2017-09-27 02:24:51 +02:00
aspectRatio: { min: 1, max: 2 },
2017-09-19 02:41:00 +02:00
},
},
2017-09-27 02:24:51 +02:00
/* locator: {
patchSize: 'medium',
halfSample: true,
},
frequency: 10,
2017-09-19 02:41:00 +02:00
decoder: {
readers: [
'ean_reader',
],
},
2017-09-27 02:24:51 +02:00
locate: true, */
2017-09-19 02:41:00 +02:00
}, (err) => {
if (err) {
this.error = err.toString();
2017-09-27 02:24:51 +02:00
// return;
2017-09-19 02:41:00 +02:00
}
2017-09-27 02:24:51 +02:00
// Quagga.start();
2017-09-19 02:41:00 +02:00
});
2017-09-27 02:24:51 +02:00
/* Quagga.onProcessed((result) => {
console.log(result);
}); */
2017-09-19 02:41:00 +02:00
},
beforeDestroy() {
2017-09-27 02:24:51 +02:00
// Quagga.offDetected(this.handleBarcode);
// Quagga.stop();
2017-09-19 02:41:00 +02:00
},
};
</script>