-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·37 lines (31 loc) · 917 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const cam = require('raspberry-pi-camera-native')
const fs = require('fs')
const zbar = require('node-zbarimg')
const _ = require('lodash')
let i = 0
cam.on('frame', frame => {
// Pause the camera recording to process the QR code.
cam.pause(() => {
const path = `./images/image.jpg`
var stream = fs.createWriteStream(path)
stream.once('open', (fd) => {
stream.write(frame)
stream.end()
// Tell zbar to process.
zbar(path, (err, code) => {
if (!err) {
console.log('code', code)
} else {
process.stdout.write('.')
}
// cam.resume()
})
})
})
})
cam.start({
fps: 10,
quality: 75,
width: 840,
height: 616,
})