Reference for ultralytics/solutions/speed_estimation.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/speed_estimation.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.solutions.speed_estimation.SpeedEstimator
A class to estimate the speed of objects in a real-time video stream based on their tracks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names |
dict
|
Dictionary of class names. |
required |
reg_pts |
list
|
List of region points for speed estimation. Defaults to [(20, 400), (1260, 400)]. |
None
|
view_img |
bool
|
Whether to display the image with annotations. Defaults to False. |
False
|
line_thickness |
int
|
Thickness of the lines for drawing boxes and tracks. Defaults to 2. |
2
|
spdl_dist_thresh |
int
|
Distance threshold for speed calculation. Defaults to 10. |
10
|
Source code in ultralytics/solutions/speed_estimation.py
estimate_speed
Estimates the speed of objects based on tracking data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im0 |
ndarray
|
Image. |
required |
tracks |
list
|
List of tracks obtained from the object tracking process. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The image with annotated boxes and tracks. |