On the new person and new passport forms, next to Read:
- "Take a photo" opens a camera view (getUserMedia, the back camera): a
frame of the photo page's shape (125 by 88 mm), a band for the two lines,
and a hint from four checks of the band four times a second: too dark,
glare on the lines, no lines in the band, not sharp yet (variance of the
Laplacian). Once the band has looked readable for a second it takes the
photo itself; "Take the photo" and Cancel (or Escape) are there too.
The band where the frame showed it is read first; when that holds no
zone, the whole frame is searched.
- "Choose a picture" reads any image: EXIF orientation, the four quarter
turns, a tilt of 7 degrees either way; a failed read says when there is
glare in the picture.
Reading happens in the browser (static/mrz-photo.js): even light from a
local mean, the lines found with Tesseract's page layout, then the band cut
along their baselines, scaled and read as one block. Tesseract.js 7.0.0
and its core (SIMD and plain LSTM builds) with Doubango's MRZ model, all
served by the app from static/vendor/tesseract/ (README.txt: sources, npm
integrity, SHA-256, licenses Apache-2.0 and BSD-3), loaded at the first
photo. The photo never leaves the device: only the lines go into the zone's
field, and Read is pressed.
The server reads them like typed ones, through mrz::from_ocr when they are
no clean zone: the first line wherever it is, the second whose check digits
match best, a miscounted filler run cut or filled, K for < in the filler,
letters and digits where the zone has them, and look-alikes (O for 0, B for
8) swapped in the number fields only where a check digit asks for it,
preferring a digit. A photo's note asks to compare the names, which have no
check digit.
Only those two pages and the reader's files allow WebAssembly
('wasm-unsafe-eval', worker-src 'self', img-src blob:) and the camera
(Permissions-Policy camera=(self)); every other page keeps camera=().
Content types for .wasm and .gz.
Checks: fmt, clippy -D warnings, 99 unit and 50 integration tests (new:
from_ocr cases from real reads, tests/mrz_photo.rs for the markup, the two
policies, the files and a read from photo lines). In Edge (Playwright): 12
made-up phone photos and 16 specimen pages from Wikimedia Commons, every
zone that is readable read with all check digits matching (not: a hard
shadow across the lines; the specimens whose zone is blanked out), 1 to 5 s
each; the camera view with a fake camera: the glare and dark hints, and a
good picture taken by itself and the form filled in. Layout check 0
problems on both forms and a person, light and dark, desk and phone.
PLAN: task 7.3 done ahead of the client link, the decision recorded.
32 lines
1.9 KiB
Plaintext
32 lines
1.9 KiB
Plaintext
The passport photo reader (static/mrz-photo.js) runs these files in the
|
|
browser. They are served by the app itself, never from a CDN.
|
|
|
|
tesseract.min.js, worker.min.js
|
|
tesseract.js 7.0.0, npm, files dist/ of
|
|
https://registry.npmjs.org/tesseract.js/-/tesseract.js-7.0.0.tgz
|
|
(sha512-exPBkd+z+wM1BuMkx/Bjv43OeLBxhL5kKWsz/9JY+DXcXdiBjiAch0V49QR3oAJqCaL5qURE0vx9Eo+G5YE7mA==)
|
|
Apache License 2.0, LICENSE-tesseract.js.txt.
|
|
|
|
tesseract-core-simd-lstm.js/.wasm, tesseract-core-lstm.js/.wasm
|
|
tesseract.js-core 7.0.0 (Tesseract 5 built for WebAssembly), npm,
|
|
https://registry.npmjs.org/tesseract.js-core/-/tesseract.js-core-7.0.0.tgz
|
|
(sha512-WnNH518NzmbSq9zgTPeoF8c+xmilS8rFIl1YKbk/ptuuc7p6cLNELNuPAzcmsYw450ca6bLa8j3t0VAtq435Vw==)
|
|
Only the two builds for the LSTM engine: with SIMD, and without for
|
|
older browsers. Apache License 2.0, LICENSE-tesseract.js.txt.
|
|
|
|
mrz.traineddata.gz
|
|
tessdata_fast/mrz.traineddata of https://github.com/DoubangoTelecom/tesseractMRZ
|
|
(sha256 ece2a54f125a73792f9cec74e6f8e62f6e5e00c7f19153ba865af689be5b5f01), a Tesseract 4 LSTM model trained
|
|
on MRZ lines, compressed with gzip. BSD 3-Clause, LICENSE-mrz-model.txt.
|
|
Chosen over Shreeshrii/tessdata_ocrb (ocrb_int) after both read the same
|
|
28 photos and specimens: it matched more check digits.
|
|
|
|
SHA-256 of the files:
|
|
df5b3b32c8a3213b3f256dbbfec3285fb6f14d4b987dc742c36b65f7a985cad5 mrz.traineddata.gz
|
|
6510efc4e8b45c5465df30679b9911ffe0071cd2ee982fa064e6f5136ef2de85 tesseract-core-lstm.js
|
|
66b17df6e20c5329a17ffa9c202a47eaa3e32500b253d4c7f38e7f2bc01457c3 tesseract-core-lstm.wasm
|
|
e48e2f02ddae3716c8dd24bf41cd290d4efa96892d689cdc4013c2545d63f469 tesseract-core-simd-lstm.js
|
|
34e8d50cac216427d86bf397d610fdd9f49492539bbcdfbfccc4eda20c810bea tesseract-core-simd-lstm.wasm
|
|
000c27d9cd0def655f77b36c72a389c0ab13793aa31cb4d7aab56d09c0afbc7e tesseract.min.js
|
|
576b7df7e3393e137e51849357c9adb53fe7ac1bb69bfa06cf3d61520f182c6d worker.min.js
|