Anirudh1950's picture
Publish project page
57687b8 verified
Raw History Blame Contribute Delete
11.2 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stereo Vision Multi Agent Pathfinding</title>
<style>
:root { --bg:#f7f7f5; --fg:#1b1b1b; --muted:#666; --card:#fff; --line:#e3e3df; --accent:#2f6fde; --code:#f0f0ec; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg:#141414; --fg:#eee; --muted:#9a9a9a; --card:#1e1e1e; --line:#333; --accent:#6c9cff; --code:#262626; } }
:root[data-theme="dark"] { --bg:#141414; --fg:#eee; --muted:#9a9a9a; --card:#1e1e1e; --line:#333; --accent:#6c9cff; --code:#262626; }
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:15px/1.6 system-ui, -apple-system, Segoe UI, sans-serif; }
main { max-width:960px; margin:0 auto; padding:24px 16px 48px; }
header h1 { margin:0 0 4px; font-size:1.7rem; }
header p { margin:0 0 14px; color:var(--muted); }
.links { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:18px; }
.links a { background:var(--accent); color:#fff; text-decoration:none; padding:7px 13px; border-radius:8px; }
.links a.ghost { background:transparent; color:var(--fg); border:1px solid var(--line); }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:18px; margin-bottom:16px; overflow-wrap:anywhere; }
.gallery { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:10px; }
.gallery figure { margin:0; }
.gallery img { width:100%; border-radius:8px; border:1px solid var(--line); background:#0001; }
.gallery figcaption { font-size:.8rem; color:var(--muted); }
#readme img { max-width:100%; }
#readme pre { background:var(--code); padding:12px; border-radius:8px; overflow-x:auto; }
#readme code { background:var(--code); padding:1px 4px; border-radius:4px; }
#readme pre code { padding:0; }
#readme table { border-collapse:collapse; display:block; overflow-x:auto; }
#readme th, #readme td { border:1px solid var(--line); padding:4px 8px; }
a { color:var(--accent); }
</style>
</head>
<body>
<main>
<header>
<h1>Stereo Vision Multi Agent Pathfinding</h1>
<p>Stereo depth (SGBM) and multi-agent 3D pathfinding</p>
</header>
<div class="links">
<a href="https://huggingface.co/Anirudh1950/Stereo-Vision-Multi-Agent-Pathfinding">Code &amp; files on Hugging Face</a>
<a class="ghost" href="https://github.com/rudzz1950/Stereo-Vision-Multi-Agent-Pathfinding">GitHub</a>
</div>
<div class="card" id="gallery-card" hidden><div class="gallery" id="gallery"></div></div>
<div class="card" id="readme"></div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.2/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.1.6/purify.min.js"></script>
<script>
const README = "# Computer Vision & Pathfinding Research\n\nThis repository contains my solutions for the **Vecros Technical Assignment**. It implements research-grade algorithms for Stereo Vision (Problem 1) and Multi-Agent Pathfinding (Problem 2).\n\nThe focus has been on **mathematical robustness** and **optimality** rather than just getting code to run.\n\n---\n\n## \ud83d\udee0\ufe0f Table of Contents\n- [Problem 1: Stereo Vision (SfM Backend)](#problem-1-stereo-vision-structure-from-motion)\n- [Problem 2: 3D Multi-Agent Pathfinding](#problem-2-3d-multi-agent-pathfinding)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Results](#results)\n\n---\n \n## \u26a1 Quick Reference (Run Commands)\n \nCopy-paste these commands to verify the solution:\n\n### 1. Problem 1: Stereo Vision (All Modes)\nRuns SGBM Dense Depth + MAGSAC++ Pose + Sparse Bundle Adjustment.\n **Option A: Middlebury Dataset (Default)**\n ```bash\n python main.py --problem 1 --dataset middlebury --data-path \"./Dataset/Adirondack-perfect/Adirondack-perfect\"\n ```\n \n **Option B: Custom Image Pair**\n Run on any two images (calibration optional, defaults to approx).\n ```bash\n python main.py --problem 1 --dataset custom --img1 \"data/left.jpg\" --img2 \"data/right.jpg\"\n ```\n \n **Option C: KITTI Odometry Dataset**\n Requires `pykitti` and a downloaded sequence (e.g., Sequence 00).\n ```bash\n python main.py --problem 1 --dataset kitti --data-path \"path/to/kitti/dataset\" --sequence 00\n ```\n \n### 2. Problem 2: Pathfinding (All Solver Modes)\n \n **Option A: Compare Mode (Recommended)**\n Runs both Fast + Optimal solvers and benchmarks them.\n ```bash\n python main.py --problem 2 --solver compare --grid-size 50\n ```\n \n **Option B: CBS Only (Optimal)**\n Runs only the Conflict-Based Search (guaranteed shortest path).\n ```bash\n python main.py --problem 2 --solver cbs --grid-size 50\n ```\n \n **Option C: Optimized Only (Fast)**\n Runs only the fast heuristics-based solver (no optimality guarantee).\n ```bash\n python main.py --problem 2 --solver optimized --grid-size 50\n ```\n \n ### 3. Problem 2: Pathfinding (Custom Scenario)\n Runs a 4-agent conflict scenario (or any number).\n ```bash\n python main.py --problem 2 --paths \"0,0,0:10,10,10\" \"10,0,0:0,10,0\" \"5,5,0:5,5,10\" \"0,5,5:10,5,5\"\n ```\n \n---\n \n## Problem 1: Stereo Vision (Structure-from-Motion)\n\nThis is a complete Visual Odometry backend. Instead of simple disparity mapping, I built a pipeline that performs **Sparse Bundle Adjustment** to recover optimal camera poses.\n\n### Key Algorithms\n1. **Feature Detection**: SIFT with **Sub-Pixel Refinement** (`cv2.cornerSubPix`) for high-precision keypoints.\n2. **Matching**: FLANN-based matching with Lowe's Ratio Test (0.75).\n3. **Pose Estimation**: **MAGSAC++** (`cv2.USAC_MAGSAC`), which is significantly more robust to outliers than standard RANSAC.\n4. **Optimization (The \"Special Sauce\")**:\n * **True Bundle Adjustment**: A custom `scipy` solver that optimizes **Pose ($R,t$) + 3D Points ($X$)** simultaneously.\n * **Sparse Jacobian**: Implemented the analytical sparsity pattern to solve for thousands of parameters in milliseconds.\n * **Trajectory Smoothing**: Exponential Moving Average (EMA) to clean up jitter in video sequences.\n5. **Moving Object Rejection**: Uses Epipolar Residuals to filter out dynamic actors (humans, cars) that violate the static geometry constraint.\n\n---\n\n## Problem 2: 3D Multi-Agent Pathfinding\n\nA swarm navigation system capable of planning collision-free paths for multiple agents in a dense 3D grid.\n\n### Key Algorithms\n1. **Conflict-Based Search (CBS)**:\n * This is an **Optimal Solver**. It guarantees the mathematically shortest path for the swarm (minimizing Flowtime or Makespan).\n * Unlike simple Prioritized Planning (which fails in tight spaces), CBS resolves conflicts by exploring a constraint tree.\n2. **Constraint Checking**:\n * **Vertex Conflicts**: Prevents two agents from occupying the same $(x,y,z)$ at time $t$.\n * **Edge Conflicts**: Prevents agents from \"swapping\" places ($u \\to v$ vs $v \\to u$) to ensure physical feasibility.\n3. **Visualization**:\n * Generates an interactive 3D HTML animation using Plotly.\n\n---\n\n## \ud83d\udd27 Installation\n\n### 1. Clone & Install Dependencies\n```bash\npip install -r requirements.txt\n```\n*(Requires: `numpy`, `opencv-python`, `scipy`, `matplotlib`, `plotly`)*\n\n### 2. Dataset Setup\nI tested this on the **Middlebury 2014 Stereo Dataset**.\n- Ensure your data is in `Dataset/Adirondack-perfect/Adirondack-perfect/`.\n- Required files: `im0.png`, `im1.png`, `calib.txt`.\n\n---\n\n## \ud83d\ude80 Usage\n\n### Run Problem 1 (Stereo Vision)\n```bash\n# Run on the included Middlebury dataset\npython main.py --problem 1 --dataset middlebury --data-path \"./Dataset/Adirondack-perfect/Adirondack-perfect\"\n```\n*Check the console for Bundle Adjustment convergence stats!*\n\n### Run Problem 2 (Pathfinding)\n```bash\n# Run the \"Comparison Mode\" (Fast Heuristic vs Optimal CBS)\npython main.py --problem 2 --solver compare --grid-size 50\n\n# Run a Custom Scenario (3 Agents)\n# Format: \"startX,startY,startZ:endX,endY,endZ\"\npython main.py --problem 2 --paths \"0,0,0:10,10,10\" \"10,0,0:0,10,0\" \"5,5,0:5,5,10\"\n```\n\n---\n\n## \ud83d\udcca Results\n\nAll outputs are saved to the `results/` directory.\n\n### Problem 1 Output (`results/problem1/`)\n \n **1. Dense Disparity Map (SGBM)**\n ![Dense Disparity](results/problem1/disparity_dense.png)\n \n **2. Robust Feature Matching (Left/Right)**\n ![Feature Matches](results/problem1/matches.png)\n \n **3. SfM Error Metrics (Bundle Adjustment Improvement)**\n ![Error Metrics](results/problem1/error_metrics.png)\n \n ### Problem 2 Output (`results/problem2/`)\n \n **1. 3D Agent Paths (Comparison)**\n | Fast Solver (Baseline) | CBS Solver (Optimal) |\n | :---: | :---: |\n | ![Fast 3D](results/problem2/fast/paths_3d_static.png) | ![CBS 3D](results/problem2/cbs/paths_3d_static.png) |\n \n **2. Position vs Time (Conflict Analysis)**\n | Fast Solver | CBS Solver |\n | :---: | :---: |\n | ![Fast Time](results/problem2/fast/paths_time_position.png) | ![CBS Time](results/problem2/cbs/paths_time_position.png) |\n \n **3. Interactive Animation**\n - `trajectory_vis.html`: **Open this in your browser!** It's an interactive 3D player where you can scrub through time to see the agents move.\n - `metrics.txt`: Comparison of execution time and path cost between the Fast and CBS solvers.\n\n---\n\n### Future Improvements\nIf I had more time, I would:\n1. **Deep Learning**: Replace SIFT with **SuperPoint+SuperGlue** for better matching in textureless areas.\n2. **Loop Closure**: Implement a Bag-of-Words (DBoW2) system to recognize previously visited locations and correct long-term drift in SLAM.\n\n---\n**Author**: Anirudh\n\n";
const IMAGES = ["results/problem1/disparity_dense.png", "results/problem1/epipolar_lines.png", "results/problem1/error_metrics.png", "results/problem1/keypoints.png", "results/problem1/matches.png", "results/problem2/cbs/paths_3d_static.png", "results/problem2/cbs/paths_time_position.png", "results/problem2/fast/paths_3d_static.png", "results/problem2/fast/paths_time_position.png"];
const BASE = 'https://huggingface.co/Anirudh1950/Stereo-Vision-Multi-Agent-Pathfinding/resolve/main/';
const el = document.getElementById('readme');
el.innerHTML = DOMPurify.sanitize(marked.parse(README));
// Relative image links in the README point at files in the model repo.
el.querySelectorAll('img').forEach(img => {
const src = img.getAttribute('src') || '';
if (!/^(https?:|data:)/.test(src)) img.src = BASE + src.replace(/^\.?\//, '').split('/').map(encodeURIComponent).join('/');
});
if (IMAGES.length) {
document.getElementById('gallery-card').hidden = false;
document.getElementById('gallery').innerHTML = IMAGES.map(p => {
const url = BASE + p.split('/').map(encodeURIComponent).join('/');
const cap = p.split('/').pop().replace(/\.[^.]+$/, '').replace(/[_-]+/g, ' ');
return `<figure><a href="${url}" target="_blank" rel="noopener"><img loading="lazy" src="${url}" alt=""></a><figcaption>${cap}</figcaption></figure>`;
}).join('');
}
</script>
</body>
</html>