Extracts and parses text from ID documents (CIN, passport, driver's license, invoices) using OCR. Handles image preprocessing, document type detection, MRZ parsing, and field extraction for KYC/document verification workflows.
Ships in claude-skills-collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Corriger l'image AVANT d'envoyer à l'OCR — c'est l'étape qui impacte le plus la précision.
import cv2
import numpy as np
def preprocess_document(img: np.ndarray) -> np.ndarray:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# CLAHE pour le contraste adaptatif
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
enhanced = clahe.apply(gray)
# Débruitage
denoised = cv2.fastNlMeansDenoising(enhanced, h=10)
# Binarisation Otsu
_, binary = cv2.threshold(denoised, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
return binary
Critères qualité à vérifier avant OCR :
Si l'image ne passe pas les critères → demander une nouvelle capture avec feedback précis ("document trop petit", "image floue", "reflet détecté").
Classifier avant d'appliquer les regex/modèles spécialisés.
Heuristiques rapides (sans ML) :
| Signal | Document probable |
|---|---|
| 2 lignes OCR-A en bas | Passeport (TD3) ou CIN biométrique |
| 3 lignes OCR-A 30 chars | Titre de voyage TD1 |
| Champ IBAN / RIB | Relevé bancaire |
| QR code + montant | Facture |
Avec ML Kit (on-device) : utiliser un MobileNetV2 TFLite quantifié INT8 pour ≤ 15 ms d'inférence. Retourner { "document_type": "CIN_MA_RECTO", "confidence": 0.94 }.
| Moteur | Cas d'usage | Précision | Déploiement |
|---|---|---|---|
| Google ML Kit v2 | Mobile Kotlin/Flutter, arabe+latin | ~96 % | On-device |
| Tesseract 5 LSTM | Backend Python, arabe+français | ~92 % | Serveur / Edge |
| EasyOCR | Python, texte incliné/diagonal | ~90 % | Backend |
| AWS Textract | Documents complexes, tableaux | ~98 % | Cloud |
| Azure Form Recognizer | Formulaires structurés avec labels | ~97 % | Cloud |
Tesseract — configuration minimale pour documents marocains :
tesseract image.png output --oem 3 --psm 3 -l ara+fra \
--dpi 300 -c preserve_interword_spaces=1
ML Kit (Kotlin) :
val recognizer = TextRecognition.getClient(
TextRecognizerOptions.Builder()
.setExecutor(Dispatchers.Default.asExecutor())
.build()
)
val result = recognizer.process(InputImage.fromBitmap(bitmap, 0)).await()
result.textBlocks.forEach { block ->
val text = block.text
val boundingBox = block.boundingBox
}
Formats ICAO 9303 à connaître :
P<MAR...)# Lib recommandée : passporteye ou mrz-python
from mrz.checker.td3 import TD3CodeChecker
checker = TD3CodeChecker("P<MARBENBRAHIM<<KHALIL<<<<<<<<<<<<<<<<<<<<<\nAB1234567MAR9001011M3012315<<<<<<<<<<<<<<02")
if checker.valid():
fields = checker.fields()
print(fields.surname, fields.name, fields.date_of_birth)
Pièges MRZ :
0 vs O, 1 vs I → normaliser avant parsey > 80% avant OCR MRZRegex par document marocain :
import re
# CIN marocaine
CIN_PATTERN = re.compile(r'\b([A-Z]{1,2}[0-9]{5,6})\b')
# Numéro passeport marocain
PASSPORT_PATTERN = re.compile(r'\b([A-Z]{2}[0-9]{7})\b')
# Date format DD/MM/YYYY ou DD-MM-YYYY
DATE_PATTERN = re.compile(r'\b(\d{2})[/-](\d{2})[/-](\d{4})\b')
# CIN recto — extraction NER via spaCy (fr_core_news_md)
import spacy
nlp = spacy.load("fr_core_news_md")
doc = nlp(raw_text)
names = [ent.text for ent in doc.ents if ent.label_ == "PER"]
Pour les champs structurés complexes (LayoutLM) :
def clean_ocr_field(value: str, field_type: str) -> dict:
value = value.strip().upper()
# Corrections OCR typiques
ocr_fixes = {"0": "O", "1": "I", "5": "S", "8": "B"}
if field_type in ("NAME", "SURNAME"):
for wrong, right in ocr_fixes.items():
value = value.replace(wrong, right)
# Dates → format ISO
if field_type == "DATE":
match = re.match(r'(\d{2})[/-](\d{2})[/-](\d{4})', value)
if match:
value = f"{match.group(3)}-{match.group(2)}-{match.group(1)}"
confidence = compute_field_confidence(value, field_type)
return {"value": value, "confidence": confidence, "needs_review": confidence < 0.7}
Seuils de confiance recommandés :
< 0.99 → retry obligatoire< 0.80 → marquer pour review< 0.65 → rejeter, saisie manuelleImplémenter un live preview overlay dans CameraX (Kotlin) :
val imageAnalysis = ImageAnalysis.Builder()
.setTargetResolution(Size(1280, 720))
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
imageAnalysis.setAnalyzer(executor) { imageProxy ->
val laplacianVariance = computeBlurScore(imageProxy.toBitmap())
runOnUiThread {
when {
laplacianVariance < 100 -> showOverlay("Image floue — stabilisez l'appareil", RED)
documentCoverage < 0.60 -> showOverlay("Rapprochez l'appareil du document", YELLOW)
else -> showOverlay("Capture prête", GREEN)
}
}
imageProxy.close()
}
Format d'entrée recommandé (REST) :
POST /api/v1/ocr/scan
Content-Type: multipart/form-data
image: <fichier JPEG/PNG/WebP, max 5 MB>
document_type: CIN_MA | PASSPORT_MA | DRIVING_LICENSE | INVOICE | AUTO
Format de sortie :
{
"document_type": "CIN_MA_RECTO",
"mrz_valid": true,
"extracted_fields": {
"cin_number": { "value": "AB123456", "confidence": 0.98 },
"surname": { "value": "BENBRAHIM", "confidence": 0.95 },
"date_of_birth": { "value": "1990-01-01", "confidence": 0.92, "needs_review": false }
},
"processing_ms": 340,
"image_quality": { "blur_score": 210, "coverage": 0.73 }
}
Ne jamais faire :
--psm 6 (bloc uniforme) sur des documents bilingues arabe/français → segmentation casséePièges fréquents :
I<chiffres>) : regex [A-Z]{2}[0-9]{6} ne match pas → ajouter pattern legacy [A-Z][0-9]{7}--psm 6 ET charger ara.traineddata depuis tessdata_best, pas tessdata_fastLimites de précision par type :
| Document | MRZ | Imprimé | Manuscrit |
|---|---|---|---|
| Passeport | ~99.5 % | ~97 % | N/A |
| CIN biométrique | ~99 % | ~95 % | ~75 % |
| Permis de conduire | N/A | ~93 % | ~70 % |
| Facture | N/A | ~95 % | ~65 % |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ocr, document-scanner, id-verification, mrz-parsing, kyc, text-extraction
348 skills in this plugin
/agent-a2a-protocol-guideGuide du protocole Agent-to-Agent (A2A) de Google pour l'interopérabilité entre agents IA — découverte, communication et collaboration inter-agents, avec exemples de code, critères de décision et pièges à éviter. Se déclenche avec "A2A", "agent-to-agent", "protocole A2A", "Google A2A", "interopérabilité agents". Also triggers on "agent-to-agent protocol", "agent interoperability", "connect two agents"./agent-agent-observabilityInstrumentation technique d'un agent IA — tracing distribué des appels LLM et outils, spans, métriques custom, corrélation de logs et dashboards de supervision. Pour les alertes et garde-fous de production, voir agent-monitoring-setup. Se déclenche avec "observabilité agent", "tracing agent", "LangSmith", "Langfuse", "OpenTelemetry agent", "spans LLM", "corréler les logs agent". Also triggers on "trace my agent", "LLM tracing", "agent spans"./agent-api-caller-subagentSous-agent spécialisé dans les appels API REST/GraphQL avec retry, auth et transformation de données. Se déclenche avec "sous-agent API", "API caller agent", "agent qui appelle une API", "REST agent", "HTTP agent", "API integration subagent", "external API agent". Also triggers on "subagent that calls an API", "API calling agent", "agent HTTP requests"./agent-autogen-guideDéveloppement d'agents conversationnels avec Microsoft AutoGen. Création de group chats, agents spécialisés et workflows multi-agents avec exécution de code. Se déclenche avec "AutoGen", "Microsoft AutoGen", "autogen agent", "group chat agent", "ConversableAgent", "AssistantAgent", "UserProxyAgent", "coding agent", "agents qui conversent". Also triggers on "AutoGen agents", "group chat agents", "conversable agent"./agent-browser-agent-builderConstruction d'agents de navigation web autonomes incluant scraping intelligent, interaction DOM et gestion de sessions. Se déclenche avec "browser agent", "agent navigateur", "agent web autonome", "Puppeteer agent", "Playwright agent. Also triggers on "web browsing agent", "autonomous scraping agent"./agent-claude-code-extension-builderConstruction d'extensions et skills pour Claude Code — slash commands, hooks, intégration MCP et commandes personnalisées. Se déclenche avec "extension Claude Code", "skill Claude", "slash command", "Claude Code plugin", "custom command Claude". Also triggers on "build a Claude Code plugin", "custom slash command", "Claude Code hooks"./claude-skills-collection:dev-ocr-document-scannerfrom claude-skills-collection
npx claudepluginhub vantaflow/claude-skills-collection --plugin claude-skills-collectionOther plugins' skills for the same job