How anhtun1467/cccd-ai-service works
CCCD AI Service is a FastAPI application for recognizing Vietnamese identity cards and performing 1:1 face verification. The primary workflow uploads a card image, detects and rectifies the card, extracts and validates identity fields, then returns JSON and retains card/portrait data in a short-lived session. A later selfie or camera capture can reuse that session for face-quality checks and similarity matching. The README documents these stages and thresholds; the sampled source confirms the application router setup and OCR pipeline behavior, but does not expose all endpoint-to-service calls.
Main entry points: ocr_pipeline.py OCR pipeline · face_verification_pipeline.py Face pipeline · detector.py Card detection · face_verification.py Face endpoints
Components 21
API and orchestration
- OCR endpoint
app/api/ocr.py - OCR pipeline
app/services/ocr_pipeline.py - Face endpoints
app/api/face_verification.py - Face pipeline
app/services/face_verification_pipeline.py
Card image processing
- Card detection
app/modules/card_detection/detector.py - Perspective transform
app/modules/card_detection/perspective_transformer.py - Image enhancement
app/modules/card_detection/image_enhancer.py
Identity extraction
- OCR service
app/modules/ocr/service.py - EasyOCR engine
app/modules/ocr/easyocr_engine.py - Field OCR
app/modules/ocr/field_ocr_service.py - Parse and normalize
app/modules/ocr/parser/regex_parser.py - Field validation
app/modules/ocr/validator.py - QR decode and fuse
app/modules/qr/qr_ocr_fuser.py
Face verification
- Face sessions
app/services/face_session_store.py - Portrait extraction
app/modules/face_verification/portrait_extractor.py - Face quality and detection
app/modules/face_verification/quality.py - Face embeddings
app/modules/face_verification/embedding.py - Similarity matching
app/modules/face_verification/matcher.py
Other components
- Client
- Selfie capture
- JSON result
Connections 23
- Client → OCR endpoint: uploads card
- OCR endpoint → OCR pipeline: starts OCR
- OCR pipeline → Card detection: detects card
- Card detection → Perspective transform: rectifies card
- Card detection → Image enhancement: enhances image
- OCR pipeline → OCR service: runs OCR
- OCR service → EasyOCR engine: recognizes text
- OCR pipeline → Field OCR: extracts fields
- OCR pipeline → Parse and normalize: parses text
- OCR pipeline → Field validation: validates fields
- OCR pipeline → QR decode and fuse: fuses QR data
- OCR pipeline → Portrait extraction: extracts portrait
- OCR pipeline → Face sessions: retains OCR session
- OCR pipeline → JSON result: returns OCR result
- Selfie capture → Face endpoints: submits selfie
- Client → Face endpoints: checks session
- Face endpoints → Face pipeline: starts verification
- Face pipeline → Face sessions: loads session
- Face pipeline → Portrait extraction: uses portrait
- Face pipeline → Face quality and detection: checks face
- Face pipeline → Face embeddings: computes embeddings
- Face pipeline → Similarity matching: compares faces
- Face pipeline → JSON result: returns decision