File size: 4,403 Bytes
a37d0db | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | # βββββββββββββββββββββββββββββββββββββββββββββ
# EALPR β Video Capture Configuration
# βββββββββββββββββββββββββββββββββββββββββββββ
# ββ Camera Settings βββββββββββββββββββββββββββ
# Use 0 for the default webcam (testing)
# Use an RTSP URL for a real IP camera, e.g.:
# "rtsp://admin:password@192.168.1.100:554/stream1"
# Use a file path to process a local video, e.g.:
# "1900-151662242.mp4" or r"C:\path\to\video.mp4"
# βΌ Switch between sources by commenting / uncommenting:
#CAMERA_URL = r"d:\Uni y3s2\ML\Project_Main_ML\1900-151662242.mp4" # local video
CAMERA_URL = "http://10.48.140.136:4747/video" # IP camera (DroidCam)
# CAMERA_URL = 0 # default webcam
# Frames per second to READ from the stream
# (does not need to match camera FPS β we sample every N frames)
# OPTIMIZATION: Changed from 3 to 12 to jump over identical redundant frames rapidly
PROCESS_EVERY_N_FRAMES = 12
# ββ Frame Buffer ββββββββββββββββββββββββββββββ
# How many frames to keep in memory before picking the best one
# More = better chance of catching a sharp frame, but more memory
# OPTIMIZATION: Raised to 45 to give the selector a broader pool to find the sharpest snapshot
FRAME_BUFFER_SIZE = 45
# ββ Motion / Trigger Settings βββββββββββββββββ
# Minimum number of changed pixels to count as "vehicle present"
MIN_MOTION_AREA = 500 # Lower = more sensitive to small objects / distance
# Max frame count a vehicle can go without motion before ending the cluster event
MAX_STATIONARY_FRAMES = 15 # Lower = splits slow traffic into separate events
# Quality/Selection rules:
MIN_PLATE_CONFIDENCE = 0.40 # discard frames where plate detection is weak
MAX_PLATE_ANGLE = 15.0 # degrees max skew allowed (if computed)
# Brightness constraints to filter out garbage flashes
MIN_BRIGHTNESS = 30 # widened for dark/night scenes in video
MAX_BRIGHTNESS = 220 # widened for bright scenes in video
# ββ Model Settings ββββββββββββββββββββββββββββ
CONF_THRESHOLD = 0.25
USE_HUGGING_FACE = True
HF_TOKEN = None
HF_PLATE_DETECTOR_REPO = "alyhassankamel/egyptian_license_plate_detector"
HF_CHAR_OCR_REPO = "alyhassankamel/egyptian-license-plate-ocr"
HF_CAR_CLASSIFIER_REPO = "PatrickBLB/egyptian_cars_recognition_computer_vision_model"
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parent
PLATE_DETECTOR_MODEL_PATH = str(PROJECT_ROOT / "weights" / "detector_best.pt")
CHAR_OCR_MODEL_PATH = str(PROJECT_ROOT / "weights" / "ocr_best.pt")
# ββ Output / Storage ββββββββββββββββββββββββββ
import os
# Directory where captured frames are saved
OUTPUT_DIR = "captured_frames"
os.makedirs(OUTPUT_DIR, exist_ok=True)
# Save every triggered frame to disk? True = yes, False = send to API only
SAVE_FRAMES_TO_DISK = True
# Image format for saved frames
SAVE_FORMAT = ".jpg"
JPEG_QUALITY = 95 # 0β100
# ββ API Settings ββββββββββββββββββββββββββββββ
# FastAPI /api/detect endpoint.
# Set to None to skip sending and only save locally.
API_ENDPOINT = "http://localhost:8000/api/detect" # β FastAPI server
API_TIMEOUT = 60 # seconds (LPR pipeline can be slow on CPU)
# Camera UUID registered in the 'cameras' table (Supabase).
# Every detection is tagged with this ID so the dashboard knows
# which physical camera triggered the event.
# Create a camera first: POST /api/cameras β copy the returned UUID here.
CAMERA_ID = "70a649c0-4ad7-4a85-bc12-9e7144e4a777"
# ββ Display / Debug βββββββββββββββββββββββββββ
# Show live preview window while running? Set False on headless servers
SHOW_PREVIEW = True
# Draw motion mask overlay on the preview?
SHOW_MOTION_MASK = False
# Print verbose console status?
VERBOSE_LOGGING = True |