File size: 1,217 Bytes
acbb1f1
 
 
 
 
 
 
 
ed7be31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
acbb1f1
ed7be31
acbb1f1
ed7be31
 
 
 
 
 
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
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.")