Endpoint
Request Parameters
This endpoint acceptsmultipart/form-data with the following fields:
Image file containing a vehicle license plate. Supported formats: JPG, JPEG, PNG. The image is saved with a timestamped filename in the format
matricula_YYYYMMDD_HHMMSS.jpg.Name of the vehicle owner. Optional field that can be left empty.
Type of vehicle (e.g., “Sedan”, “SUV”, “Motorcycle”, “Truck”). Optional field.
Additional notes or observations about the vehicle or registration. Optional field.
OCR Process
The endpoint uses a two-stage OCR process:Stage 1: GPT-4o-mini Vision
The image is base64-encoded and sent to OpenAI’s GPT-4o-mini model with the prompt:“Extrae únicamente el texto de la matrícula visible en esta imagen (placa de vehículo). Devuelve solo la matrícula, sin texto adicional, comentarios ni símbolos extras.”The extracted text is:
- Converted to uppercase
- Cleaned to contain only alphanumeric characters and hyphens
- Truncated to 10 characters maximum
Stage 2: Tesseract Fallback
If GPT-4o returns “NO_DETECTADA”, the system falls back to Tesseract OCR:Response
The endpoint returns an HTTP 302 redirect to the home page (/) with a flash message.
Success Response
Status Code:302 Found
Location: /
Flash Message: ✅ Registro guardado correctamente (category: ok)
A new record is added to data/registros.csv with:
- Auto-generated ID (sequential)
- Current timestamp
- Extracted license plate number
- Provided owner, vehicle type, and observations
- Saved image filename
Error Response
Status Code:302 Found
Location: /
Flash Message: ⚠️ Debes subir una imagen (category: error)
This occurs when no image file is provided in the request.
Request Examples
- cURL
- Python Requests
- JavaScript Fetch
- HTML Form
CSV Record Structure
After successful upload, a new row is appended todata/registros.csv:
Image Storage
Uploaded images are saved in theuploads/ directory with the naming pattern:
matricula_20260304_153045.jpg
Images can be accessed via the /uploads/<filename> endpoint.
Error Scenarios
Best Practices
- Image Quality: Use high-resolution images with clear visibility of the license plate for best OCR results
- File Size: Keep image files under 10MB for optimal processing speed
- Lighting: Ensure the plate is well-lit and not obscured by shadows or glare
- Angle: Front-facing or rear-facing shots work best; avoid extreme angles
- Error Handling: Always check the flash message after redirect to confirm success
Related Endpoints
View Records
See all uploaded records
Delete Record
Remove an uploaded record
