Skip to content

Commit

Permalink
Merge pull request #1189 from siiky/fix/lam-994/pdf417-failed-scans
Browse files Browse the repository at this point in the history
LAM-994 fix: skip first few frames while camera is opening
  • Loading branch information
RafaelTaranto authored Oct 5, 2024
2 parents 8b8bdd0 + e7b5bba commit 294887d
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions lib/brain.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ const readFailedFrames = callback => failedScansTmpdirs =>
_.flatten,
failedScans => _.chunk(_.round(_.size(failedScans)/6), failedScans),
_.map(failedScanGroup =>
fsPromises.readFile(failedScanGroup[0])
fsPromises.readFile(_.last(failedScanGroup))
.then(callback)
.catch(console.error)
)
Expand All @@ -856,27 +856,20 @@ Brain.prototype.scanPDF = function scanPDF () {
this.scanner.scanPDF417((err, result) => {
this.scanBayLightOff()
this.startDisabled = false
if (!this.isGenmegaMachine) {
if (err || !result) {
const photos = idCardData.getIdDataPhotos()
this.trader.updateIdCardPhotos(customer.id, { photos })
.then(() => console.log('Successfully saved ', photos.length, ' id data photos'))
.catch(err => {
console.log('Error saving id card photos', err)
})
}
if (!this.isGenmegaMachine && (err || !result)) {
const photos = idCardData.getIdDataPhotos()
this.trader.updateIdCardPhotos(customer.id, { photos })
.then(
() => console.log('Successfully saved', photos.length, 'id data photos'),
err => console.log('Error saving id card photos', err)
)
}

if (err) {
console.log(err)
if (err || !result) {
console.log(err || 'No PDF417 result')
return idCardData.dispatch('SCAN_ERROR')
}

if (!result) {
console.log('No PDF417 result')
return
}

if (this.hasExpired(result)) {
console.log('Expired ID card')
return idCardData.dispatch('SCAN_ERROR')
Expand Down

0 comments on commit 294887d

Please sign in to comment.