import streamlit as st import cv2 import numpy as np from LicensePlateAuthorizer import LicensePlateAuthorizer # Initialize the License Plate Authorizer lpa = LicensePlateAuthorizer() st.title("License Plate Detection") st.write("Upload an image or video for license plate detection.") # Upload an image uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png", "mp4"]) if uploaded_file is not None: # Check if it's an image or video if uploaded_file.type.startswith('image'): # Read the image file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8) image = cv2.imdecode(file_bytes, 1) # Process the image processed_frame = lpa.forward(image) if processed_frame is not None: # Convert to RGB for display processed_frame_rgb = cv2.cvtColor(processed_frame, cv2.COLOR_BGR2RGB) st.image(processed_frame_rgb, channels="RGB") else: st.write("No license plate detected.") elif uploaded_file.type.startswith('video'): # Handle video upload (this is more complex, but possible) st.write("Video processing is not yet supported.")