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
```python
from ultralytics.solutions.parking_management import ParkingPtsSelection, tk
!!! Example "Parking slots Annotator Ultralytics YOLOv8"
root = tk.Tk()
ParkingPtsSelection(root)
root.mainloop()
```
=== "Parking Annotator"
```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.

View File

@ -8,7 +8,7 @@ keywords: Ultralytics, YOLOv8, Object Detection, Speed Estimation, Object Tracki
## 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">
<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
</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?
- **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
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.
keywords: YOLOv10, real-time object detector, state-of-the-art, Tsinghua University, COCO dataset, NMS-free training, holistic model design, efficient architecture
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 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

View File

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

View File

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

View File

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

View File

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