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.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.
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.| Mode | Script | Confidence Threshold | Window Title |
|---|---|---|---|
| Image | Object_detection_image.py | 0.65 | Detector de Placas PRUEBA-IMAGEN |
| Video | Object_detection_video.py | 0.55 | Detector de placas- PRUEBA VIDEO |
| Webcam | Object_detection_webcam.py | 0.50 | Detector de placas PRUEBA-WEBCAM |
.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:-
Load the label map —
label_map_util.load_labelmapreadslabelmap.pbtxt,label_map_util.convert_label_map_to_categoriesconverts it to a list of category dicts, andlabel_map_util.create_category_indexbuilds the integer-to-name mapping used by the visualiser. -
Deserialise the frozen graph — A
tf.GraphDef()object is populated by readingfrozen_inference_graph.pbwithtf.gfile.GFile, then imported into a dedicatedtf.Graph()viatf.import_graph_def. -
Open a TensorFlow session —
tf.Session(graph=detection_graph)creates the runtime context bound to the frozen graph. -
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}. -
Collect outputs and visualise — The session returns four tensors:
detection_boxes:0— normalised[ymin, xmin, ymax, xmax]coordinates for each detected objectdetection_scores:0— per-box confidence scores in[0, 1]detection_classes:0— integer class indicesnum_detections:0— total number of detections in the batch
vis_util.visualize_boxes_and_labels_on_image_arrayoverlays boxes and scores on the original frame, which is then shown withcv2.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(), andtf.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_utilandvisualization_utilsfrom thetensorflow/modelsresearch 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: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.