Skip to content

Feat/Backend: Add Depth Estimation for Object Proximity Warnings-147#239

Open
tamannaa-rath wants to merge 2 commits into
sahoo-tech:mainfrom
tamannaa-rath:feature/depth-estimation
Open

Feat/Backend: Add Depth Estimation for Object Proximity Warnings-147#239
tamannaa-rath wants to merge 2 commits into
sahoo-tech:mainfrom
tamannaa-rath:feature/depth-estimation

Conversation

@tamannaa-rath
Copy link
Copy Markdown

🔗 Related Issue

Closes #147


📝 Summary of Changes

This PR adds a new DepthEstimator module to handle smart distance checking for industrial hazards.

  • What it does: It takes a video frame and a bounding box from an object detector, passes it through a lightweight deep learning model (MiDaS_small), and calculates the average relative distance of that specific object.
  • Why it matters: It prevents injuries by triggering a system alert if a dangerous object (like a knife or flame) gets too close to the camera.
  • Decoupled Architecture: Because the main video pipeline code is still being written by another contributor (who has raised a PR), this module is built independently. It uses a strict input-output agreement so it will seamlessly connect to their work as soon as their PR merges.

🔍 Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📖 Documentation update
  • 🧪 Test addition or improvement
  • 🧹 Refactor / Code cleanup (no functional change)
  • ⚙️ Build / CI / Chore

🧪 How Was This Tested?

I ran the automated unit testing suite locally to check the initialization logic, min-max image math normalization, matrix array slicing coordinates, and the proximity alert limits.

python -m unittest core/physical/test_depth_estimator.py

Test environment:

  • OS: Windows 11 (Ryzen 7, Integrated AMD Graphics)
  • Python version: 3.12+
  • Node version (if frontend): N/A

image

✅ Pre-Submission Checklist

  • My branch is up to date with upstream/main
  • My code follows the project's coding standards (Black, isort, flake8 pass)
  • I have written / updated tests for my changes
  • All existing tests pass (python -m pytest tests/)
  • I have added docstrings and type hints to all new public functions
  • I have updated relevant documentation (README, docs/, inline comments)
  • My PR title follows the Conventional Commits format
  • I have not committed any .env files, secrets, or model weights
  • This PR addresses only the scope of the linked issue

💬 Additional Notes for Reviewer

  • Hardware-Adaptive Logic: The code automatically detects the user's computer specs. It safely falls back to CPU processing if an NVIDIA GPU isn't available, meaning it can be run locally without system crashes.

  • No-Download Testing: The test suite uses unittest.mock to completely bypass downloading the heavy 300MB model files from the internet during test execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Depth Estimation for Object Proximity Warnings

1 participant