Skip to content

HelenTrinh-NA/IE_TrafficSeg

Repository files navigation

IE_TrafficSeg: Freight Traffic Intelligence System (FreTIS)

License: MIT Python 3.8+ Research Project

Computer Vision and Machine Learning for Inland Empire Freight Traffic Analysis

A Leonard Transportation Center (LTC) research project analyzing freight exposure and environmental justice in California's most freight-intensive region.


Table of Contents

  1. Quick Start
  2. Project Overview
  3. Repository Structure
  4. Installation & Setup
  5. Data Pipeline
  6. Key Results
  7. Research Context
  8. Technical Documentation
  9. Contact & Acknowledgments

Quick Start

For First-Time Users:

  1. Review the proposal: Start with LTC Proposal Freight Services_BK.docx.md to understand the research objectives and methodology
  2. Install dependencies: Follow the Installation & Setup section below
  3. Explore sample outputs: Check the segmentation examples:
    • sample_truck_segmentation.png and .json (original demo)
    • sample_truck_segmentation_20251201.png and .json (latest version)
  4. Examine data structure: Navigate through the data/raw_images/ directory organized by camera location
  5. Review results: See OpenSeeD/extracted_data_full/ for processed segmentation outputs

Key Files to Start With:

  • 📄 LTC Proposal Freight Services_BK.docx.md - Full research proposal and methodology
  • 📊 DATA.md - Important! How to obtain camera images and data
  • 📸 sample_truck_segmentation*.png - Visual demonstration of segmentation capabilities
  • 📊 sample_truck_segmentation*.json - Sample JSON output structure
  • 📝 requirements.txt - Python dependencies list

⚠️ Data Notice: Raw camera images (~19,543 files, ~5-6GB) are NOT included in this repository due to size constraints and licensing. See DATA.md for instructions on obtaining the data.


Project Overview

What is FreTIS?

FreTIS (Freight Traffic Intelligence System) is a research initiative that transforms freeway camera imagery into actionable freight analytics to address environmental justice concerns in Southern California's Inland Empire.

Research Objectives

  1. Computer Vision Pipeline: Develop Inland Empire-specific freight vehicle detection and segmentation using OpenSeeD
  2. Freight Metrics: Quantify truck volumes, temporal patterns, and freight intensity across major corridors
  3. Data Integration: Combine vision-derived metrics with demographic, environmental, health, and safety datasets
  4. Correlation Analysis: Assess freight exposure impacts on disadvantaged communities
  5. Predictive Modeling: Forecast truck volumes 1-7 days ahead for proactive risk alerts
  6. Policy Support: Deliver web-based analytics and peer-reviewed research

Why This Matters

The Problem:

  • 11.15M+ medium-duty truck trips annually (2021)
  • 5.73M+ heavy-duty truck trips annually (2021)
  • 2.63M+ residents exposed to freight corridors (2024)
  • 700+ large distribution centers with continued expansion
  • Elevated pollution and health impacts in disadvantaged communities

The Gap: Traditional traffic monitoring (e.g., Caltrans PeMS) provides:

  • Aggregate flow data without vehicle-type detail
  • No lane-level behavior analysis
  • No visual/incident context
  • Poor freight vehicle classification

FreTIS Solution:

  • Vehicle-specific freight measurement
  • Lane-level analysis with visual context
  • Camera-level spatial resolution
  • Hourly temporal resolution
  • Integration with environmental justice data

Repository Structure

IE_TrafficSeg/
│
├── 📄 README.md                              # This navigation guide
├── 📄 LTC Proposal Freight Services_BK.docx.md  # Full research proposal (START HERE!)
├── 📄 requirements.txt                       # Python dependencies
├── 📄 generate_uml_diagram.py                # Project structure visualization tool
├── 📄 scraper.log                            # Data collection logs
├── 📄 WARP.md                                # [Documentation file]
│
├── 📸 sample_truck_segmentation.png          # Example segmentation output (demo)
├── 📊 sample_truck_segmentation.json         # Example JSON output (demo)
├── 📸 sample_truck_segmentation_20251201.png # Latest segmentation example
├── 📊 sample_truck_segmentation_20251201.json # Latest JSON output
│
├── 📂 data/                                  # All data files
│   └── 📂 raw_images/                        # Freeway camera images by location
│       ├── 📁 i1012westofhaven/              # I-10 @ 2 West of Haven
│       ├── 📁 i101810mileswestofcherry/      # I-10 @ 18/10 Miles West of Cherry
│       ├── 📁 i10200i210/                    # I-10 @ 200/I-210 Interchange
│       ├── 📁 i1026westofrancho/             # I-10 @ 26 West of Rancho
│       ├── 📁 i1033eastofwaterman/           # I-10 @ 33 East of Waterman
│       ├── 📁 i1587foothillblvd/             # I-15 @ 87 Foothill Blvd
│       ├── 📁 i215207vinestreet/             # I-215 @ 207 Vine Street
│       ├── 📁 sr60153eastofeuclidavemuebonviewavenue/  # SR-60 @ 153 East of Euclid
│       ├── 📁 sr60359westofvalleyway/        # SR-60 @ 359 West of Valley Way
│       └── 📁 sr60362marketstreet/           # SR-60 @ 362 Market Street
│
├── 📂 OpenSeeD/                              # Open-vocabulary segmentation model
│   ├── 📂 configs/                           # Model configurations
│   ├── 📂 datasets/                          # Dataset definitions
│   ├── 📂 demo/                              # Demo scripts and examples
│   ├── 📂 extracted_data_full/               # 🔍 PROCESSED OUTPUT - Segmentation results
│   ├── 📂 figs/                              # Visualization outputs
│   └── [Additional OpenSeeD model files]
│
├── 📂 src/                                   # Source code (processing & analysis)
│   └── [Analysis scripts and utilities]
│
└── 📂 venv/                                  # Python virtual environment (created after setup)

Camera Location Guide

Monitored Corridors:

Corridor Camera Locations Subdirectory Name
I-10 2 West of Haven i1012westofhaven
18/10 Miles West of Cherry i101810mileswestofcherry
200/I-210 Interchange i10200i210
26 West of Rancho i1026westofrancho
33 East of Waterman i1033eastofwaterman
I-15 87 Foothill Blvd i1587foothillblvd
I-215 207 Vine Street i215207vinestreet
SR-60 153 East of Euclid Ave sr60153eastofeuclidavemuebonviewavenue
359 West of Valley Way sr60359westofvalleyway
362 Market Street sr60362marketstreet

Total Images Processed: ~19,543 (as of proposal date)


Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • Windows, macOS, or Linux
  • ~5GB free disk space (for virtual environment and dependencies)
  • Internet connection (for initial setup)

Step-by-Step Installation

1. Navigate to Repository

cd C:\Users\Helen\Downloads\LTC_project\IE_TrafficSeg

2. Create Virtual Environment

Windows (PowerShell/CMD):

python -m venv venv
.\venv\Scripts\activate

Unix/macOS:

python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Verify Installation

python -c "import cv2; import torch; import pandas as pd; print('All packages installed successfully!')"

Troubleshooting

  • Python not found: Install Python from python.org
  • Permission errors: Run terminal as administrator (Windows) or use sudo (Unix/macOS)
  • Package conflicts: Try upgrading pip: pip install --upgrade pip

Data Pipeline

Overview

Freeway Cameras → Image Collection → Vehicle Segmentation → Metric Extraction → 
Spatial Analysis → Correlation Analysis → Forecasting → Policy Insights

Step 1: Image Collection

Source: Caltrans District 8 freeway camerasStorage: data/raw_images/[location]/Format: JPEG imagesSampling: Regular intervals capturing:

  • Diverse traffic conditions
  • Various lighting scenarios
  • Different congestion states

Step 2: Vehicle Segmentation

Model: OpenSeeD (Open-vocabulary Panoptic Segmentation)Configuration: OpenSeeD/configs/Process:

  1. Load image from camera location folder
  2. Apply OpenSeeD segmentation model
  3. Identify vehicle instances (cars, trucks, buses)
  4. Extract roadway elements (lanes, barriers)
  5. Generate segmentation masks and bounding boxes

Output Location: OpenSeeD/extracted_data_full/Output Format: JSON files with:

  • Vehicle classifications (passenger car, light truck, heavy truck)
  • Bounding box coordinates
  • Lane positions
  • Confidence scores
  • Timestamps

Example Output: See sample_truck_segmentation_20251201.json

Step 3: Metric Extraction

Computed Metrics:

  • Hourly truck counts by corridor
  • Car-to-truck ratios
  • Peak-hour exposure profiles
  • Temporal patterns (hourly/daily/weekly)
  • Lane-specific vehicle distributions

Step 4: Data Integration

External Datasets Integrated:

Category Source Data Type
Demographics US Census ACS Income, race/ethnicity, linguistic isolation
Environment CalEnviroScreen 4.0 Diesel PM, PM2.5, ozone, traffic density
EPA EJScreen Environmental justice indicators
CARB/SCAQMD Air quality monitoring
Health CA Healthy Places Index Asthma ER visits, cardiovascular disease
Land Use SCAG Warehouse locations, truck routes
LODES Employment patterns
Safety SWITRS/TIMS Truck-involved crash records

Integration Method: Spatial joins at census tract/block group levels

Step 5: Analysis

Phase 1 - Correlation Analysis:

  • Spatial regression analysis
  • Stratified temporal methods
  • Testing freight exposure vs.:
    • Pollution burden in disadvantaged communities
    • Health outcomes (asthma, cardiovascular)
    • Crash frequencies
    • Warehouse density

Phase 2 - Forecasting:

  • Time-series models: ARIMA, Prophet
  • Machine learning: Gradient Boosting, LSTM
  • Prediction horizon: 1-7 days
  • Proactive exposure alerts
  • Policy scenario modeling

Key Results

Preliminary Findings (as documented in proposal)

Temporal Patterns

Figure 2 Analysis (Proposal Section 4):

  • Truck traffic: Peaks morning-to-early-afternoon
  • Passenger vehicles: Peak later in day
  • Key insight: Clear temporal separation demonstrates need for freight-specific analysis rather than aggregate traffic counts

Corridor Comparison

Figure 3 Analysis (Proposal Section 4):

  • Significant variation in truck intensity across camera locations
  • Some corridors show elevated truck presence despite similar total vehicle counts
  • Traditional loop detectors would miss these distinctions

Truck Traffic Heatmap

Figure 4 Analysis (Proposal Section 4):

Corridor Pattern Peak Characteristics
I-10 Extended high intensity Sustained daytime freight activity
SR-60 Extended high intensity Sustained daytime freight activity
I-15 Concentrated peaks Shorter, focused peak periods
SR-91 Concentrated peaks Shorter, focused peak periods
I-215 Concentrated peaks Shorter, focused peak periods

Key Insight: These hour-by-hour, corridor-by-corridor patterns are not observable using aggregate loop-detector data.

Validation

  • Vehicle-level segmentation compared against ground-truth annotations
  • Cross-referenced with Caltrans PeMS vehicle classification (where available)
  • Camera-level spatial resolution enables unprecedented freight analysis detail

Research Context

The Inland Empire Freight Challenge

Strategic Importance:

  • Primary inland distribution hub for goods from Ports of LA/Long Beach
  • Major corridors: I-10, I-15, SR-60, SR-91, I-215

Scale (2021 Data):

  • Medium-weight truck trips: ~11.15 million
  • Heavy-weight truck trips: ~5.73 million
  • Population: 2.63+ million residents (2024)
  • Warehouse facilities: 700+ large-scale distribution centers
  • 2023 expansion: 28+ million sq ft of new warehouse space

Freight Activity Patterns:

  • Peaks mid-week
  • Aligned with port throughput
  • Tied to warehouse operations
  • Intensifies September-December (holiday season)

Environmental Justice Concerns

Exposure Burdens (CalEnviroScreen 4.0 / EPA EJScreen):

  • Elevated diesel particulate matter
  • High PM2.5 and ozone levels
  • Increased asthma ER visit rates
  • Elevated cardiovascular vulnerability

Demographic Correlations:

  • Lower median household income
  • Higher renter occupancy
  • Greater linguistic isolation
  • Proximity to freight corridors

Safety Impact:

  • 12,000+ annual truck-involved injury crashes in California (2022-2024)
  • Several hundred fatalities annually
  • Risk increases during peak freight seasons

Data Gap

Existing research relies on:

  • Aggregate traffic counts
  • Surveys
  • Policy indicators

Missing: Direct, vehicle-specific measurement at appropriate spatial/temporal scales.

FreTIS fills this gap with camera-level, hourly freight exposure metrics.


Technical Documentation

Model: OpenSeeD

Full Name: Open-vocabulary Panoptic SegmentationType: Deep learning computer vision modelCapabilities:

  • Instance segmentation (individual vehicle detection)
  • Semantic segmentation (roadway elements)
  • Open-vocabulary recognition (text-driven, flexible labels)
  • Single-pass inference (efficient)

Advantages over Fixed-Label Models:

  • No predefined vehicle categories required
  • Flexible classification ("heavy-duty truck" vs. "passenger car")
  • Better generalization to diverse traffic scenes
  • Lane-level context understanding

Output Format

JSON Structure (see sample_truck_segmentation_20251201.json):

{
  "image_id": "camera_location_timestamp",
  "vehicles": [
    {
      "type": "heavy_duty_truck",
      "bbox": [x, y, width, height],
      "confidence": 0.95,
      "lane": 2,
      "timestamp": "2025-12-01T10:30:00"
    },
    ...
  ],
  "summary": {
    "total_vehicles": 45,
    "trucks": 12,
    "cars": 33,
    "truck_percentage": 26.7
  }
}

Validation Methods

  1. Ground Truth Comparison: Manual annotation of sample images
  2. PeMS Cross-Reference: Where spatially/temporally aligned data exists
  3. Inter-Corridor Consistency: Logical pattern verification
  4. Temporal Plausibility: Expected daily/weekly patterns

Forecasting Methods (Phase 2)

Method Type Characteristics
ARIMA Statistical Time-series, trend/seasonality
Prophet Statistical Robust to outliers, holidays
Gradient Boosting ML Ensemble Complex non-linear relationships
LSTM Deep Learning Sequential dependencies, long-term patterns

Evaluation Metrics:

  • Mean Absolute Error (MAE)
  • Root Mean Square Error (RMSE)
  • Mean Absolute Percentage Error (MAPE)

Project Timeline

Weeks Phase Tasks
1-3 Setup & Refinement Finalize datasets, refine segmentation pipeline
4-6 Data Integration Extract freight metrics, integrate demographic/environmental/safety datasets
7-9 Analysis & Dashboard Conduct correlation analyses, develop web-based analytics dashboard
10-12 Publication & Delivery Finalize analytics product, prepare journal/conference submission

Current Status: Data collection and preliminary analysis complete (~19,543 images processed)


Contact & Acknowledgments

Research Team

Principal Investigator: Dr. Bilal Khan California State University-San Bernardino bilal.khan@csusb.edu (909) 537-5428

Student Researcher: Ha Trinh California State University-San Bernardino helentrinh9784@gmail.com

Funding & Support

Leonard Transportation Center (LTC) California State University-San Bernardino

This research advances LTC goals in:

  • Freight systems analysis
  • Transportation equity
  • Applied analytics for environmental justice
  • Student research mentorship
  • Data-driven policy support

References

Key references are documented in the full proposal (LTC Proposal Freight Services_BK.docx.md), including:

  1. Khatri, B. (2024). "Truck Traffic Analysis in the Inland Empire." Master's project, CSUSB.
  2. California crash statistics (CHP, 2022-2024)
  3. CalEnviroScreen 4.0 (OEHHA, 2023)
  4. Inland Empire development and population reports (2022-2024)

Citation

If you use this code, data, or methods in your research, please cite:

@techreport{Khan2025FreTIS,
  author = {Khan, Bilal and Trinh, Ha},
  title = {Freight Traffic Intelligence System (FreTIS): Computer Vision and Machine Learning for Inland Empire Freight Traffic Analysis},
  institution = {Leonard Transportation Center, California State University-San Bernardino},
  year = {2025},
  type = {Research Project}
}

License

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

Summary:

  • ✅ Free to use, modify, and distribute
  • ✅ Suitable for academic and commercial use
  • ✅ Attribution required (cite our work)
  • ⚠️ Provided "as-is" without warranty

Note: This license applies to the code. Data usage may be subject to additional terms from data providers (e.g., Caltrans). Please consult with the research team before using this project.


Acknowledgments

  • Caltrans District 8: Freeway camera imagery access
  • Leonard Transportation Center: Research funding and support
  • California State University-San Bernardino: Institutional support
  • Community Partners: Input on environmental justice concerns

Last Updated: January 2025 Repository Maintainer: Ha Trinh Documentation Version: 2.0


For questions about navigation or usage, please contact the research team.

About

FreTIS: Computer vision system analyzing freight traffic exposure and environmental justice in California's Inland Empire

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages