Skip to content

This repository contains the code and analysis for the research paper "Pedestrian Planet: What YouTube Driving from 233 Countries and Territories Teaches Us About the World", presented at the 17th International Conference on Automotive User Interfaces and Interactive Vehicular Applications (AutomotiveUI’25).

License

Notifications You must be signed in to change notification settings

bazilinskyy/youtube-national

 
 

Repository files navigation

Overview

Pedestrian crossing behaviour varies globally. This study analyses dashcam footage from the CROWD dataset, covering 233 countries and territories, to examine crossing initiation time, crossing speed, and contextual variables, including detected vehicles, traffic mortality, GDP, and Gini coefficient. Qatar had the longest mean crossing initiation time (6.44 s), while China exhibited the fastest crossing speed (1.69 m/s). On average, worldwide, pedestrians exhibited a crossing initiation time of 3.18 s and crossing speed 1.20 m/s. Crossing speed and crossing initiation time are negatively correlated (r = -0.18), indicating slower crossings after longer hesitation. Crossing speed is negatively correlated with Gini coefficient (r = -0.19) and positively correlated with traffic mortality (r = 0.18). Similar crossing times in countries with different infrastructures, such as Bangladesh (3.42 s) and the Netherlands (3.40 s), underscore the complex interaction between infrastructure and behavioural adaptation. These findings emphasise the importance of culturally aware road design and the development of adaptive interfaces for vehicles.

Usage of the code

The code is open-source and free to use. It is aimed for, but not limited to, academic research. We welcome forking of this repository, pull requests, and any contributions in the spirit of open science and open-source code 😍😄 For inquiries about collaboration, you may contact Md Shadab Alam (md_shadab_alam@outlook.com) or Pavlo Bazilinskyy (pavlo.bazilinskyy@gmail.com).

Citation

If you use the this project for academic work please cite the following paper:

Alam, M. S., Martens, M. H., & Bazilinskyy, P. (2025). Pedestrian planet: What YouTube driving from 233 countries and territories teaches us about the world. 17th International Conference on Automotive User Interfaces and Interactive Vehicular Applications. Brisbane, QLD, Australia. https://doi.org/10.1145/3744333.3747827

Getting started

Python Version Package Manager: uv

Tested with Python 3.9.19 and the uv package manager.
Follow these steps to set up the project.

Step 1: Install uv. uv is a fast Python package and environment manager. Install it using one of the following methods:

macOS / Linux (bash/zsh):

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows (PowerShell):

irm https://astral.sh/uv/install.ps1 | iex

Alternative (if you already have Python and pip):

pip install uv

Step 2: Fix permissions (if needed):

Sometimes uv needs to create a folder under ~/.local/share/uv/python (macOS/Linux) or %LOCALAPPDATA%\uv\python (Windows).
If this folder was created by another tool (e.g. sudo), you may see an error like:

error: failed to create directory ... Permission denied (os error 13)

To fix it, ensure you own the directory:

macOS / Linux

mkdir -p ~/.local/share/uv
chown -R "$(id -un)":"$(id -gn)" ~/.local/share/uv
chmod -R u+rwX ~/.local/share/uv

Windows

# Create directory if it doesn't exist
New-Item -ItemType Directory -Force "$env:LOCALAPPDATA\uv"

# Ensure you (the current user) own it
# (usually not needed, but if permissions are broken)
icacls "$env:LOCALAPPDATA\uv" /grant "$($env:UserName):(OI)(CI)F"

Step 3: After installing, verify:

uv --version

Step 4: Clone the repository:

git clone https://github.com/bazilinskyy/youtube-national
cd youtube-national

Step 5: Ensure correct Python version. If you don’t already have Python 3.9.19 installed, let uv fetch it:

uv python install 3.9.19

The repo should contain a .python-version file so uv will automatically use this version.

Step 6: Create and sync the virtual environment. This will create .venv in the project folder and install dependencies exactly as locked in uv.lock:

uv sync --frozen

Step 7: Activate the virtual environment:

macOS / Linux (bash/zsh):

source .venv/bin/activate

Windows (PowerShell):

.\.venv\Scripts\Activate.ps1

Windows (cmd.exe):

.\.venv\Scripts\activate.bat

Step 8: Ensure that dataset are present. Place required datasets (including mapping.csv) into the data/ directory:

Step 9: Run the code:

python3 analysis.py

Configuration of project

Configuration of the project needs to be defined in config. Please use the default.config file for the required structure of the file. If no custom config file is provided, default.config is used. The config file has the following parameters:

  • data: Directories containing data (CSV output from YOLO).
  • videos: Directories containing the videos used to generate the data.
  • mapping: CSV file that contains mapping data for the cities referenced in the data.
  • machine_name: User-defined name for the machine; included in notification emails to help identify which machine the emails are coming from.
  • tracking_mode: Configures YOLO for object tracking.
  • segmentation_mode: Configures YOLO for object detection.
  • always_analyse: Always conduct analysis even when pickle files are present (good for testing).
  • display_frame_tracking: Displays the frame tracking during analysis.
  • display_frame_segmentation: Displays the frame segmentation during analysis.
  • save_annotated_img: Saves the annotated frames produced by YOLO.
  • save_tracked_img: Saves the tracked frames produced during YOLO analysis.
  • delete_labels: Deletes label files from YOLO output.
  • delete_frames: Deletes frames from YOLO output.
  • delete_youtube_video: Deletes downloaded YouTube videos.
  • compress_youtube_video: Compresses YouTube videos (using the H.255 codec by default).
  • save_annotated_video: Saves the annotated video produced by YOLO.
  • delete_runs_files: Deletes files containing YOLO output after analysis.
  • check_missing_mapping: Identifies all the missing csv files.
  • min_max_videos: Takes a value n and returns the n fastest and n slowest speed/time segments with tracked objects.
  • bbox_tracker: Specifies the bounding-box based tracker to be used.
  • seg_tracker: Specifies the segmentation-based tracker to be used.
  • client: Specifies the client type for downloading YouTube videos; accepted values are "WEB", "ANDROID" or "ios".
  • tracking_model: Specifies the YOLO model to use; supported/tested versions include v8x and v11x.
  • segment_model: Specifies the YOLO segmentation model to use; supported/tested version includes yolo11x-seg.
  • reanalyse_waiting_time:If set to True, the crossing initiation time will be reanalysed once the analysis is complete; new values are then taken from min_waiting_time and max_waiting_time.
  • min_waiting_time: Minimum crossing initiation time (in seconds); the lowest allowed value is 1 s.
  • max_waiting_time: Maximum crossing initiation time (in seconds).
  • check_per_sec_time: Number of checks per second to verify whether a person remains in the same position as during the previous check.
  • boundary_left: Normalised position value (e.g., 0.4) representing the left boundary; if a person crosses this point, they are considered as crossing the road.
  • boundary_right: Normalised position value (e.g., 0.6) representing the right boundary; if a person crosses this point, they are considered as crossing the road.
  • use_geometry_correction: Applies geometric correction to prevent identity switches (ID swaps) when objects cross paths (e.g., overtaking).
  • population_threshold: Minimum population threshold for including a city in analysis.
  • footage_threshold: Minimum total footage of the city required for including a video in the analysis.
  • min_city_population_percentage:Minimum percentage of the population of the country required for the city to be included in the analysis.
  • min_crossing_detect: Minimum number of crossings detected in the country required for the country to be included in the analysis.
  • reanalyse_speed: If set to True, the speed at which the analysis is re-executed will be adjusted. The new speed values can be set within the min_speed_limit and max_speed_limit.
  • min_speed_limit: Minimum speed of the pedestrian while crossing during analysis.
  • max_speed_limit: Maximum speed of the pedestrian while crossing during analysis.
  • countries_analyse: Lists the countries to be analysed, specified using their ISO3 country codes.
  • vehicles_analyse: Specifies the list of vehicle types to analyse using the following values: 0 for car, 1 for bus, 2 for truck, 3 for two-wheeler, 4 for bicycle, 5 for automated car, 6 for automated bus, 7 for automated truck, 8 for automated two-wheeler, and 9 for electric scooter.
  • confidence: Sets the confidence threshold parameter for YOLO.
  • update_ISO_code: Updates the ISO code of the country in the mapping file during analysis.
  • update_pop_country: Updates the country’s population in the mapping file during analysis.
  • update_mortality_rate: Updates the mortality rate of the country in the mapping file during analysis.
  • update_gini_value: Updates the GINI value of the country in the mapping file during analysis.
  • update_upload_date: Updates the upload date of videos in the mapping file during analysis.
  • update_package: Updates the pytubefix library each time analysis starts.
  • need_authentication: Enables authentication when required for downloading YouTube videos.
  • font_family: Specifies the font family to be used in outputs.
  • font_size: Specifies the font size to be used in outputs.
  • plotly_template: Defines the template for Plotly figures.
  • logger_level: Level of console output. Can be: debug, info, warning, error.
  • sleep_sec: Amount of seconds of pause between going over the mapping files.
  • git_pull: Automatically pulls the latest updates from the Git repository before running analysis.
  • email_send: Enables or disables email notifications after the analysis. If enabled, an email is sent when the processing is completed or if an error occurs.
  • email_sender: Specifies the email address used as the sender for notifications.
  • email_recipients: A list of email addresses that will receive notifications about the analysis, including completion or error messages.
  • ftp_server: URL of the remote server (e.g., https://files.mobility-squad.com/) from where videos can be retrieved or uploaded for analysis and storage purposes.

Description and analysis of dataset

Refer to https://github.com/Shaadalam9/pedestrians-in-youtube for a description of the selection criteria for videos in the underlying CROWD dataset.

Locations of cities with footage in dataset A political world map colored by continent, showing 233 countries included in the analysis. The shading represents the total duration of dashcam footage from each country, adjusted with a logarithmic scale so that countries with very large or very small totals are both visible. Black dots indicate the cities from which footage was collected.

Histogram of pedestrian crossing speeds
Histogram of pedestrian crossing speeds (in m/s), computed per individual pedestrian and pooled across all locations/countries (i.e., not aggregated by city or country).

Histogram of pedestrian crossing initiation time
Histogram of pedestrian crossing initiation time (in s), computed per individual pedestrian and pooled across all locations/countries (i.e., not aggregated by city or country).

Mean time to start crossing (in s, sorted by average of day) Mean time to start crossing (in s, sorted by day).

Mean speed of crossing (in m/s, sorted by average of day) Mean speed of crossing (in m/s, sorted by day).

Dataset after filtering

The dataset undergoes a filtering process to ensure quality and sufficient coverage before being used in analysis. The following thresholds are applied:

  • footage_threshold = 1800. A city is included only if it has more than 1800 seconds (30 minutes) of recorded footage. This ensures each city has a substantial amount of data for reliable insights.
  • min_crossing_detect = 100. A country is included only if at least 100 pedestrian crossings are detected within its boundaries. This ensures that pedestrian-related statistics are meaningful at the country level.
  • vehicles_analyse = [0] → Only cars are analysed (0 = car).
  • min_speed_limit = 0.5, max_speed_limit = 2.5 → Only crossings with pedestrian speeds within this range are considered.
  • boundary_left = 0.45, boundary_right = 0.55 → Crossing is counted when a person moves across these normalized frame-width positions (0 = far left, 1 = far right).
  • reanalyse_waiting_time = false, min_waiting_time = 1, max_waiting_time = 150 → Reanalysis of crossing initiation time is disabled; waiting-time values are ignored (note: effective minimum waiting time is 1 s).
  • check_per_sec_time = 3 → Performs 3 checks per second to verify if a person remains in the same position as the previous check.

Histogram of pedestrian crossing speeds
Histogram of pedestrian crossing speeds (in m/s), computed per individual pedestrian and pooled across all locations/countries (i.e., not aggregated by city or country).

Histogram of pedestrian crossing initiation time
Histogram of pedestrian crossing initiation time (in s), computed per individual pedestrian and pooled across all locations/countries (i.e., not aggregated by city or country).

Location of the cities included in the dataset after filtering Location of the cities included in the dataset after filtering.

Total time of footage after filtering Total time of footage after filtering.

Time to start crossing

Map with mean time to start crossing (in s) Map with heatmap based on mean time to start crossing (in s).

Mean time to start crossing (in s, sorted by average of day and night) Mean time to start crossing (in s, sorted by average of day and night).

Mean time to start crossing (in s, sorted by average of day) Mean time to start crossing (in s, sorted by day).

Mean time to start crossing (in s, sorted alphabetically)
Mean time to start crossing (in s, sorted alphabetically).

Mean time to start crossing at day (in s, sorted by values)
Mean time to start crossing at day (in s, sorted by values).

Mean time to start crossing at night (in s, sorted by values)
Mean time to start crossing at night (in s, sorted by values).

Speed of crossing

Map with mean speed of crossing (in m/s) Map with heatmap based on mean speed of crossing (in m/s).

Mean speed of crossing (in m/s, sorted by average of day and night) Mean speed of crossing (in m/s, sorted by average of day and night).

Mean speed of crossing (in m/s, sorted by average of day) Mean speed of crossing (in m/s, sorted by day).

Mean speed of crossing (in m/s, sorted alphabetically) Mean speed of crossing (in m/s, sorted alphabetically).

Mean speed of crossing at day (in m/s, sorted by values)
Mean speed of crossing at day (in m/s, sorted by values).

Mean speed of crossing at night (in m/s, sorted by values)
Mean speed of crossing at night (in m/s, sorted by values).

Relationship between computed and statistical metrics

Mean speed of crossing during daytime over mean time to start crossing
Mean speed of crossing (in m/s) during daytime over mean time to start crossing (in s).

Mean speed of crossing vs. proportion of pedestrians detected using a cellphone
Mean speed of crossing (in m/s) versus the proportion of pedestrians detected using a cellphone.

Mean speed of crossing over Gini index
Mean speed of crossing (in m/s) over Gini index (income inequality).

Mean speed of crossing over literacy rate
Mean speed of crossing (in m/s) over literacy rate (% of population).

Mean speed of crossing over median age
Mean speed of crossing (in m/s) over median age of the population.

Mean speed of crossing over population
Mean speed of crossing (in m/s) over total population of the country.

Mean speed of crossing over mean time to start crossing
Mean speed of crossing (in m/s) over mean time to start crossing (in s).

Mean speed of crossing over traffic mortality rate
Mean speed of crossing (in m/s) over traffic-related mortality (per 100,000 people).

Mean speed of crossing at night over mean time to start crossing
Mean speed of crossing (in m/s) at night over mean time to start crossing (in s).

Mean time to start crossing vs. proportion of pedestrians detected using a cellphone
Mean time to start crossing (in s) versus the proportion of pedestrians detected using a cellphone.

Mean time to start crossing over Gini index
Mean time to start crossing (in s) over Gini index (income inequality).

Mean time to start crossing over literacy rate
Mean time to start crossing (in s) over literacy rate (% of population).

Mean time to start crossing over median age
Mean time to start crossing (in s) over median age of the population.

Mean time to start crossing over population
Mean time to start crossing (in s) over total population of the country.

Mean time to start crossing over traffic mortality rate
Mean time to start crossing (in s) over traffic-related mortality (per 100,000 people).

Total footage time over bicycle count (normalised)
Total footage time (in s) over number of bicycles (normalised per detected persons).

Total footage time over pedestrian count (normalised)
Total footage time (in s) over number of pedestrians (normalised per detected pedestrian).

Total footage time over pedestrian count
Total footage time (in s) over total number of pedestrians.

Footage with traffic light over footage without traffic light (normalised)
Footage with traffic lights over footage without traffic lights, both normalised per population.

Correlation matrices

Correlation matrix based on average speed and time to start cross Correlation matrix of average values of day and night.

Correlation matrix at daytime Correlation matrix at daytime.

Correlation matrix at night time Correlation matrix at night time.

Correlation matrix for Africa Correlation matrix for Africa.

Correlation matrix for Asia Correlation matrix for Asia.

Correlation matrix for Oceania Correlation matrix for Oceania.

Correlation matrix for Europe Correlation matrix for Europe.

Correlation matrix for North America Correlation matrix for North America.

Correlation matrix for South America Correlation matrix for South America.

Edge cases in analysed data

The analysis surfaced several edge cases that complicate detection and measurement. Some “fastest” crossings are inflated by camera rotation or vehicle turning, which can make nearby pedestrians appear to traverse the frame as if crossing the roadway, while some “slowest” cases involve people pushing carts or approaching the ego vehicle before stepping off, stretching initiation times and lowering apparent speeds. To curb false positives, we filtered out rider-like trajectories (bicycle/motorcycle) and frame-motion artifacts, but occasional misclassification remains—e.g., cyclists or motorcyclists labeled as “person” when trajectories overlap. Measurement noise also arises from converting pixels to meters using national average human height and from perspective effects; thus we exclude implausible speeds (<0.5 or >2.5 m/s) and initiation times (<1 or >150 s) and verify “static” status using a ±0.1 · mean-height margin at sub-second checks. Finally, because the base detector does not recognize road boundaries or subtle cues (e.g., posture/gestures), some complex scenes remain error-prone; future improvements (lane detection, pose estimation, stronger multi-object tracking) are likely to reduce these edge cases.

Fastest crossings


📍 Johannesburg (ZAF)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Stavropol (RUS)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Cebu City (PHL)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Aleppo (SYR)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Tallinn (EST)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Den Haag (NLD)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Kathmandu (NPL)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Istanbul (TUR)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Stockholm (SWE)
⚡ 2.50 m/s
🎥 Event, YouTube video

📍 Accra (GHA)
⚡ 2.50 m/s
🎥 Event, YouTube video

Slowest crossings


📍 Toronto (CAN)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Toronto (CAN)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Kathmandu (NPL)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Brussels (BEL)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 London (GBR)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Damascus (SYR)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Monterrey (MEX)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Belem (BRA)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Montreal (CAN)
⚡ 0.50 m/s
🎥 Event, YouTube video

📍 Wellington (USA)
⚡ 0.50 m/s
🎥 Event, YouTube video

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

If you have any questions or suggestions, feel free to reach out to md_shadab_alam@outlook.com.

About

This repository contains the code and analysis for the research paper "Pedestrian Planet: What YouTube Driving from 233 Countries and Territories Teaches Us About the World", presented at the 17th International Conference on Automotive User Interfaces and Interactive Vehicular Applications (AutomotiveUI’25).

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 99.8%
  • Python 0.2%