15 #include "../../../third-party/json.hpp" 118 bool was_set =
false;
120 bool is_duplicated =
false;
126 template<
class T,
class S>
132 bool check_ranges =
true;
136 float value =
static_cast<float>(::atof(str.c_str()));
137 strct->vals[0].*field =
static_cast<S
>(scale *
value);
138 strct->update =
true;
143 std::stringstream ss;
144 ss << strct->vals[0].*field /
scale;
160 template<
class T,
class S>
173 (strct->vals[0].*field) = static_cast<S>(_values[value]);
174 strct->update =
true;
179 std::stringstream ss;
180 auto val = strct->vals[0].*field;
181 auto res = std::find_if(
std::begin(_values),
std::end(_values), [&](
const std::pair<std::string, float> &pair)
183 return pair.second ==
val;
194 template<
class T,
class S>
202 auto value = ::atof(str.c_str());
203 (strct->vals[0].*field) = (
value > 0) ? 0 : 1;
204 strct->update =
true;
209 std::stringstream ss;
210 ss << ((strct->vals[0].*field > 0.f) ? 0.
f : 1.
f);
215 template<
class T,
class S>
216 std::shared_ptr<json_field>
make_field(
T& strct, S T::group_type::* field,
float scale = 1.0
f,
bool is_duplicated_field =
false)
222 f->is_duplicated = is_duplicated_field;
226 template<
class T,
class S>
227 std::shared_ptr<json_field>
make_string_field(
T& strct, S T::group_type::* field,
const std::map<std::string, float>&
values,
bool is_duplicated_field =
false)
232 f->is_duplicated = is_duplicated_field;
238 return std::make_shared<json_ignored_field>();
241 template<
class T,
class S>
242 std::shared_ptr<json_field>
make_invert_field(
T& strct, S T::group_type::* field,
bool is_duplicated_field =
false)
247 f->is_duplicated = is_duplicated_field;
251 typedef std::map<std::string, std::shared_ptr<json_field>>
parsers_map;
253 template <
class T,
typename S>
261 template <
class T,
typename S>
264 const std::map<std::string, float>&
values)
270 template <
typename T>
274 preset_control = param.
vals[0];
277 template <
typename T>
282 camera_control = param.
vals[0];
283 camera_control.was_set =
true;
412 static const std::map<std::string, float> auto_control_values{ {
"False", 0.f }, {
"True", 1.f } };
415 static const std::map<std::string, float> laser_state_values{ {
"off", 0.f }, {
"on", 1.f }, {
"auto", 2.f } };
451 for (
auto&&
f : fields)
453 if (
f.second->is_duplicated)
456 auto str =
f.second->save();
458 j[
f.first.c_str()] =
str;
462 return std::vector<uint8_t>(
str.begin(),
str.end());
473 auto kvp = fields.find(
it.key());
474 if (
kvp != fields.end())
480 float val =
it.value();
481 std::stringstream ss;
483 kvp->second->load(ss.str());
487 kvp->second->load(
it.value());
489 kvp->second->was_set =
true;
std::string save() const override
uint32_t rauDiffThresholdBlue
param_group< STColorControl > color_control
param_group< sharpness_control > color_sharpness
Advanced Mode Commands header file.
param_group< STRauSupportVectorControl > rsvc
param_group< white_balance_control > color_white_balance
GLuint const GLchar * name
param_group< gain_control > depth_gain
param_group< STColorCorrection > cc
exposure_control color_exposure
STColorControl color_control
uint32_t disableSLOLeftColor
static basic_json parse(T(&array)[N], const parser_callback_t cb=nullptr)
deserialize from an array
laser_power_control laser_power
void insert_control_to_map(parsers_map &map, bool was_set, const std::string &name, param_group< T > &control, S field)
GLenum GLenum GLenum GLenum GLenum scale
param_group< STDepthTableControl > depth_table
std::vector< uint8_t > generate_json(const preset &in_preset)
STSloColorThresholdsControl sctc
void update_preset_camera_control(T &camera_control, const param_group< T > ¶m)
a class to store JSON values
auto_white_balance_control depth_auto_white_balance
auto_exposure_control color_auto_exposure
STDepthControlGroup depth_controls
uint32_t textureCountThreshold
param_group< exposure_control > color_exposure
GLsizei const GLchar *const * string
preset_param_group(const preset &other)
void load(const std::string &str) override
std::shared_ptr< json_field > make_ignored_field()
uint32_t sloK2PenaltyMod2
param_group< STSloPenaltyControl > spc
void insert_string_control_to_map(parsers_map &map, bool was_set, const std::string &name, param_group< T > &control, S field, const std::map< std::string, float > &values)
iterator end() noexcept
returns an iterator to one past the last element
param_group< power_line_frequency_control > color_power_line_frequency
uint32_t diffThresholdRed
param_group< backlight_compensation_control > color_backlight_compensation
uint32_t deepSeaMedianThreshold
uint32_t sloK1PenaltyMod2
param_group< STAFactor > a_factor
void update_structs(const std::string &content, preset &in_preset)
laser_state_control laser_state
param_group< auto_exposure_control > color_auto_exposure
param_group< gamma_control > color_gamma
sharpness_control color_sharpness
brightness_control color_brightness
std::map< std::string, float > _values
std::shared_ptr< json_field > make_invert_field(T &strct, S T::group_type::*field, bool is_duplicated_field=false)
auto_exposure_control depth_auto_exposure
uint32_t disableSLORightColor
white_balance_control color_white_balance
param_group< auto_white_balance_control > depth_auto_white_balance
uint32_t meanIntensitySetPoint
void load(const std::string &str) override
param_group< gain_control > color_gain
STAFactor amplitude_factor
std::map< std::string, std::shared_ptr< json_field > > parsers_map
std::string save() const override
std::shared_ptr< json_field > make_field(T &strct, S T::group_type::*field, float scale=1.0f, bool is_duplicated_field=false)
std::string save() const override
void load(const std::string &value) override
STRauSupportVectorControl rsvc
json_string_struct_field(std::map< std::string, float > values)
param_group< STHdad > hdad
preset_param_group & operator=(const preset &other)
gamma_control color_gamma
param_group< STAEControl > ae
void load(const std::string &str) override
auto_white_balance_control color_auto_white_balance
param_group< STDepthControlGroup > depth_controls
GLsizei const GLfloat * values
param_group< brightness_control > color_brightness
param_group< STSloColorThresholdsControl > sctc
parsers_map initialize_field_parsers(preset_param_group &p)
param_group< contrast_control > color_contrast
STDepthTableControl depth_table
uint32_t lrAgreeThreshold
std::string save() const override
void update_preset_control(T &preset_control, const param_group< T > ¶m)
contrast_control color_contrast
string_t dump(const int indent=-1) const
serialization
uint32_t sloK2PenaltyMod1
std::shared_ptr< json_field > make_string_field(T &strct, S T::group_type::*field, const std::map< std::string, float > &values, bool is_duplicated_field=false)
uint32_t diffThresholdGreen
param_group< auto_white_balance_control > color_auto_white_balance
exposure_control depth_exposure
saturation_control color_saturation
uint32_t disableSADNormalize
backlight_compensation_control color_backlight_compensation
basic_json<> json
default JSON class
param_group< hue_control > color_hue
uint32_t sloK1PenaltyMod1
param_group< STCensusRadius > census
uint32_t deepSeaNeighborThreshold
void copy(const preset &other)
param_group< STRauColorThresholdsControl > rctc
param_group< laser_state_control > laser_state
param_group< laser_power_control > laser_power
param_group< auto_exposure_control > depth_auto_exposure
uint32_t textureDifferenceThreshold
uint32_t rauDiffThresholdRed
power_line_frequency_control color_power_line_frequency
uint32_t rauDiffThresholdGreen
uint32_t diffThresholdBlue
int backlight_compensation
iterator begin() noexcept
returns an iterator to the first element
uint32_t deepSeaSecondPeakThreshold
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
STRauColorThresholdsControl rctc
void copy(void *dst, void const *src, size_t size)
param_group< saturation_control > color_saturation
param_group< exposure_control > depth_exposure
std::string to_string(T value)