ultralytics 8.2.22 Parking Management Solution fix (#13122)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Muhammad Rizwan Munawar 2024-05-25 22:25:54 +05:00 committed by GitHub
parent 11d1928479
commit 1f438bf633
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 42 additions and 31 deletions

View file

@ -38,13 +38,14 @@ Parking management with [Ultralytics YOLOv8](https://github.com/ultralytics/ultr
Max Image Size of 1920 * 1080 supported Max Image Size of 1920 * 1080 supported
```python !!! Example "Parking slots Annotator Ultralytics YOLOv8"
from ultralytics.solutions.parking_management import ParkingPtsSelection, tk
root = tk.Tk() === "Parking Annotator"
ParkingPtsSelection(root)
root.mainloop() ```python
``` from ultralytics import solutions
solutions.ParkingPtsSelection()
```
- After defining the parking areas with polygons, click `save` to store a JSON file with the data in your working directory. - After defining the parking areas with polygons, click `save` to store a JSON file with the data in your working directory.

View file

@ -8,7 +8,7 @@ keywords: Ultralytics, YOLOv8, Object Detection, Speed Estimation, Object Tracki
## What is Speed Estimation? ## What is Speed Estimation?
Speed estimation is the process of calculating the rate of movement of an object within a given context, often employed in computer vision applications. Using [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics/) you can now calculate the speed of object using [object tracking](../modes/track.md) alongside distance and time data, crucial for tasks like traffic and surveillance. The accuracy of speed estimation directly influences the efficiency and reliability of various applications, making it a key component in the advancement of intelligent systems and real-time decision-making processes. [Speed estimation](https://www.ultralytics.com/blog/ultralytics-yolov8-for-speed-estimation-in-computer-vision-projects) is the process of calculating the rate of movement of an object within a given context, often employed in computer vision applications. Using [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics/) you can now calculate the speed of object using [object tracking](../modes/track.md) alongside distance and time data, crucial for tasks like traffic and surveillance. The accuracy of speed estimation directly influences the efficiency and reliability of various applications, making it a key component in the advancement of intelligent systems and real-time decision-making processes.
<p align="center"> <p align="center">
<br> <br>
@ -21,6 +21,10 @@ Speed estimation is the process of calculating the rate of movement of an object
<strong>Watch:</strong> Speed Estimation using Ultralytics YOLOv8 <strong>Watch:</strong> Speed Estimation using Ultralytics YOLOv8
</p> </p>
!!! tip "Check Out Our Blog"
For deeper insights into speed estimation, check out our blog post: [Ultralytics YOLOv8 for Speed Estimation in Computer Vision Projects](https://www.ultralytics.com/blog/ultralytics-yolov8-for-speed-estimation-in-computer-vision-projects)
## Advantages of Speed Estimation? ## Advantages of Speed Estimation?
- **Efficient Traffic Control:** Accurate speed estimation aids in managing traffic flow, enhancing safety, and reducing congestion on roadways. - **Efficient Traffic Control:** Accurate speed estimation aids in managing traffic flow, enhancing safety, and reducing congestion on roadways.

View file

@ -1,7 +1,7 @@
--- ---
comments: true comments: true
description: Explore the YOLOv10, a real-time object detector. Understand its superior speed, impressive accuracy, and unique approach to end-to-end object detection optimization. description: Discover YOLOv10, a cutting-edge real-time object detector known for its exceptional speed and accuracy. Learn about NMS-free training, holistic model design, and performance across various scales.
keywords: YOLOv10, real-time object detector, state-of-the-art, Tsinghua University, COCO dataset, NMS-free training, holistic model design, efficient architecture keywords: YOLOv10, real-time object detection, Tsinghua University, COCO dataset, NMS-free training, efficient architecture, object detection optimization, state-of-the-art AI
--- ---
# YOLOv10: Real-Time End-to-End Object Detection # YOLOv10: Real-Time End-to-End Object Detection

View file

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.2.21" __version__ = "8.2.22"
from ultralytics.data.explorer.explorer import Explorer from ultralytics.data.explorer.explorer import Explorer
from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld

View file

@ -5,7 +5,7 @@ from .analytics import Analytics
from .distance_calculation import DistanceCalculation from .distance_calculation import DistanceCalculation
from .heatmap import Heatmap from .heatmap import Heatmap
from .object_counter import ObjectCounter from .object_counter import ObjectCounter
from .parking_management import ParkingManagement from .parking_management import ParkingManagement, ParkingPtsSelection
from .queue_management import QueueManager from .queue_management import QueueManager
from .speed_estimation import SpeedEstimator from .speed_estimation import SpeedEstimator

View file

@ -1,3 +1,5 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
from itertools import cycle from itertools import cycle
import cv2 import cv2

View file

@ -1,3 +1,5 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
import json import json
from tkinter import filedialog, messagebox from tkinter import filedialog, messagebox
@ -10,32 +12,31 @@ from ultralytics.utils.plotting import Annotator
class ParkingPtsSelection: class ParkingPtsSelection:
def __init__(self, master): def __init__(self):
""" """Initializes the UI for selecting parking zone points in a tkinter window."""
Initializes the UI for selecting parking zone points in a tkinter window.
Args:
master (tk.Tk): The main tkinter window object.
"""
check_requirements("tkinter") check_requirements("tkinter")
import tkinter as tk import tkinter as tk
self.master = master self.tk = tk
master.title("Ultralytics Parking Zones Points Selector") self.master = tk.Tk()
self.master.title("Ultralytics Parking Zones Points Selector")
# Disable window resizing # Disable window resizing
master.resizable(False, False) self.master.resizable(False, False)
# Setup canvas for image display # Setup canvas for image display
self.canvas = tk.Canvas(master, bg="white") self.canvas = self.tk.Canvas(self.master, bg="white")
# Setup buttons # Setup buttons
button_frame = tk.Frame(master) button_frame = self.tk.Frame(self.master)
button_frame.pack(side=tk.TOP) button_frame.pack(side=self.tk.TOP)
tk.Button(button_frame, text="Upload Image", command=self.upload_image).grid(row=0, column=0) self.tk.Button(button_frame, text="Upload Image", command=self.upload_image).grid(row=0, column=0)
tk.Button(button_frame, text="Remove Last BBox", command=self.remove_last_bounding_box).grid(row=0, column=1) self.tk.Button(button_frame, text="Remove Last BBox", command=self.remove_last_bounding_box).grid(
tk.Button(button_frame, text="Save", command=self.save_to_json).grid(row=0, column=2) row=0, column=1
)
self.tk.Button(button_frame, text="Save", command=self.save_to_json).grid(row=0, column=2)
# Initialize properties # Initialize properties
self.image_path = None self.image_path = None
@ -50,6 +51,8 @@ class ParkingPtsSelection:
self.canvas_max_width = 1280 self.canvas_max_width = 1280
self.canvas_max_height = 720 self.canvas_max_height = 720
self.master.mainloop()
def upload_image(self): def upload_image(self):
"""Upload an image and resize it to fit canvas.""" """Upload an image and resize it to fit canvas."""
self.image_path = filedialog.askopenfilename(filetypes=[("Image Files", "*.png;*.jpg;*.jpeg")]) self.image_path = filedialog.askopenfilename(filetypes=[("Image Files", "*.png;*.jpg;*.jpeg")])
@ -74,12 +77,12 @@ class ParkingPtsSelection:
if self.canvas: if self.canvas:
self.canvas.destroy() # Destroy previous canvas self.canvas.destroy() # Destroy previous canvas
self.canvas = tk.Canvas(self.master, bg="white", width=canvas_width, height=canvas_height) self.canvas = self.tk.Canvas(self.master, bg="white", width=canvas_width, height=canvas_height)
resized_image = self.image.resize((canvas_width, canvas_height), Image.LANCZOS) resized_image = self.image.resize((canvas_width, canvas_height), Image.LANCZOS)
self.canvas_image = ImageTk.PhotoImage(resized_image) self.canvas_image = ImageTk.PhotoImage(resized_image)
self.canvas.create_image(0, 0, anchor=tk.NW, image=self.canvas_image) self.canvas.create_image(0, 0, anchor=self.tk.NW, image=self.canvas_image)
self.canvas.pack(side=tk.BOTTOM) self.canvas.pack(side=self.tk.BOTTOM)
self.canvas.bind("<Button-1>", self.on_canvas_click) self.canvas.bind("<Button-1>", self.on_canvas_click)
# Reset bounding boxes and current box # Reset bounding boxes and current box
@ -115,7 +118,7 @@ class ParkingPtsSelection:
if self.bounding_boxes: if self.bounding_boxes:
self.bounding_boxes.pop() # Remove the last bounding box self.bounding_boxes.pop() # Remove the last bounding box
self.canvas.delete("all") # Clear the canvas self.canvas.delete("all") # Clear the canvas
self.canvas.create_image(0, 0, anchor=tk.NW, image=self.canvas_image) # Redraw the image self.canvas.create_image(0, 0, anchor=self.tk.NW, image=self.canvas_image) # Redraw the image
# Redraw all bounding boxes # Redraw all bounding boxes
for box in self.bounding_boxes: for box in self.bounding_boxes:
@ -210,6 +213,7 @@ class ParkingManagement:
im0 (ndarray): inference image im0 (ndarray): inference image
boxes (list): bounding boxes data boxes (list): bounding boxes data
clss (list): bounding boxes classes list clss (list): bounding boxes classes list
Returns: Returns:
filled_slots (int): total slots that are filled in parking lot filled_slots (int): total slots that are filled in parking lot
empty_slots (int): total slots that are available in parking lot empty_slots (int): total slots that are available in parking lot