Skip to content

Add reflectivity tool to Depth Quality Tool application - #7675

Merged
maloel merged 2 commits into
realsenseai:developmentfrom
Nir-Az:add_reflectivity_tool
Nov 3, 2020
Merged

Add reflectivity tool to Depth Quality Tool application#7675
maloel merged 2 commits into
realsenseai:developmentfrom
Nir-Az:add_reflectivity_tool

Conversation

@Nir-Az

@Nir-Az Nir-Az commented Oct 29, 2020

Copy link
Copy Markdown
Collaborator

Adding reflectivity tool to DQT:

  • Add new option "RS2_NOISE_ESTIMATION"
  • Add new option "RS2_ENABLE_IR_REFLECTIVITY"
  • Add reflectivity algorithm class
  • Add display at the DQT application
  • Current calculations for display occurs at frame rate

UI:
image

Note: This PR does not contain all logical conditions for activating IR Reflectivity

Tracked on [RS5-9263]

Comment thread src/l500/l500-options.cpp Outdated
{
if (value == 1.0f)
{
auto &max_usable_range_option = _l500_depth_dev->get_depth_sensor().get_option(RS2_OPTION_ENABLE_MAX_USABLE_RANGE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should do this only AFTER we've checked that all the other options are acceptable...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread src/l500/l500-options.cpp
Comment thread src/l500/l500-options.cpp Outdated
const char * ir_reflectivity_option::get_description() const
{

return "IR Reflectivity Tool� calculates the percentage of IR light reflected by the "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's a symbol after Tool that I don't think should be there

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread src/l500/l500-options.cpp Outdated
{

return "IR Reflectivity Tool� calculates the percentage of IR light reflected by the "
"object and returns to the camera for processing.\n For example, a value of 60% means "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space after \n shouldn't be there

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread src/l500/l500-options.cpp Outdated

return "IR Reflectivity Tool� calculates the percentage of IR light reflected by the "
"object and returns to the camera for processing.\n For example, a value of 60% means "
"that 60% of the IR light projected by L515 is reflected by the object and returns "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

by L515 -> by the camera

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread src/types.cpp Outdated
CASE(HUMIDITY_TEMPERATURE)
CASE(ENABLE_MAX_USABLE_RANGE)
CASE(NOISE_ESTIMATION)
CASE(ENABLE_IR_REFLECTIVITY)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you need to override this one manually to return Enable IR Reflectivity

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Cause we want capitalized R in IR ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread wrappers/matlab/option.m Outdated
Comment thread wrappers/python/pybackend.cpp Outdated
.value("sequence_id", RS2_OPTION_SEQUENCE_ID)
.value("humidity_temperature", RS2_OPTION_HUMIDITY_TEMPERATURE)
.value("enable_max_usable_range", RS2_OPTION_ENABLE_MAX_USABLE_RANGE)
.value("noise_estimation", RS2_OPTION_NOISE_ESTIMATION)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/viewer.h Outdated
std::shared_ptr<updates_model> updates;

bool draw_max_usable_range = true;
std::unordered_set<int> _hided_options;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_hidden_options? No such thing as hided :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/viewer.h Outdated
Comment thread common/viewer.h Outdated
Comment thread common/reflectivity/reflectivity.h
Comment thread common/model-views.cpp Outdated
if (_reflectivity_data_collected)
{
viewer.ref.reset();
_reflectivity_data_collected = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we make it so the Reflectivity class knows whether data has been collected (essentially, if it's not empty)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We can I thought about it too but wasn't sure what I preffer , if you think its better I can change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes please

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread common/model-views.cpp Outdated
Comment thread common/model-views.cpp Outdated
Comment thread common/model-views.cpp Outdated
viewer.ref.add_input(val, x, y);
_reflectivity_data_collected = true;

float noise_est = ds.get_option(RS2_OPTION_NOISE_ESTIMATION);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remind me -- the noise estimation is now shown in the Viewer? With the temperatures?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I will add it to the hidden options for the viewer+ DQT since nobody asked for it.

Comment thread common/model-views.cpp
Comment thread common/model-views.cpp Outdated
try
{
pixel_ref = viewer.ref.get_reflectivity(noise_est, max_usable_range, ir_val);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extra line

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/model-views.cpp Outdated
@Nir-Az
Nir-Az force-pushed the add_reflectivity_tool branch from 6396f7d to b9c5db1 Compare November 2, 2020 10:32
Comment thread common/reflectivity/reflectivity.cpp Outdated
return false;
} );

if (0 == count_valid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Needed? Why not just use _filt_dist_arr.empty()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/reflectivity/reflectivity.cpp Outdated
float reflectivity::get_reflectivity(float raw_noise_estimation,float max_usable_range, float ir_val) const
{
//Calculating STD over time(temporal noise), when there are more than 5 % invalid return high value
std::vector<float> _filt_dist_arr(STD_PERIOD);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not _dist_queue.size()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/reflectivity/reflectivity.cpp Outdated
using namespace rs2;


static const int STD_PERIOD = 100;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

N_STD_FRAMES? Period implies time...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/reflectivity/reflectivity.cpp Outdated
return true;
}
return false;
} );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clang

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/reflectivity/reflectivity.cpp Outdated
static const int VGA_HALF_WIDTH = 320;
static const int VGA_HALF_HEIGHT = 240;

static bool is_close_to_zero(float x) { return (std::abs(x) < std::numeric_limits<float>::epsilon()); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clang

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/reflectivity/reflectivity.cpp Outdated
{
float variance = 0.0f;
for( auto val : _filt_dist_arr )
variance += pow( val - mean, 2.0f );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we do all this why we're counting count_valid? Then maybe we don't need to copy to another vector?

@Nir-Az Nir-Az Nov 3, 2020

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed as discussed (count_vaid removed)

Comment thread common/reflectivity/reflectivity.cpp Outdated
standard_deviation = sqrt( variance );
}

//Range is calculated based on position in map(assuming 0 tilt) Distance is just based on plane distance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space between // and the text, please

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/model-views.cpp Outdated
}
catch (...) {};
if (pixel_ref != -1.0f)
ref_str = to_string() << std::dec << round(pixel_ref * 100) << "%";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move into the try block

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/model-views.cpp Outdated
auto max_usable_range = mur_sensor.get_max_usable_depth_range();
reflectivity_valid = true;
std::string ref_str = "N/A";
float pixel_ref = -1.0f;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not needed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/model-views.cpp Outdated
{
pixel_ref = _reflectivity->get_reflectivity(noise_est, max_usable_range, ir_val);
}
catch (...) {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/model-views.cpp Outdated
&& ds.supports( RS2_OPTION_ENABLE_MAX_USABLE_RANGE )
&& ( p.stream_type() == RS2_STREAM_INFRARED ) || ( p.stream_type() == RS2_STREAM_DEPTH ) )
{
_reflectivity = std::unique_ptr< reflectivity >(new reflectivity());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we check whether it's skipped here rather than later?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/reflectivity/reflectivity.cpp Outdated
variance += pow( val - mean, 2.0f );

variance = variance / _filt_dist_arr.size();
standard_deviation = sqrt( variance );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a double conversion, no? Maybe use std::sqrt...
Make sure no warnings.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread common/reflectivity/reflectivity.cpp Outdated
static bool is_close_to_zero(float x) { return (std::abs(x) < std::numeric_limits<float>::epsilon()); }


reflectivity::reflectivity() : _is_empty(false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clang

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

@Nir-Az
Nir-Az force-pushed the add_reflectivity_tool branch from b9c5db1 to 0e3a2d3 Compare November 3, 2020 08:07
@maloel
maloel merged commit 7573fee into realsenseai:development Nov 3, 2020
@Nir-Az
Nir-Az deleted the add_reflectivity_tool branch December 23, 2020 07:24
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