CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Verify depth metrics roi size #14133
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds validation to prevent accessing pixels outside the current frame resolution when calculating depth metrics. The change ensures that if the resolution has changed since the ROI (Region of Interest) was calculated, the function returns early to avoid illegal memory access.
- Adds bounds checking to compare frame dimensions against ROI boundaries
- Removes unnecessary mutex and lock guard that were protecting vector operations
tools/depth-quality/depth-metrics.h
Outdated
snapshot_metrics result{ w, h, roi, {} }; | ||
|
||
std::mutex m; | ||
if( w < roi.max_x || h < roi.max_y ) // Resolution have changed since calculating roi, avoid accessing illegal pixels. |
Copilot
AI
Jul 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bounds check logic is incorrect. It should use <=
instead of <
because pixel coordinates are typically 0-indexed, so valid x coordinates range from 0 to w-1, and valid y coordinates from 0 to h-1. The condition should be if( w <= roi.max_x || h <= roi.max_y )
.
if( w < roi.max_x || h < roi.max_y ) // Resolution have changed since calculating roi, avoid accessing illegal pixels. | |
if( w <= roi.max_x || h <= roi.max_y ) // Resolution has changed since calculating roi, avoid accessing illegal pixels. |
Copilot uses AI. Check for mistakes.
tools/depth-quality/depth-metrics.h
Outdated
snapshot_metrics result{ w, h, roi, {} }; | ||
|
||
std::mutex m; | ||
if( w < roi.max_x || h < roi.max_y ) // Resolution have changed since calculating roi, avoid accessing illegal pixels. |
Copilot
AI
Jul 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammatical error in comment: 'Resolution have changed' should be 'Resolution has changed'.
if( w < roi.max_x || h < roi.max_y ) // Resolution have changed since calculating roi, avoid accessing illegal pixels. | |
if( w < roi.max_x || h < roi.max_y ) // Resolution has changed since calculating roi, avoid accessing illegal pixels. |
Copilot uses AI. Check for mistakes.
Tracked on [LRS-1290]