Parameter Types#

IParameter#

class IParameter#

Subclassed by aidi::param::SchemableParameter

ISchemable#

struct ISchemable#

Json Schemable Class API.

A Json Schemable Class is a class that can be serialized to/deserialized from Json and can be validated by Json Schema.

Subclassed by aidi::param::SchemableParameter

Public Functions

virtual std::string json_schema() const = 0#

Get the json schema of the class.

Returns:

std::string the json schema string.

virtual aidi::Buffer to_json() const = 0#

Serialize the parameter group to schema-validatable json string.

Returns:

aidi::Buffer the schema-validatable json string.

virtual ISchemable &from_json(const aidi::Buffer &json_str) = 0#

Deserialize the parameter group from schema-validatable json string.

See also

validate(const std::string &json_str, std::string *error_msg = nullptr)

Parameters:

json_str[in] the schema-validatable json string.

Throws:
Returns:

ISchemable& the reference of the parameter.

bool validate(const aidi::Buffer &json_str, std::string *error_msg = nullptr) const#

Validate the parameter json string with json schema.

Parameters:
  • json_str[in] the json string.

  • error_msg[out] the error message if the json string is invalid, otherwise empty.

Throws:

aidi::excepts::InvalidJson – if the json string is invalid.

Returns:

bool true if the json string is valid, otherwise false.

SchemableParameter#

struct SchemableParameter : public virtual aidi::param::IParameter, public virtual aidi::param::ISchemable#

SchemableParameter feature interface for IParameter classes.

Subclassed by aidi::param::CustomParam, aidi::param::ExampleAugRotate, aidi::param::ExampleAugShift, aidi::param::ExampleAugments, aidi::param::InputImageParam

CustomParam#

class CustomParam : public aidi::param::SchemableParameter#

CustomParam Parameter class generated by jinja2 automatically.

可自定义的扩展参数组,使用一个字典存储用户给定的任意键值对. 键和值都必须是字符串类型,对于非字符串类型,用户可自行转换为字符串.

Public Functions

virtual std::string json_schema() const override#

Get the json schema of the class.

Returns:

std::string the json schema string.

const std::map<std::string, std::string> &get_ext() const#

Get Extend Parameters.

Extended parameters are used to set parameters conveniently in the development stage or for features that are not stable enough. In the officially released version, extended parameters should be used as little as possible.

See also

set_ext()

Returns:

const std::map<std::string, std::string> & Extend Parameters

CustomParam &set_ext(const std::map<std::string, std::string> &ext)#

Set Extend Parameters with std::map<std::string, std::string> value.

Extended parameters are used to set parameters conveniently in the development stage or for features that are not stable enough. In the officially released version, extended parameters should be used as little as possible.

See also

get_ext()

Parameters:

ext – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

CustomParam& the reference of this object.

const std::string &get_ext_at(const std::string &key) const#

Get value in Extend Parameters with key.

Warning

The key must be exist in Extend Parameters. otherwise, the behavior is undefined and will cause segmentation fault.

Returns:

const std::map<std::string, std::string> & value in Extend Parameters at key.

CustomParam &set_ext_at(const std::string &key, const std::string &value)#

Set value in Extend Parameters with key.

Parameters:
  • key – the key to set.

  • value – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

CustomParam& the reference of this object.

bool ext_contains(const std::string &key) const#

Check if the key is exist in Extend Parameters.

Returns:

bool true if the key is exist in Extend Parameters, otherwise false.

size_t get_ext_size() const#

Get the size of Extend Parameters.

Returns:

size_t the size of Extend Parameters

InputImageParam#

class InputImageParam : public aidi::param::SchemableParameter#

InputImageParam Parameter class generated by jinja2 automatically.

输入图像相关参数,用于控制工程的输入图像格式规范.

Public Functions

virtual std::string json_schema() const override#

Get the json schema of the class.

Returns:

std::string the json schema string.

int get_visual_size() const#

Get 可视图象数.

一个aidi.Image允许包含的可视图象数量, 多数情况下, 使用默认值1即可。若需要将多张图像当作一张图像处理, 可以设置为大于1的值。

Returns:

int 可视图象数

InputImageParam &set_visual_size(int visual_size)#

Set 可视图象数 with int value.

一个aidi.Image允许包含的可视图象数量, 多数情况下, 使用默认值1即可。若需要将多张图像当作一张图像处理, 可以设置为大于1的值。

Parameters:

visual_size – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

InputImageParam& the reference of this object.

以下参数项仅为示例#

class ExampleAugRotate : public aidi::param::SchemableParameter#

ExampleAugRotate Parameter class generated by jinja2 automatically.

Public Functions

virtual std::string json_schema() const override#

Get the json schema of the class.

Returns:

std::string the json schema string.

bool get_enable() const#

Get Enable.

Enable this augments

See also

set_enable()

Returns:

bool Enable

ExampleAugRotate &set_enable(bool enable)#

Set Enable with bool value.

Enable this augments

See also

get_enable()

Parameters:

enable – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugRotate& the reference of this object.

float get_rotate_angle() const#

Get Rotate Angle.

Rotate angle

Returns:

float Rotate Angle

ExampleAugRotate &set_rotate_angle(float rotate_angle)#

Set Rotate Angle with float value.

Rotate angle

Parameters:

rotate_angle – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugRotate& the reference of this object.

bool get_filp_horizontal() const#

Get Flip Horizontal.

Flip horizontal

Returns:

bool Flip Horizontal

ExampleAugRotate &set_filp_horizontal(bool filp_horizontal)#

Set Flip Horizontal with bool value.

Flip horizontal

Parameters:

filp_horizontal – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugRotate& the reference of this object.

bool get_flip_vertical() const#

Get Flip Vertical.

Flip vertical

Returns:

bool Flip Vertical

ExampleAugRotate &set_flip_vertical(bool flip_vertical)#

Set Flip Vertical with bool value.

Flip vertical

Parameters:

flip_vertical – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugRotate& the reference of this object.

class ExampleAugShift : public aidi::param::SchemableParameter#

ExampleAugShift Parameter class generated by jinja2 automatically.

Public Functions

virtual std::string json_schema() const override#

Get the json schema of the class.

Returns:

std::string the json schema string.

bool get_enable() const#

Get Enable.

Enable this augments

See also

set_enable()

Returns:

bool Enable

ExampleAugShift &set_enable(bool enable)#

Set Enable with bool value.

Enable this augments

See also

get_enable()

Parameters:

enable – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugShift& the reference of this object.

float get_shift_width() const#

Get Shift Width.

Shift width

Returns:

float Shift Width

ExampleAugShift &set_shift_width(float shift_width)#

Set Shift Width with float value.

Shift width

Parameters:

shift_width – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugShift& the reference of this object.

float get_shift_height() const#

Get Shift Height.

Shift height

Returns:

float Shift Height

ExampleAugShift &set_shift_height(float shift_height)#

Set Shift Height with float value.

Shift height

Parameters:

shift_height – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugShift& the reference of this object.

class ExampleAugments : public aidi::param::SchemableParameter#

ExampleAugments Parameter class generated by jinja2 automatically.

Public Functions

virtual std::string json_schema() const override#

Get the json schema of the class.

Returns:

std::string the json schema string.

bool get_enable() const#

Get Enable.

Enable this augments

See also

set_enable()

Returns:

bool Enable

ExampleAugments &set_enable(bool enable)#

Set Enable with bool value.

Enable this augments

See also

get_enable()

Parameters:

enable – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugments& the reference of this object.

const ExampleAugShift &get_shift() const#

Get Shift.

Shift augments

See also

set_shift()

Returns:

const ExampleAugShift & Shift

ExampleAugments &set_shift(const ExampleAugShift &shift)#

Set Shift with ExampleAugShift value.

Shift augments

See also

get_shift()

Parameters:

shift – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugments& the reference of this object.

ExampleAugShift &get_shift()#

Get mutable reference of Shift.

Shift augments

Returns:

ExampleAugments& the mutable reference of the group.

const ExampleAugRotate &get_rotate() const#

Get Rotate.

Rotate augments

See also

set_rotate()

Returns:

const ExampleAugRotate & Rotate

ExampleAugments &set_rotate(const ExampleAugRotate &rotate)#

Set Rotate with ExampleAugRotate value.

Rotate augments

See also

get_rotate()

Parameters:

rotate – the value to set.

Throws:

aidi::excepts::JsonSchemaValidationError – if validate the value with json schema failed.

Returns:

ExampleAugments& the reference of this object.

ExampleAugRotate &get_rotate()#

Get mutable reference of Rotate.

Rotate augments

Returns:

ExampleAugments& the mutable reference of the group.