43
Home
Shawn edited this page 2026-06-02 18:05:51 -04:00

Scan & OCR Improvements (2026-06-02)

Three improvements shipped:

1. Scan New Asset button

After scanning/OCR'ing an existing asset, a "Scan New" button appears that cleanly resets the scanner for the next asset. The barcode scan result now shows in-place instead of navigating away to the Assets tab.

Functions added: resetBarcodeScanner(), resetOcrScanner() — these clear results, reset camera UI, and auto-restart the appropriate scanner.

2. Barcode scanner fix

The barcode scanner was too slow on mobile because:

  • TRY_HARDER decode hint was enabled (very slow per frame)
  • 13 barcode formats were registered (1D + 2D like QR, DataMatrix, etc.)

Fix: Removed TRY_HARDER, reduced to 7 focused 1D formats (CODE_128, CODE_39, EAN_13, EAN_8, UPC_A, UPC_E, ITF). Added ZXing CDN load check. Extended camera timeout from 5s to 10s.

Function added: checkZxingLoaded(), showFallbackCameraError()

The server's /api/ocr endpoint already cross-referenced detected text against the DB by serial_number, connect_id, etc. (matched_assets in response). But the client-side displayOcrResult() only showed results when machine_id was detected.

Fix: Now when OCR detects text matching an asset by serial/ID but no machine_id pattern, it shows the matched asset(s) with a "View Details" button. Also shows serial matches as supplementary info when machine_id IS found.

Technical details

  • Only file modified: static/index.html (34 insertions, 8 deletions)
  • Commit: dd4744d on main
  • Issue: #63
  • Gitea repo: shawn/canteen-asset-tracker