Lädt...

🔧 Crop Bounding Box ( part deux! ) for License Plate


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Abstract

We are pre-processing photos to ultimately enable OCR. Prior step we found the bounding box for license plates. Let’s crop down images to only license plates themselves for OCR next.

Step-by-Step

License plate detection workflow visualized

Recipe

The over-arching goal is to read license plate numbers from images. On that journey, we detected cars in highway image captures, cropped to just cars, and detected license plates on car images. Now we crop to just license plates. And those zoomed-in license plate images are inputs to OCR, which will read license plate numbers into database.

Unlike prior cropping step, we can safely assume one license plate per image. It’s not 1:[0,n) it’s 1:[0,1].

Thus, simple step: if we found a license plate (ie have a bounding box), then crop license plate

from ultralytics import YOLO
import cv2 
import imutils
import numpy as np
from os import path

baseDir = '/Users/japollock/Projects/TrainHighwayCarDetector/'
inputFilePath = baseDir + 'photos/yolo_licensePlates/licensePlates/IMG_4554_0002.jpg'
inputFileName = path.basename(inputFilePath)
outputPhotosDir = baseDir + 'photos/yolo_licensePlates/croppedPlates/'
model = YOLO(baseDir + 'src/runs/detect/yolov8n_100_16_LP_v27/weights/best.pt')

imageOriginal = cv2.imread(inputFilePath)
imageScaled = imutils.resize(imageOriginal, width=1280)

imgRatio = imageOriginal.shape[1] / imageScaled.shape[1]

results = model.predict(source=imageScaled, imgsz=1280)

if results is not None and len(results) > 0 and results[0].boxes is not None and len(results[0].boxes) > 0:
    box = results[0].boxes[0]
    # bounding box in scaled-down image
    x1Float = box.xyxy[0][0].item()
    x2Float = box.xyxy[0][2].item()
    y1Float = box.xyxy[0][1].item()
    y2Float = box.xyxy[0][3].item()

    # calc bounding box in original (scaled-up) image
    x1 = int(imgRatio * x1Float)
    y1 = int(imgRatio * y1Float)
    x2 = int(imgRatio * x2Float)
    y2 = int(imgRatio * y2Float)

    # cropped
    imageCropped = imageOriginal[y1:y2,x1:x2]

    outputFilePath = outputPhotosDir + inputFileName[0:(len(inputFileName)-4)] + '.jpg'
    cv2.imwrite(outputFilePath, imageCropped)
    print('Wrote ' + outputFilePath)

At this point we’re enabling from highway to car to license plate, such as the following:

Highway view

Cropped car, and cropped license plate

Almost there! From highway-view image capture, to car, to license plate. Next up: OCR!

Next Link: TBD -- Read license plate with OCR

...

🔧 Crop Bounding Box ( part deux! ) for License Plate


📈 109.97 Punkte
🔧 Programmierung

🔧 Crop Bounding Box + Rotate


📈 52.89 Punkte
🔧 Programmierung

🔧 Ctrl-V: Higher Fidelity Video Generation with Bounding-Box Controlled Object Motion


📈 35.71 Punkte
🔧 Programmierung

📰 Cropping Landsat Scenes from their Bounding Box using Python


📈 35.71 Punkte
🔧 AI Nachrichten

🪟 Use Crop And Lock in PowerToys to crop an app into smaller interactive window


📈 34.35 Punkte
🪟 Windows Tipps

🕵️ Low CVE-2015-9426: Manual image crop project Manual image crop


📈 34.35 Punkte
🕵️ Sicherheitslücken

🔧 Separation of Storage and Compute, Part Deux


📈 29.15 Punkte
🔧 Programmierung

🎥 HPR4247: Installing GuixSD--Part Deux


📈 29.15 Punkte
🎥 Podcasts

📰 Public Wi-Fi Insecurity – Part Deux, For Compliance Sakes


📈 29.15 Punkte
📰 IT Security Nachrichten

🎥 AI Show Live - Episode 58 - Microsoft Build 2022 Recap (Part Deux)


📈 29.15 Punkte
🎥 Video | Youtube

🎥 Security & Compliance Legal Highlights - Part Deux - SCW #65


📈 29.15 Punkte
🎥 IT Security Video

📰 Password killer FIDO2 comes bounding into Azure Active Directory hybrid environments


📈 28.61 Punkte
📰 IT Security Nachrichten

📰 License Plate Readers Are Creating a US-Wide Database of More Than Just Cars


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 ParkMobile Breach Exposes License Plate Data, Mobile Numbers of 21M Users


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 Police can't keep license plate data scans secret without reason


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 Millions of Kia Vehicles Open to Remote Hacks via License Plate


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 DJI Proposes New Electronic 'License Plate' For Drones


📈 27.93 Punkte
📰 IT Security Nachrichten

🕵️ Hacking Kia Cars Remotely with a License Plate


📈 27.93 Punkte
🕵️ Hacking

📰 Hackers breach US license plate scanning company


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 America's Border Patrol 'Can Track Everyone's Car' By Buying License Plate-Reader Data


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 Feds Convinced Police To Use License Plate-Scanning Tech At Gun Shows


📈 27.93 Punkte
📰 IT Security

📰 Hackers Could Steal Millions of Kia Cars Using Just a License Plate


📈 27.93 Punkte
📰 IT Security Nachrichten

🕵️ Hacker breached Perceptics, a US maker of license plate readers


📈 27.93 Punkte
🕵️ Hacking

🎥 Use Skiptracer to Gather License Plate OSINT Data [Tutorial]


📈 27.93 Punkte
🎥 IT Security Video

📰 Feds Convinced Police To Use License Plate-Scanning Tech At Gun Shows


📈 27.93 Punkte
📰 IT Security

📰 This company wants to sell license plate readers for your neighbors to track you video


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 Hacking Kia cars made after 2013 using just their license plate


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 Hackers Breach Company That Makes License Plate Readers for US Government


📈 27.93 Punkte
📰 IT Security Nachrichten

📰 Rekor could turn every home's camera into a license plate reader


📈 27.93 Punkte
📰 IT Security Nachrichten

matomo