Skip to content

Commit

Permalink
chore: bw images on xwing
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelTaranto committed Nov 19, 2024
1 parent c729ec2 commit 52e672b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/scanner-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Pdf417Parser = require('./compliance/parsepdf417')
const { utils: coinUtils } = require('@lamassu/coins')
const { cameraExists, stream } = require('./capture/streamer/v4l2camera')
const scanner = require('./capture/scanner/zxing')
const sharp = require('sharp')

const DEFAULT_FPS = 10
const DEFAULT_DELAYEDSHOT_DELAY = 3
Expand Down Expand Up @@ -138,7 +139,7 @@ const capture = (device, config, returnCallback, stillsCallback, process) => {

activeStream.on('close', externallyClosedHandler)

activeStream.on('data', async (frame) => {
activeStream.on('data', async (frame) => {
if (processing) return
processing = true
const result = await process(frame)
Expand Down Expand Up @@ -168,7 +169,8 @@ const scanPDF417 = (resultCallback, idCardStillsCallback) => {
const device = getCameraDevice(mode)

capture(device, {}, resultCallback, idCardStillsCallback, async frame => {
const result = await scanner.scanPDF417(frame)
const bwFrame = await sharp(frame).greyscale().toBuffer()
const result = await scanner.scanPDF417(bwFrame)
return result ? Pdf417Parser.parse(result) : null
})
}
Expand All @@ -177,15 +179,20 @@ const scanQR = (resultCallback) => {
const mode = 'qr'
const device = getCameraDevice(mode)

capture(device, {}, resultCallback, _.noop, scanner.scanQRcode)
capture(device, {}, resultCallback, _.noop, async frame => {
const bwFrame = await sharp(frame).greyscale().toBuffer()
return scanner.scanQRcode(bwFrame)
}
)
}

const scanMainQR = (cryptoCode, qrStillsCallback, resultCallback) => {
const mode = 'qr'
const device = getCameraDevice(mode)

capture(device, {}, resultCallback, qrStillsCallback, async frame => {
const code = await scanner.scanQRcode(frame)
const bwFrame = await sharp(frame).greyscale().toBuffer()
const code = await scanner.scanQRcode(bwFrame)
const network = 'main'

if (!code) return null
Expand Down

0 comments on commit 52e672b

Please sign in to comment.