Skip to content

[RSDK-13824] Fix depth image scale by applying Orbbec SDK valueScale#72

Merged
SebastianMunozP merged 2 commits intoviam-modules:mainfrom
SebastianMunozP:fix-depth-scale
Apr 27, 2026
Merged

[RSDK-13824] Fix depth image scale by applying Orbbec SDK valueScale#72
SebastianMunozP merged 2 commits intoviam-modules:mainfrom
SebastianMunozP:fix-depth-scale

Conversation

@SebastianMunozP
Copy link
Copy Markdown
Contributor

@SebastianMunozP SebastianMunozP commented Apr 24, 2026

The previous implementation divided raw depth values by 1000 before storing them as uint16_t mm values, compressing all distances into the 0-1 mm range. Additionally, getValueScale() was never applied, meaning cameras with a non-1.0 scale factor would produce wrong values.

Now encode_to_depth_raw accepts a valueScale parameter and computes actual_mm = raw_pixel * valueScale before encoding.

This fix is based on the example from Orbbec: https://github.com/orbbec/OrbbecSDK_v2/tree/main/examples/1.stream.depth

Test (using a simple python script to print the images we receive from the camera)

Before:

color_and_depth_bug

After:

color_and_depth_fixed

The previous implementation divided raw depth values by 1000 before
storing them as uint16_t mm values, compressing all distances into the
0-1 mm range. Additionally, getValueScale() was never applied, meaning
cameras with a non-1.0 scale factor would produce wrong values.

Now encode_to_depth_raw accepts a valueScale parameter and computes
actual_mm = raw_pixel * valueScale before encoding.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SebastianMunozP SebastianMunozP changed the title Fix depth image scale by applying Orbbec SDK valueScale [RSDK-13824] Fix depth image scale by applying Orbbec SDK valueScale Apr 24, 2026
Copy link
Copy Markdown
Collaborator

@oliviamiller oliviamiller left a comment

Choose a reason for hiding this comment

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

nice lgtm

Copy link
Copy Markdown
Contributor

@seanavery seanavery left a comment

Choose a reason for hiding this comment

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

Nice improvement!

[question] Was the old depth image return effectively unusable with the old 0-1mm normalization?

[question] Do we currently have any users of the depth image that will be affected by this change?

Comment thread src/module/encoding.cpp Outdated
Comment thread src/module/orbbec.cpp
@SebastianMunozP
Copy link
Copy Markdown
Contributor Author

[question] Was the old depth image return effectively unusable with the old 0-1mm normalization?
That's correct.

[question] Do we currently have any users of the depth image that will be affected by this change?
Brad is trying to use these depth images, he is the one that flagged this issue and who will use this as soon as we release it.

@SebastianMunozP SebastianMunozP merged commit 91738d4 into viam-modules:main Apr 27, 2026
5 checks passed
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.

3 participants