-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #8952 from Avishag: Support L535 options
- Loading branch information
Showing
19 changed files
with
327 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//// License: Apache 2.0. See LICENSE file in root directory. | ||
//// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#include "l535-amc-option.h" | ||
#include "l500-private.h" | ||
#include "l500-depth.h" | ||
|
||
|
||
using librealsense::ivcam2::l535::amc_option; | ||
|
||
amc_option::amc_option( librealsense::l500_device * l500_dev, | ||
librealsense::hw_monitor * hw_monitor, | ||
librealsense::ivcam2::l535::amc_control type, | ||
const std::string & description ) | ||
: _device( l500_dev ) | ||
, _hw_monitor( hw_monitor ) | ||
, _control( type ) | ||
, _description( description ) | ||
{ | ||
// Keep the USB power on while triggering multiple calls on it. | ||
ivcam2::group_multiple_fw_calls( _device->get_depth_sensor(), [&]() { | ||
auto min = _hw_monitor->send( command{ AMCGET, _control, get_min } ); | ||
auto max = _hw_monitor->send( command{ AMCGET, _control, get_max } ); | ||
auto step = _hw_monitor->send( command{ AMCGET, _control, get_step } ); | ||
|
||
if( min.size() < sizeof( int32_t ) || max.size() < sizeof( int32_t ) | ||
|| step.size() < sizeof( int32_t ) ) | ||
{ | ||
std::stringstream s; | ||
s << "Size of data returned is not valid min size = " << min.size() | ||
<< ", max size = " << max.size() << ", step size = " << step.size(); | ||
throw std::runtime_error( s.str() ); | ||
} | ||
|
||
auto max_value = float( *( reinterpret_cast< int32_t * >( max.data() ) ) ); | ||
auto min_value = float( *( reinterpret_cast< int32_t * >( min.data() ) ) ); | ||
|
||
auto res = query_default(); | ||
|
||
_range = option_range{ min_value, | ||
max_value, | ||
float( *( reinterpret_cast< int32_t * >( step.data() ) ) ), | ||
res }; | ||
} ); | ||
} | ||
|
||
float amc_option::query() const | ||
{ | ||
auto res = _hw_monitor->send( command{ AMCGET, _control, get_current } ); | ||
|
||
if( res.size() < sizeof( int32_t ) ) | ||
{ | ||
std::stringstream s; | ||
s << "Size of data returned from query(get_current) of " << _control << " is " << res.size() | ||
<< " while min size = " << sizeof( int32_t ); | ||
throw std::runtime_error( s.str() ); | ||
} | ||
auto val = *( reinterpret_cast< uint32_t * >( res.data() ) ); | ||
return float( val ); | ||
} | ||
|
||
void amc_option::set( float value ) | ||
{ | ||
_hw_monitor->send( command{ AMCSET, _control, (int)value } ); | ||
} | ||
|
||
librealsense::option_range amc_option::get_range() const | ||
{ | ||
return _range; | ||
} | ||
|
||
float amc_option::query_default() const | ||
{ | ||
auto res = _hw_monitor->send( command{ AMCGET, _control, l500_command::get_default } ); | ||
|
||
auto val = *( reinterpret_cast< uint32_t * >( res.data() ) ); | ||
return float( val ); | ||
} | ||
|
||
void amc_option::enable_recording( std::function< void( const option & ) > recording_action ) {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
#include "hw-monitor.h" | ||
#include "l500-device.h" | ||
|
||
namespace librealsense { | ||
namespace ivcam2 { | ||
namespace l535 { | ||
enum amc_control | ||
{ | ||
confidence = 0, | ||
post_processing_sharpness = 1, | ||
pre_processing_sharpness = 2, | ||
noise_filtering = 3, | ||
apd = 4, | ||
laser_gain = 5, | ||
min_distance = 6, | ||
invalidation_bypass = 7, | ||
alternate_ir = 8, | ||
rx_sensitivity = 9, | ||
}; | ||
|
||
enum amc_command | ||
{ | ||
get_current = 0, | ||
get_min = 1, | ||
get_max = 2, | ||
get_step = 3, | ||
get_default = 4 | ||
}; | ||
|
||
class amc_option : public option | ||
{ | ||
public: | ||
float query() const override; | ||
|
||
void set( float value ) override; | ||
|
||
option_range get_range() const override; | ||
|
||
bool is_enabled() const override { return true; } | ||
|
||
const char * get_description() const override { return _description.c_str(); } | ||
|
||
void enable_recording( std::function< void( const option & ) > recording_action ) override; | ||
|
||
amc_option( l500_device * l500_dev, | ||
hw_monitor * hw_monitor, | ||
amc_control type, | ||
const std::string & description ); | ||
|
||
private: | ||
float query_default() const; | ||
|
||
amc_control _control; | ||
l500_device * _device; | ||
hw_monitor * _hw_monitor; | ||
option_range _range; | ||
std::string _description; | ||
}; | ||
} // namespace l535 | ||
} // namespace ivcam2 | ||
} // namespace librealsense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//// License: Apache 2.0. See LICENSE file in root directory. | ||
//// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#include "l535-device-options.h" | ||
#include "l535-amc-option.h" | ||
#include "l535-preset-option.h" | ||
#include "l500-private.h" | ||
#include "l500-depth.h" | ||
|
||
using librealsense::ivcam2::l535::device_options; | ||
|
||
device_options::device_options( std::shared_ptr< librealsense::context > ctx, | ||
const librealsense::platform::backend_device_group & group ) | ||
: device( ctx, group ) | ||
, l500_device( ctx, group ) | ||
{ | ||
auto & raw_depth_sensor = get_raw_depth_sensor(); | ||
auto & depth_sensor = get_depth_sensor(); | ||
|
||
// Keep the USB power on while triggering multiple HW monitor commands on it. | ||
ivcam2::group_multiple_fw_calls( depth_sensor, [&]() { | ||
auto default_sensor_mode = RS2_SENSOR_MODE_VGA; | ||
|
||
std::map< rs2_option, std::pair< amc_control, std::string > > options = { | ||
{ RS2_OPTION_POST_PROCESSING_SHARPENING, | ||
{ post_processing_sharpness, | ||
"Changes the amount of sharpening in the post-processed image" } }, | ||
{ RS2_OPTION_PRE_PROCESSING_SHARPENING, | ||
{ pre_processing_sharpness, | ||
"Changes the amount of sharpening in the pre-processed image" } }, | ||
{ RS2_OPTION_NOISE_FILTERING, | ||
{ noise_filtering, "Control edges and background noise" } }, | ||
{ RS2_OPTION_AVALANCHE_PHOTO_DIODE, | ||
{ apd, "Changes the exposure time of Avalanche Photo Diode in the receiver" } }, | ||
{ RS2_OPTION_CONFIDENCE_THRESHOLD, | ||
{ confidence, | ||
"The confidence level threshold to use to mark a pixel as valid by the depth " | ||
"algorithm" } }, | ||
{ RS2_OPTION_LASER_POWER, | ||
{ laser_gain, "Power of the laser emitter, with 0 meaning projector off" } }, | ||
{ RS2_OPTION_MIN_DISTANCE, | ||
{ min_distance, "Minimal distance to the target (in mm)" } }, | ||
{ RS2_OPTION_INVALIDATION_BYPASS, | ||
{ invalidation_bypass, "Enable/disable pixel invalidation" } }, | ||
{ RS2_OPTION_ALTERNATE_IR, | ||
{ alternate_ir, "Enable/Disable alternate IR" } }, | ||
{ RS2_OPTION_AUTO_RX_SENSITIVITY, | ||
{ rx_sensitivity, "auto gain" } } // TODO: replace the description | ||
}; | ||
|
||
for( auto i : options ) | ||
{ | ||
auto opt = std::make_shared< amc_option >( this, | ||
_hw_monitor.get(), | ||
i.second.first, | ||
i.second.second ); | ||
|
||
depth_sensor.register_option( i.first, opt ); | ||
_advanced_options.push_back( i.first ); | ||
} | ||
|
||
auto preset = std::make_shared< preset_option >( | ||
option_range{ RS2_L500_VISUAL_PRESET_CUSTOM, | ||
RS2_L500_VISUAL_PRESET_CUSTOM, | ||
1, | ||
RS2_L500_VISUAL_PRESET_CUSTOM }, | ||
"Preset to calibrate the camera" ); //todo:improve the | ||
|
||
depth_sensor.register_option( RS2_OPTION_VISUAL_PRESET, preset ); | ||
} ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
#include "hw-monitor.h" | ||
#include "l500-device.h" | ||
|
||
namespace librealsense { | ||
namespace ivcam2 { | ||
namespace l535 { | ||
|
||
class device_options : public virtual l500_device | ||
{ | ||
public: | ||
device_options( std::shared_ptr< context > ctx, const platform::backend_device_group & group ); | ||
}; | ||
|
||
} // namespace l535 | ||
} // namespace ivcam2 | ||
} // namespace librealsense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//// License: Apache 2.0. See LICENSE file in root directory. | ||
//// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#include "l535-preset-option.h" | ||
#include "l500-private.h" | ||
#include "l500-depth.h" | ||
|
||
using librealsense::ivcam2::l535::preset_option; | ||
|
||
preset_option::preset_option( const librealsense::option_range & range, std::string description ) | ||
: float_option_with_description< rs2_l500_visual_preset >( range, description ) | ||
{ | ||
} | ||
|
||
void preset_option::set( float value ) | ||
{ | ||
if (static_cast<rs2_l500_visual_preset>(int(value)) != RS2_L500_VISUAL_PRESET_CUSTOM) | ||
throw invalid_value_exception(to_string() << | ||
static_cast<rs2_l500_visual_preset>(int(value)) << "not supported!"); | ||
|
||
super::set( value ); | ||
} | ||
|
||
void preset_option::set_value( float value ) | ||
{ | ||
super::set( value ); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
#include "hw-monitor.h" | ||
#include "l500-device.h" | ||
|
||
namespace librealsense { | ||
namespace ivcam2 { | ||
namespace l535 { | ||
|
||
class preset_option : public float_option_with_description< rs2_l500_visual_preset > | ||
{ | ||
typedef float_option_with_description< rs2_l500_visual_preset > super; | ||
public: | ||
preset_option( const option_range& range, std::string description ); | ||
void set( float value ) override; | ||
void set_value( float value ); | ||
}; | ||
|
||
} // namespace l535 | ||
} // namespace ivcam2 | ||
} // namespace librealsense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.