Skip to content

SW device depth-units per sensor's DEPTH_UNITS, if set #12196

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

Merged
merged 8 commits into from
Sep 18, 2023

Conversation

maloel
Copy link
Contributor

@maloel maloel commented Sep 14, 2023

Goes along with #12193:

  • Fixes initialization in Python of software frames (all types)
  • If SW sensor now has DEPTH_UNITS set and no depth_units are set in the frame (when creating the frame), then the frame will pick up the sensor's depth units
  • If a sensor changes its depth units after the frame exists, it will not see the new value
  • Added a unit-test

Tracked on [DSO-19246]

@maloel maloel requested a review from Nir-Az September 14, 2023 08:48
@Nir-Az
Copy link
Collaborator

Nir-Az commented Sep 14, 2023

Can you elaborate on If a sensor changes its depth units after the frame exists, it will not see the new value

If a user does

  • create_sw_frame (depth_unit = 0.1)
  • set_option(depth_unit, 0.2)

what will be the behavior on the next two cases?

  • create_sw_frame ()
  • create_sw_frame(depth_unit = 0.3)


with test.closure( "New frame should pick up DEPTH_UNITS" ):
test.check_approx_abs( df.get_units(), 0.001, 0.00000001 )
test.check_approx_abs( df.get_distance( 0, 0 ), 26.985, 0.000001 )
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the distance did change when setting the depth_units?
Where did you modified it from 0?

Copy link
Contributor Author

@maloel maloel Sep 14, 2023

Choose a reason for hiding this comment

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

From the sensor: we changed the sensor DEPTH_UNITS (line 35), to the new frame picked it up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I will ask again here as my question before was general.
Do we use the depth units in the frame calculation? for some scale factor?
How did you get the 26.985? there is no real sensor here, so this value comes from somewhere and I am missing it..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes: see here.
We do pixel-value * depth-units, in this case 0x6969 (from sw.py buffer) * 0.001 = 26.985. That's why I changed sw.py to 0x69 -- it was 0x00 before, so would have yielded 0 distance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Now I understand thanks.
Can you add a comment before this check? its not clear as the initialization is done in another file.

What will happen if no depth unit is set? depth will always be zero?

I am not sure its the best default behavior as the user doesnt know he must set it.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without depth units, there can be no depth. With regular cameras, we take care to set this (it wasn't always a setting), but with software sensors it has to be provided by someone...

Before, it was completely uninitialized with no way to set it at all... I'd say this is an improvement. And again, this is only for the get_distance() function -- there are other ways to get at the pixel data and calculating depth. I just don't think SW devices saw much use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(it was uninitialized in the wrappers; in C++ it's part of the structure so visible to all and settable)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree its good to fix in the root.
Only issue is that when user will use without setting the depth unit he we get 0.

Maybe we need to set it to 1? no impact on the pixels by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my comment offline. I do not believe we can or should tell the user what value to put there. It is up to the user to correctly set the data.

@maloel
Copy link
Contributor Author

maloel commented Sep 14, 2023

Can you elaborate on If a sensor changes its depth units after the frame exists, it will not see the new value

If a user does

  • create_sw_frame (depth_unit = 0.1)
  • set_option(depth_unit, 0.2)

what will be the behavior on the next two cases?

  • create_sw_frame ()
  • create_sw_frame(depth_unit = 0.3)

The frame takes:

  • The SW frame depth_units, if it's not 0
  • The sensor DEPTH_UNITS, if it's not 0

So the first case, if you publish a sw-frame with depth_units unset, it will take the sensor's (if it's set).
The second case, it should take the 0.3.

See the code in software-device.cpp.

Copy link
Collaborator

@Nir-Az Nir-Az left a comment

Choose a reason for hiding this comment

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

LGTM

@maloel maloel merged commit 372a608 into IntelRealSense:development Sep 18, 2023
@maloel maloel deleted the query-units branch September 18, 2023 17:19
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.

2 participants