Skip to main content

Overview

This quickstart guide will walk you through:
  • Starting the CoroNet application
  • Uploading your first license plate image
  • Viewing the AI-detected results
  • Managing and exporting records
Before starting, make sure you’ve completed the Installation steps, including setting up your OpenAI API key and installing Tesseract OCR.

Start the Application

1

Activate Virtual Environment

First, navigate to your project directory and activate the Python virtual environment:
cd TallerMatricula
source venv/bin/activate
2

Run the Flask Server

Start the application with Python:
python app.py
You should see output similar to:
 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
The application runs in debug mode by default (app.py:159), which enables hot-reloading and detailed error messages.
3

Open the Web Interface

Open your web browser and navigate to:
http://localhost:5000
You’ll see the CoroNet upload interface with the title “Lector de Matrículas Inteligente” (Intelligent License Plate Reader).

Detect Your First License Plate

Now let’s process an image and see CoroNet’s AI detection in action:
1

Prepare a Test Image

You’ll need an image containing a visible vehicle license plate. You can:
  • Use your phone to take a photo of a parked car
  • Download a sample license plate image from the internet
  • Use a stock photo with a clear vehicle plate
For best results, ensure:
  • The license plate is clearly visible
  • Good lighting conditions
  • Minimal blur or distortion
  • JPG, PNG, or other common image format
2

Upload the Image

On the main page:
  1. Click the “Selecciona una imagen de matrícula” button
  2. Choose your license plate image from your file system
  3. You’ll see a preview of the uploaded image
The interface is defined in templates/index.html:38-45:
<input id="imagen" name="imagen" type="file" 
       accept="image/*" required 
       onchange="previewImage(event)">
3

Add Optional Metadata

Optionally, fill in additional information:
  • Propietario (Owner): Name of the vehicle owner
  • Tipo de vehículo (Vehicle Type): e.g., “Car”, “Truck”, “Motorcycle”
  • Observación (Observation): Color, condition, or any notes
Only the image is required. All other fields are optional and help with record-keeping.
4

Submit and Detect

Click the “Guardar Matrícula” button to process the image.Behind the scenes (app.py:86-128), CoroNet:
  1. Saves the uploaded image to uploads/ directory
  2. Encodes the image to base64 format
  3. Sends it 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.”
  4. If AI detection fails, falls back to Tesseract OCR
  5. Cleans and formats the detected text (alphanumeric only, max 10 chars)
  6. Saves the record to data/registros.csv
# Detection flow (app.py:103-110)
matricula = extract_plate_from_image(path)

# Fallback with pytesseract
if matricula == "NO_DETECTADA":
    image = Image.open(path)
    ocr_text = pytesseract.image_to_string(image, lang="eng")
    ocr_text = ocr_text.strip().replace(" ", "").replace("\n", "").upper()
    matricula = "".join([c for c in ocr_text if c.isalnum() or c == "-"])[:10]
5

View the Results

After processing, you’ll see a success message:
✅ Registro guardado correctamente
The detected license plate and metadata are now stored in the database!

View and Manage Records

1

Navigate to Records

Click the ”📜 Ver Registros” button on the main page, or navigate directly to:
http://localhost:5000/registros
2

Browse Your Records

The records page displays a table with all detected plates (templates/registros.html:30-65):
ColumnDescription
IDUnique record identifier
ImagenThumbnail of uploaded image
MatrículaDetected license plate text
PropietarioVehicle owner name
TipoVehicle type
Obs.Additional observations
ActionsDelete button (trash icon)
Click on any thumbnail to view the full-size image.
3

Export Records

To export all records as CSV:
  1. Click the “Descargar CSV” button at the bottom of the records page
  2. The file registros.csv will download to your browser
The CSV export route is defined in app.py:154-156:
@app.route("/descargar")
def descargar():
    ensure_csv()
    return send_file(DATA_PATH, as_attachment=True, 
                    download_name="registros.csv")
CSV Format:
id,fecha_hora,matricula,propietario,tipo_vehiculo,observacion,imagen
1,2026-03-04 14:23:45,ABC1234,John Doe,Car,Blue sedan,matricula_20260304_142345.jpg
4

Delete Records (Optional)

To remove a record:
  1. Find the record in the table
  2. Click the trash icon in the Actions column
  3. The record will be deleted from both the CSV and the uploaded image removed
The deletion route (app.py:136-147) handles cleanup:
@app.route("/eliminar/<id>")
def eliminar(id):
    rows = read_csv()
    filtered = [r for r in rows if r["id"] != id]
    deleted = [r for r in rows if r["id"] == id]
    if deleted:
        img = deleted[0]["imagen"]
        img_path = os.path.join(UPLOADS_DIR, img)
        if os.path.exists(img_path):
            os.remove(img_path)
    write_csv(filtered)

Understanding the Detection Process

Here’s what happens when you upload an image:

Primary Detection: OpenAI GPT-4o-mini

The AI detection function (app.py:44-80) uses vision capabilities:
def extract_plate_from_image(image_path):
    try:
        with open(image_path, "rb") as f:
            img_base64 = base64.b64encode(f.read()).decode("utf-8")

        response = client.chat.completions.create(
            model="gpt-4o-mini",
            messages=[
                {
                    "role": "user",
                    "content": [
                        {
                            "type": "text",
                            "text": (
                                "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."
                            ),
                        },
                        {
                            "type": "image_url",
                            "image_url": {
                                "url": f"data:image/jpeg;base64,{img_base64}"
                            },
                        },
                    ],
                }
            ],
        )

        text = response.choices[0].message.content.strip().upper()
        clean = "".join([c for c in text if c.isalnum() or c == "-"])[:10]
        return clean or "NO_DETECTADA"

    except Exception as e:
        print(" Error OCR con OpenAI:", e)
        return "NO_DETECTADA"
The function returns only alphanumeric characters and hyphens, limited to 10 characters maximum, which matches typical license plate formats.

Fallback Detection: Tesseract OCR

When AI detection fails, Tesseract OCR takes over (app.py:106-110):
if matricula == "NO_DETECTADA":
    image = Image.open(path)
    ocr_text = pytesseract.image_to_string(image, lang="eng")
    ocr_text = ocr_text.strip().replace(" ", "").replace("\n", "").upper()
    matricula = "".join([c for c in ocr_text if c.isalnum() or c == "-"])[:10]

Common Issues and Solutions

Possible causes:
  • Poor image quality or lighting
  • Plate is too small or partially obscured
  • Unusual plate format or characters
Solutions:
  • Use a higher resolution image
  • Ensure good lighting and contrast
  • Try cropping the image to focus on the plate
  • Check that the plate text is clearly readable by eye
Common issues:
  • Similar-looking characters confused (O/0, I/1, S/5)
  • Dirt or damage on plate affecting readability
Solutions:
  • Clean the plate before photographing
  • Take photo from directly in front (not at angle)
  • Manually correct the detected text in the CSV if needed
Possible causes:
  • Very large image file
  • Slow internet connection to OpenAI API
  • OpenAI API rate limits
Solutions:
  • Resize images to under 5MB before uploading
  • Check your internet connection
  • Verify your OpenAI API key has available credits
  • Wait a moment and try again (Tesseract fallback will still work)

Next Steps

Congratulations! You’ve successfully:
  • ✅ Started the CoroNet application
  • ✅ Uploaded and processed a license plate image
  • ✅ Viewed and managed records
  • ✅ Exported data to CSV
Now explore more advanced features:

Core Features

Deep dive into detection algorithms and optimization

Configuration

Customize CoroNet for your specific use case

User Guide

Best practices for image capture and processing

API Reference

Technical documentation for developers

Build docs developers (and LLMs) love