Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/oktopuzSlid/detectorPlacas/llms.txt

Use this file to discover all available pages before exploring further.

DetectorPlacas is a Python computer vision project that uses TensorFlow 1.x and a frozen SSD MobileNet v1 inference graph to locate and highlight vehicle license plates. Built on top of the TensorFlow Object Detection API and OpenCV, it supports three distinct detection modes — static images, pre-recorded video files, and live webcam feeds — making it practical for both batch image analysis and continuous real-time surveillance. The model was trained on a single-class dataset (license plates) and produces bounding boxes annotated with confidence scores on every frame it processes.

What DetectorPlacas Does

DetectorPlacas exposes three detection modes, each implemented as a self-contained Python script and each tuned with its own minimum confidence threshold to balance precision against recall for that input type.
ModeScriptConfidence ThresholdWindow Title
ImageObject_detection_image.py0.65Detector de Placas PRUEBA-IMAGEN
VideoObject_detection_video.py0.55Detector de placas- PRUEBA VIDEO
WebcamObject_detection_webcam.py0.50Detector de placas PRUEBA-WEBCAM
Image mode scans a directory for .jpg files using os.listdir() combined with endswith('.jpg'), and runs inference on each file sequentially, displaying results in an OpenCV window. The directory is set via the --ruta flag; if omitted, the current working directory is used. Video mode opens a file named prueba.mp4 from the working directory and processes it frame by frame. A slightly lower threshold of 0.55 is used to account for motion blur and varying lighting across frames. Webcam mode captures a continuous live feed from camera index 0 at a resolution of 1280×720 pixels and runs inference on every frame. The lowest threshold of 0.50 is applied to ensure plates are caught even under challenging real-time conditions. In all three modes, detections are visualised using vis_util.visualize_boxes_and_labels_on_image_array, which draws labelled bounding boxes with a line thickness of 8 px (image and webcam) or 5 px (video) directly onto the output frame.

Key Components

frozen_inference_graph.pb

The pre-trained SSD MobileNet v1 model exported as a frozen TensorFlow graph. Stored inside inference_graph/, this .pb file contains all weights and the full computation graph needed for inference — no separate training step is required at runtime.

labelmap.pbtxt

The label map that maps the single integer class index to its human-readable name. DetectorPlacas recognises exactly one class — license_plate — so the file contains a single item block with id: 1.

Detection Scripts

Three standalone Python scripts — Object_detection_image.py, Object_detection_video.py, and Object_detection_webcam.py — each loading the same frozen graph and label map but reading input from a different source and applying a mode-appropriate confidence threshold.

Graphical Interface

interfaz.py is a Tkinter GUI with window title "Proyecto" that presents radio buttons for IMAGEN, VIDEO, and CAMARA modes alongside a text field for the image directory path. Clicking PRUEBA dispatches the correct script via os.system, making it easy to switch modes without touching the command line.

Architecture Overview

Every detection script follows the same five-stage pipeline:
  1. Load the label maplabel_map_util.load_labelmap reads labelmap.pbtxt, label_map_util.convert_label_map_to_categories converts it to a list of category dicts, and label_map_util.create_category_index builds the integer-to-name mapping used by the visualiser.
  2. Deserialise the frozen graph — A tf.GraphDef() object is populated by reading frozen_inference_graph.pb with tf.gfile.GFile, then imported into a dedicated tf.Graph() via tf.import_graph_def.
  3. Open a TensorFlow sessiontf.Session(graph=detection_graph) creates the runtime context bound to the frozen graph.
  4. Feed the image tensor — Each frame is converted from BGR to RGB with OpenCV, expanded to a batch dimension of 1, and passed to the session via feed_dict={image_tensor: frame_expanded}.
  5. Collect outputs and visualise — The session returns four tensors:
    • detection_boxes:0 — normalised [ymin, xmin, ymax, xmax] coordinates for each detected object
    • detection_scores:0 — per-box confidence scores in [0, 1]
    • detection_classes:0 — integer class indices
    • num_detections:0 — total number of detections in the batch
    vis_util.visualize_boxes_and_labels_on_image_array overlays boxes and scores on the original frame, which is then shown with cv2.imshow.

Dependencies

DetectorPlacas depends on the following libraries. Ensure all are installed before running any detection script:
  • TensorFlow 1.x — the scripts use tf.app.flags, tf.Graph(), tf.Session(), and tf.GraphDef(), which are TF 1.x APIs removed or substantially changed in TF 2.x
  • OpenCV (cv2) — image and video I/O, colour-space conversion, and display
  • NumPy — tensor reshaping (np.expand_dims, np.squeeze)
  • TensorFlow Object Detection API — provides label_map_util and visualization_utils from the tensorflow/models research repository
  • Tkinter — standard-library GUI toolkit used by interfaz.py (included with most Python distributions)

Project Structure

All scripts resolve paths relative to the current working directory, so the following layout must be preserved exactly when running any detection script:
project-root/
├── inference_graph/
│   ├── frozen_inference_graph.pb
│   ├── model.ckpt.data-00000-of-00001
│   ├── model.ckpt.index
│   └── model.ckpt.meta
├── labelmap.pbtxt
├── Object_detection_image.py
├── Object_detection_video.py
├── Object_detection_webcam.py
└── interfaz.py
The model training configuration (pipeline.config) specifies num_examples: 1100 for evaluation and uses coco_detection_metrics as the metrics set. These COCO detection metrics — including mean Average Precision (mAP) at various IoU thresholds — are the standard benchmarks used to measure license-plate detection accuracy for this model.

Build docs developers (and LLMs) love