Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host nodes: DepthMerger. #163

Merged
merged 5 commits into from
Jan 31, 2025
Merged

Host nodes: DepthMerger. #163

merged 5 commits into from
Jan 31, 2025

Conversation

kkeroo
Copy link
Collaborator

@kkeroo kkeroo commented Jan 24, 2025

This PR adds first host node called DepthMerger. The node merges normal ImgDetections or ImgDetectionsExtended with depth information into SpatialImgDetections. The node is taken from experiments host-nodes folder and slightly adjusted so it works with ImgDetectionsExtended. We also introduce parameter shrinking_factor that is responsible for optionally shrinking the ROI for calculating depth values. This is useful because sometimes bounding-box also includes background and so the mean depth value is affected. E.g. In bouding-box of a human the shrinking factor will shrink the ROI into the human torso.

I am not sure about the folder hierarchy. I was thinking of placing it in the helpers folder under specific subfolders. Maybe there is something better?

The proposed node works with rewritten experiments: Human-Machine safety and social distancing.

@codecov-commenter
Copy link

codecov-commenter commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 99.10714% with 1 line in your changes missing coverage. Please review.

Project coverage is 37.78%. Comparing base (d9770af) to head (adc4f65).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
depthai_nodes/nodes/depth_merger.py 98.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #163      +/-   ##
==========================================
+ Coverage   36.05%   37.78%   +1.72%     
==========================================
  Files          72       75       +3     
  Lines        4024     4137     +113     
==========================================
+ Hits         1451     1563     +112     
- Misses       2573     2574       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@dominik737 dominik737 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I would have a nodes folder along (same level as) the ml folder. Since many of the nodes are actually not related to ml. Then if there are too many nodes, we can group then in the nodes folder into subfolders.

depthai_nodes/ml/helpers/depth/__init__.py Outdated Show resolved Hide resolved
@dominik737
Copy link
Contributor

@klemen1999 Also I just remembered we were talking about tests. Should they be implemented now in those PRs that add nodes?

Copy link
Collaborator

@klemen1999 klemen1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM

Agree on moving nodes into separate folder (same level as ml) and not nesting them into subfolders at least for now, we can do that later on if needed.

@klemen1999 Also I just remembered we were talking about tests. Should they be implemented now in those PRs that add nodes?

Good catch, we should make tests for every new node as potentially many different experiments will rely on their specifics. We can sync offline what/how to test.

depthai_nodes/ml/helpers/depth/depth_merger.py Outdated Show resolved Hide resolved
depthai_nodes/ml/helpers/depth/host_spatials_calc.py Outdated Show resolved Hide resolved
depthai_nodes/ml/helpers/depth/host_spatials_calc.py Outdated Show resolved Hide resolved
@kkeroo
Copy link
Collaborator Author

kkeroo commented Jan 27, 2025

Okay, I moved the added DepthMerger node to the depthai_nodes/nodes folder and exposed it in the __init__.py. We can import it as from depthai_nodes.nodes import DepthMerger.

Copy link
Collaborator

@jkbmrz jkbmrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just adding a small stylistic suggestion.

Also, I agree on having the nodes folder at the same level as ml. I'm wondering, though, if we should also move there the contents of thedepthai_nodes/ml/helpers folder?

depthai_nodes/nodes/depth_merger.py Show resolved Hide resolved
@kkeroo
Copy link
Collaborator Author

kkeroo commented Jan 31, 2025

I added the tests for DepthMerger and HostSpatialsCalc in adc4f65.

Copy link
Collaborator

@klemen1999 klemen1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kkeroo kkeroo merged commit 9edfea8 into main Jan 31, 2025
11 checks passed
@kkeroo kkeroo deleted the nodes/depth-merger branch January 31, 2025 11:04
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.

5 participants