Skip to content

Commit

Permalink
fix(module-scan): improve quirc perf
Browse files Browse the repository at this point in the history
My PR was merged (kaworu/node-quirc#15), so now we can pass an `ImageData` directly to be decoded without encoding as a PNG first.
  • Loading branch information
eventualbuddha committed Jan 12, 2021
1 parent d8dc321 commit 2f26515
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions apps/module-scan/src/util/qrcode.ts
Expand Up @@ -5,7 +5,6 @@ import { detect as qrdetect } from '@votingworks/qrdetect'
import makeDebug from 'debug'
import jsQR from 'jsqr'
import { decode as quircDecode, QRCode } from 'node-quirc'
import { toPNG } from './images'
import { time } from './perf'

const debug = makeDebug('module-scan:qrcode')
Expand Down Expand Up @@ -97,7 +96,7 @@ export const detectQRCode = async (
{
name: 'quirc',
detect: async (imageData: ImageData): Promise<Buffer[]> => {
const results = await quircDecode(await toPNG(imageData))
const results = await quircDecode(imageData)
return results
.filter((result): result is QRCode => !('err' in result))
.map((result) => result.data)
Expand Down
4 changes: 2 additions & 2 deletions apps/module-scan/types/node-quirc.d.ts
Expand Up @@ -38,9 +38,9 @@ declare module 'node-quirc' {
err: string
}

export function decode(img: Buffer): Promise<DecodeResult>
export function decode(img: Buffer | ImageData): Promise<DecodeResult>
export function decode(
img: Buffer,
img: Buffer | ImageData,
callback: (err: Error, results: DecodeResult) => void
): Promise<DecodeResult>
}

0 comments on commit 2f26515

Please sign in to comment.