Skip to content

Synthetic underwater video generation and optical flow-based speed estimation pipeline for marine robotics and computer vision applications.

Notifications You must be signed in to change notification settings

srinathvv-dev/Underwater-Object-Speed-Estimation

Repository files navigation

Underwater Object Speed Estimation

This repository provides a complete pipeline to generate synthetic underwater video and estimate object speed using optical flow techniques. It is designed for researchers and engineers working in underwater computer vision, robotics, or video analytics.


Table of Contents


Overview

Underwater visual data is difficult to process due to challenges like poor lighting, turbidity, and distortion. This project helps:

  • Generate synthetic underwater videos with moving objects.
  • Track object movement using Lucas-Kanade optical flow.
  • Estimate object speed in both pixels/frame and meters/second.
  • Visualize speed statistics and motion path.

Features

✅ Synthetic underwater video with smooth object motion
✅ Optical flow-based tracking (Lucas-Kanade method)
✅ CLAHE enhancement for underwater contrast
✅ Motion outlier filtering using MAD
✅ Gaussian smoothing for clean speed curves
✅ Real-time visualization and dual speed plots
✅ Speed output in px/frame and m/s


Scripts

1. Synthetic Underwater Video Generator

Generates a 10-second underwater-style video with a white object moving across a blue background.

  • Script: synthetic_video_generator.py
  • Output: synthetic_underwater_multi.mp4
  • Purpose: Controlled video for speed estimation testing

2. Speed Estimation Using Optical Flow

Processes any underwater video to estimate object speed.

  • Script: speed_estimation.py
  • Input: Underwater video file (real or synthetic)
  • Output:
    • Real-time tracking visualization (optional)
    • Plots of speed (px/frame and m/s)
    • Console report with statistics

Installation

Install Python 3.x and the following packages:

pip install opencv-python numpy matplotlib scipy

Usage

Generate Synthetic Video

python synthetic_video_generator.py

Creates synthetic_underwater_multi.mp4 in your directory.


Estimate Speed

Update the path in speed_estimation.py:

VIDEO_PATH = "synthetic_underwater_multi.mp4"

Then run:

python speed_estimation.py
  • Press q to quit tracking early.
  • After processing, two side-by-side plots and a full speed report are shown.

Parameters & Customization

In speed_estimation.py

Parameter Description
VIDEO_PATH Input video path
SHOW_TRACKING Show live tracking overlay
SMOOTHING_SIGMA Gaussian smoothing strength
PIXELS_PER_METER Conversion ratio (100 px = 1 m default)
FPS Video frame rate
SCALING_FACTOR Manual multiplier for speed
feature_params Shi-Tomasi corner detection settings
lk_params Lucas-Kanade flow tuning
frame_count % 15 Refresh points every 15 frames

Results & Visualization

🔴 Tracking Overlay: Red dots show features, green lines show motion vectors.

📈 Plots (side-by-side):

  1. Speed in px/frame:

    • Light blue: Raw speeds
    • Blue: Smoothed curve
    • Red dashed line: Mean with shaded ±1 std dev
  2. Speed in m/s:

    • Green: Converted speed
    • Red dashed line: Median with ±1 std dev shaded

📊 Console Output:

=== FINAL REPORT ===
Mean speed: 0.50 px/frame
Median speed: 0.44 px/frame
Std deviation: ±0.24 px/frame

=== REAL-WORLD ESTIMATE ===
Mean speed: 0.15 m/s
Median speed: 0.13 m/s
Variation (std): ±0.07 m/s

Methodology

  1. CLAHE Preprocessing: Improves contrast in murky underwater frames.

  2. Feature Detection (Shi-Tomasi): Identifies good points to track.

  3. Optical Flow Tracking (Lucas-Kanade): Tracks feature movement between frames.

  4. Camera Motion Compensation: Estimates background shift using affine transformation.

  5. Speed Calculation: Measures point displacements minus camera motion → filters outliers using MAD → applies Gaussian smoothing.

  6. Conversion to Real Units: Speed (px/frame) → meters/second using FPS and pixels-per-meter ratio.


Potential Applications

  • Benchmarking underwater tracking algorithms
  • Marine life motion analysis
  • AUV/ROV path tracking
  • Underwater robotics simulation
  • Educational demos in vision and robotics

License

© 2025 [Srinath V V] All rights reserved. Private and proprietary — reproduction or distribution without permission is strictly prohibited.


Contact

📫 Feel free to raise issues or connect via GitHub: github.com/srinathvv-dev


🎥 Happy Tracking & Speed Estimation! 🌊🐠

About

Synthetic underwater video generation and optical flow-based speed estimation pipeline for marine robotics and computer vision applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages