Skip to content

ocr done#6

Merged
oussa29-dev merged 1 commit into
mainfrom
mounia
May 31, 2026
Merged

ocr done#6
oussa29-dev merged 1 commit into
mainfrom
mounia

Conversation

@mouniarouabhi

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings May 31, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds server-side passport OCR to the check-in flow by accepting an uploaded passport image, running a Python MRZ reader, and saving extracted passport fields to the existing CHECKIN record.

Changes:

  • Adds POST /checkin/:id/passport/ocr with multer upload handling and Python subprocess OCR execution.
  • Adds mrz_reader.py for MRZ extraction and field normalization.
  • Adds multer and its lockfile dependencies.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 9 comments.

File Description
routes/checkin.js Adds OCR upload endpoint and persistence of extracted passport data.
mrz_reader.py Adds PassportEye/Tesseract-based MRZ parsing script.
package.json Adds multer dependency for multipart uploads.
package-lock.json Locks multer and transitive dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mrz_reader.py
Comment on lines +7 to +8
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
os.environ['TESSDATA_PREFIX'] = r'C:\Program Files\Tesseract-OCR\tessdata'
Comment thread mrz_reader.py
Comment on lines +22 to +27
def parse_dob(raw):
yy = ''.join(c for c in raw[:2] if c.isdigit())
if not yy:
return None
yyyy = f"19{yy}" if int(yy) >= 30 else f"20{yy}"
return f"{yyyy}-01-01"
Comment thread mrz_reader.py
Comment on lines +15 to +20
def fix_last_name(raw):
# H between two vowel-adjacent consonants is likely M
# More targeted: SLI_ANI pattern — the _ is M
import re
raw = re.sub(r'(?<=[A-Z])H(?=[A-Z])', 'M', raw)
return raw
Comment thread routes/checkin.js
}
});
});
console.log("[OCR] PassportEye result:", parsed);
Comment thread routes/checkin.js
try {
resolve(JSON.parse(stdout));
} catch (e) {
reject(new Error("Failed to parse PassportEye output: " + stdout));
Comment thread routes/checkin.js
return res.status(404).json({ message: "Check-in not found" });
}
const parsed = await new Promise((resolve, reject) => {
execFile("python", ["mrz_reader.py", filePath], (err, stdout, stderr) => {
Comment thread routes/checkin.js
});
});
console.log("[OCR] PassportEye result:", parsed);
if (parsed.error || !parsed.passportNumber) {
Comment thread routes/checkin.js
if (allowed.includes(file.mimetype)) {
cb(null, true);
} else {
cb(new Error("Only JPEG and PNG images are allowed"));
Comment thread mrz_reader.py
Comment on lines +4 to +5
import pytesseract
from passporteye import read_mrz
@oussa29-dev oussa29-dev merged commit 46eee15 into main May 31, 2026
1 check passed
@oussa29-dev oussa29-dev deleted the mounia branch May 31, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants