Property Types#

class IProperty#

Subclassed by aidi::props::FeatureMap, aidi::props::IRegionList, aidi::props::Image, aidi::props::PolygonRegionList, aidi::props::RawImageInfo, aidi::props::RegionMatchResultList, aidi::props::ViewList

class Image : public aidi::props::IProperty#

Property Image.

Public Functions

Image()#

Construct a new Image object by default.

explicit Image(const aidi::Image &image)#

Construct a new Image object.

Parameters:

imageaidi::Image image data.

Image(const Image &rhs)#

Copy constructor.

Only copy the image data pointer and raw image infomation, not the data. If you want to copy the data, you should use aidi::Image::clone().

Parameters:

rhs – Other Image.

Image &operator=(const Image &rhs)#

Assignment operator.

Only copy the image data pointer and raw image infomation, not the data. If you want to copy the data, you should use aidi::Image::clone().

Parameters:

rhs – Other Image.

Returns:

Image& reference to this object.

Image(Image &&rhs) noexcept#

Move constructor.

Parameters:

rhs – Other rvalue Image.

Image &operator=(Image &&rhs) noexcept#

Move assignment operator.

Parameters:

rhs – Other rvalue Image.

Returns:

Image& reference to this object.

const aidi::Image &image() const#

Get image data.

Returns:

NO_DISCARD const aidi::Image& image data.

Image &set_image(const aidi::Image &image)#

Set the image data.

Parameters:

imageaidi::Image image data.

Returns:

Image& reference to this object.

class RawImageInfo : public aidi::props::IProperty#

Public Functions

explicit RawImageInfo(const std::string &file_path, bool from_camera = false, int64_t import_time = 0, const Tags &tags = Tags())#

Construct a new Raw Image Info object, with file path, camera id, import time and tags.

Parameters:
  • file_path – File path. If from_camera is true, file_path means camera id.

  • from_camera – Whether the image is from camera. Default is false, which means from file.

  • import_time – Import time. If import time is 0 (As default), it will be set to the current time.

  • tags – The Tags.

const std::string &file_path() const#

Get image file path.

Returns:

const std::string& if from_camera() is true, return the camera id.

const std::string &camera_id() const#

Get image camera id.

Returns:

const std::string& if from_camera() is false, return file path.

int64_t import_time() const#

Get image import time.

Returns:

NO_DISCARD Image import time.

bool from_camera() const#

Get whether the image is from camera.

Returns:

NO_DISCARD true for camera, false for file.

const Tags &tags() const#

Get the tags of the raw image.

Returns:

NO_DISCARD const Tags & the tags of the raw image.

Tags &tags()#

Get the mutable tags of the raw image.

Returns:

NO_DISCARD Tags & the mutable tags of the raw image.

RawImageInfo &set_file_path(const std::string &file_path)#

Set the file path.

Parameters:

file_pathImage file path.

Returns:

RawImageInfo& reference to this object.

RawImageInfo &set_camera_id(const std::string &camera_id)#

Set the camera id.

Parameters:

camera_idImage camera id.

Returns:

RawImageInfo& reference to this object.

RawImageInfo &set_import_time(int64_t import_time)#

Set the import time.

Parameters:

import_timeImage import time.

Returns:

RawImageInfo& reference to this object.

RawImageInfo &set_tags(const Tags &tags)#

Set the tags of the raw image.

Parameters:

tags – The tags of the raw image.

Returns:

RawImageInfo& reference to this object.

class ViewList : public virtual aidi::props::IRegionList, public virtual aidi::props::IProperty#

Property ViewList contains multiple aidi::TaggedView.

Public Types

using Iterator = std::map<std::string, TaggedView>::iterator#

ViewList iterator.

Public Functions

ViewList()#

Construct a new ViewList object by default.

ViewList(const ViewList &rhs)#

Deep copy constructor.

It will not share the same references as the source object.

Parameters:

rhs – Other ViewList.

ViewList &operator=(const ViewList &rhs)#

Assignment operator.

Parameters:

rhs – Other ViewList.

Returns:

ViewList& reference to this object.

ViewList(ViewList &&rhs) noexcept#

Move constructor.

Parameters:

rhs – Other rvalue ViewList.

ViewList &operator=(ViewList &&rhs) noexcept#

Move assignment operator.

Parameters:

rhs – Other rvalue ViewList.

Returns:

ViewList& reference to this object.

virtual size_t size() const override#

Get the number of aidi::TaggedView in this ViewList.

Returns:

size_t The number of aidi::TaggedView in this ViewList.

virtual std::vector<std::string> keys() const override#

Get all aidi::TaggedView IDs in this list.

Returns:

std::vector<std::string> The IDs of all aidi::TaggedView in this list.

virtual const TaggedView &at(const std::string &view_key) const override#

Get the aidi::TaggedView at the given view ID.

Parameters:

view_key – The ID of the aidi::TaggedView.

Returns:

const TaggedView& The aidi::TaggedView reference at the given ID.

virtual bool contains(const std::string &view_key) const override#

Whether the aidi::TaggedView with the given ID exists in this viewlist.

Parameters:

view_key – The ID of the aidi::TaggedView.

Returns:

true The aidi::TaggedView with the given ID exists in this list.

Returns:

false The aidi::TaggedView with the given ID does not exist in this list.

virtual void erase(const std::string &view_key) override#

Remove the aidi::TaggedView with the given ID. Nothing will be done if the ID is not found.

Parameters:

view_key – The ID of the aidi::TaggedView to be removed.

Iterator erase(const Iterator &pos)#

Remove the aidi::TaggedView the Iterator refereced and return iterator to the next.

Parameters:

pos – The Iterator of the aidi::TaggedView to be removed.

Returns:

The Iterator to the aidi::TaggedView follows the removed view.

std::string add(const TaggedView &view)#

Add a new aidi::TaggedView instance into this list. An new id will be generated for the view added.

Parameters:

view – The aidi::TaggedView to be added into this list.

Returns:

std::string The view id generated by the list.

bool add(const Iterator &it)#

Add a new aidi::TaggedView into this list. If the ID already exists, fail to add and return false.

Parameters:

it – The Iterator of the aidi::TaggedView to be added.

Returns:

true If added successfully.

Returns:

false If failed to add.

void update(const std::string &view_key, const TaggedView &new_view)#

Update aidi::TaggedView specified by view_key with the new view. If view specified by view_key does not exist, the new aidi::TaggedView instance new_view will be added into this list with key view_key.

Parameters:
  • view_key – The key of the view to be updated.

  • new_view – The new aidi::TaggedView to be updated.

Iterator find(const std::string &view_key)#

Get iterator to aidi::TaggedView with id view_key.

Parameters:

view_key – The id to be searched for.

Returns:

Iterator The iterator to the aidi::TaggedView with id view_key or The iterator to map::end if not found.

Iterator begin() const#

Get iterator pointing to the first element.

If the ViewList is empty, the returned iterator will be equal to end().

Returns:

NO_DISCARD iterator pointing to the first element.

Iterator end() const#

Get iterator pointing to the element following the last element of ViewList.

This element acts as a placeholder. Attempting to access it results in undefined behavior.

Returns:

NO_DISCARD iterator pointing to the element following the last element of ViewList.

ViewList tagged_views(const aidi::SplitTag &split_tag) const#

Get the specified split tag ViewList.

Parameters:

split_tagaidi::SplitTag split tag.

Returns:

NO_DISCARD the specified split tag ViewList

std::vector<aidi::View> views() const#

Get the aidi::View corresponding to each aidi::TaggedView.

Returns:

NO_DISCARD the aidi::View corresponding to each aidi::TaggedView.

struct IRegionList : public virtual aidi::props::IProperty#

IRegionList Interface to represent a list of regions.

Each region in the list has it’s own unique id with which the region can be identified.

Subclassed by aidi::props::PolygonRegionList, aidi::props::ViewList

Public Functions

virtual size_t size() const = 0#

Interface to get the number of regions in this list.

Returns:

size_t The number of regions in this list.

inline bool empty() const#

If the region list is empty or not.

Returns:

true If the region list is empty.

Returns:

false If the region list is not empty.

virtual std::vector<std::string> keys() const = 0#

Get all regions IDs in this list.

Returns:

std::vector<std::string> The IDs of all regions in this list.

virtual const IRegion &at(const std::string &region_key) const = 0#

Interface to get the region at the given region ID.

Parameters:

region_key – The ID of the region.

Returns:

const IRegion& The region reference at the given ID.

virtual bool contains(const std::string &region_key) const = 0#

If the region with the given ID exists in this list.

Parameters:

region_key – The ID of the region.

Returns:

true The region with the given ID exists in this list.

Returns:

false The region with the given ID does not exist in this list.

virtual void erase(const std::string &region_key) = 0#

Interface to remove the region at the given ID. Nothing will be done if the ID is not found.

Parameters:

region_key – The ID of the region to be removed.

class PolygonRegionList : public virtual aidi::props::IRegionList, public virtual aidi::props::IProperty#

PolygonRegionList Class to store list of PolygonRegion. Generally used as segmentation label.

Public Functions

virtual size_t size() const override#

Interface to get the number of regions in this list.

Returns:

size_t The number of regions in this list.

virtual std::vector<std::string> keys() const override#

Get all regions IDs in this list.

Returns:

std::vector<std::string> The IDs of all regions in this list.

virtual const PolygonRegion &at(const std::string &region_key) const override#

Interface to get the region at the given region ID.

Parameters:

region_key – The ID of the region.

Returns:

const IRegion& The region reference at the given ID.

virtual bool contains(const std::string &region_key) const override#

If the region with the given ID exists in this list.

Parameters:

region_key – The ID of the region.

Returns:

true The region with the given ID exists in this list.

Returns:

false The region with the given ID does not exist in this list.

virtual void erase(const std::string &region_key) override#

Interface to remove the region at the given ID. Nothing will be done if the ID is not found.

Parameters:

region_key – The ID of the region to be removed.

std::string add(const PolygonRegion &region)#

Add a new PolygonRegion instance into this list. An new id will be generated for the region added.

Parameters:

region – The region to be added into this list.

Returns:

std::string The region id generated by the list.

void update(const std::string &region_key, const PolygonRegion &new_region)#

Update region specified by region_key with the new region. If region specified by region_key does not exist, the new PolygonRegion instance new_region will be added into this list with key region_key.

Parameters:
  • region_key – The key of the region to be updated.

  • new_region – The new region to be updated.

geometry::MultiPolygon2f to_multi_polygons(const std::string &specific_name) const#

Concat all polygon of regions with the specific_name into a geometry::MultiPolygon2f data structure.

Parameters:

specific_name – the specific region name.

Returns:

geometry::MultiPolygon2f

geometry::MultiPolygon2f to_multi_polygons() const#

Concat all polygon of regions in the list into a geometry::MultiPolygon2f data structure.

Returns:

geometry::MultiPolygon2f

class FeatureMap : public aidi::props::IProperty#

FeatureMap is a data structure used to store feature maps detected by each algorithm module. A FeatureMap stores a single-channel floating-point grayscale image for each label class according to the label class name of the detected target. It’s recommended that the value of the grayscale image is between 0 and 1.

Public Functions

void insert(const std::string &label_class, const aidi::SubImage &feature_map)#

Insert feature map with label class name. The old feature map with same label class name will be replaced.

Note

The data of the image in the aidi::SubImage will not be copied, which means that if you modify the data content in the image later, the data of the image in the inserted sub-image will also be modified. If this is not the behavior you expect, you can call aidi::SubImage::clone() explicitly like below:

feature_map.insert("label-class", sub_image.clone());

Parameters:
  • label_class – The label class name of the feature map.

  • feature_map – The feature map, which should be a single-channel floating-point grayscale image, and it’s recommended that the value of the grayscale image is between 0 and 1.

Throws:

aidi::excepts::InvalidArgument – if the feature map if not a single-channel floating-point grayscale image.

void remove(const std::string &label_class)#

Remove feature map specified by the label class name. Do nothing if the class name not found.

Parameters:

label_class – The key of the feature map to be removed.

bool contains(const std::string &label_class) const#

Check if the feature map exists in the container.

Parameters:

label_class – The class name of the feature map

Returns:

True if exists. Else false.

const aidi::SubImage &get(const std::string &label_class) const#

Get the feature map specified by the name.

Note

Do not modify the data of the image in the aidi::SubImage without clone,

Parameters:

label_class

Returns:

const aidi::SubImage & The reference of the feature map.

std::vector<std::string> keys() const#

Get all class names of all feature maps.

Returns:

std::vector<std::string> The class names list.

void clear()#

Clear the container.

class RegionMatchResultList : public aidi::props::IProperty#

Property to store list of RegionMatchResult.

Public Functions

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

Get all ground truth match results named with the regions’ key.

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

Get all match results for predicted regions named with the regions’ key.

std::map<std::string, RegionMatchResult> &gt_infos()#

Get all mutable ground truth match results.

std::map<std::string, RegionMatchResult> &pred_infos()#

Get all mutable match results for predicted regions.

Property Base Types#

class View#

View after matrix transformation.

Subclassed by aidi::TaggedView

Public Functions

View()#

Construct a new View object by default.

View(const geometry::Matrix3f &mat, const geometry::Size2f &size)#

Constructor with transformation matrix and transformed View size.

Parameters:
  • mat – Transformation matrix.

  • sizeView size.

View(const View &rhs)#

Deep copy constructor.

It will not share the same references as the source object.

Parameters:

rhs – Other View.

View &operator=(const View &rhs)#

Assignment operator.

It will not share the same references as the source object.

Parameters:

rhs – Other View.

Returns:

View& reference to this object.

View(View &&rhs) noexcept#

Move constructor.

Parameters:

rhs – Other rvalue View.

View &operator=(View &&rhs) noexcept#

Move assignment operator.

Parameters:

rhs – Other rvalue View.

Returns:

View& reference to this object.

geometry::Ring2f view_on_raw_image() const#

Ring on raw image before View transformation.

Returns:

NO_DISCARD geometry::Ring2f the result is Ring.

const geometry::Matrix3f &transform_matrix() const#

Get transformation matrix.

Returns:

NO_DISCARD const geometry::Matrix3f& transformation matrix.

const geometry::Size2f &size() const#

Get transformed View size.

Returns:

NO_DISCARD const geometry::Size2f& View size.

View &set_size(const geometry::Size2f &size)#

Set the transformed View size.

Parameters:

sizeView size.

Returns:

View& reference to this object.

View &set_size(float w, float h)#

Set the transformed View size.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
  • wView size width.

  • hView size height.

Returns:

View& reference to this object.

View &set_transform_matrix(const geometry::Matrix3f &mat)#

Set the transformation matrix.

Parameters:

mat – Transformation matrix.

Returns:

View& reference to this object.

enum aidi::SplitTag#

Split tag for the View.

Values:

enumerator kUnknown = 0#

Undivided set.

enumerator kTrain = 1#

Training set.

enumerator kTest = 2#

Test set.

class Tags#

Tags Manager. The Tags Manager supports two types of tags: value-tag and grouped-tag.

The value-tag is a string with any characters but should not contains “:=”, You can add any number of unique value-tags into a Tags Manager.

The grouped-tag is a string format like “<GROUP>:=<VALUE>”, the GROUP is the group name, and the VALUE is the value of this group. The Tags Manager will only keep one value for each unique group. For example, All tags start with “date:=” will be remove from the Tags Manager when you add “date:=2021:12:31” into the Tags Manager.

Public Functions

Tags &add(const std::string &tag)#

Add tag string to tag some object.

Parameters:

tag – The tag string to be add, which should not be empty, otherwise it will be ignored and warning log will be print. In particular, if a tag string is formatted like “<GROUP>:=<VALUE>” (e.g. “date:=2021-12-31”), it will be recognized as a grouped-tag.

Tags &remove(const std::string &tag)#

Remove tag from the manager.

Parameters:

tag – The tag to be removed. If it’s formatted like “<GROUP>:=”, the grouped-tag “GROUP” will be removed.

const std::string &at(const std::string &group) const#

Get the value of the tag with the group name.

Parameters:

group – The group name. e.g. “date:=”

Throws:

aidi::excepts::DataNotFound – If the group name is not found.

Returns:

const std::string& The value of the tag. If the tag is not found, an exception will be thrown.

bool contains(const std::string &tag) const#

Check if the manager contains the specific tag.

Parameters:

tag – The specific tag. If it’s formatted like “<GROUP>:=”, The result represent that if the group exists in the manager.

Returns:

true

Returns:

false

size_t size() const#

Get number of tags in the manager.

Returns:

size_t The number of tags in the manager.

std::vector<std::string> all() const#

Get all tags in the manager.

Returns:

std::vector<std::string> The vector of tags.

std::vector<std::string> search(const std::string &regex) const#

Search all tags matching the given regular expression.

Parameters:

regex – The regular expression.

Throws:

aidi::excepts::InvalidArgument – Maybe the regex is invalid.

Returns:

std::vector<std::string> Tags match with the regular expression

bool operator==(const Tags &other) const#

Compare two tags manager. Two tags manager are equal if they have the same tags.

Returns:

true If the two tags manager are equal.

class TaggedView : public aidi::View, public aidi::IRegion#

View with split tag.

Public Functions

TaggedView()#

Construct a new TaggedView object by default.

explicit TaggedView(const View &view, const SplitTag &split_tag = kUnknown)#

Constructor with View and SplitTag.

Parameters:
  • viewView.

  • split_tag – SplitTag. Default is kUnknown, which means undivided set.

TaggedView(const TaggedView &rhs)#

Deep copy constructor.

It will not share the same references as the source object.

Parameters:

rhs – Other TaggedView.

TaggedView &operator=(const TaggedView &rhs)#

Assignment operator.

It will not share the same references as the source object.

Parameters:

rhs – Other TaggedView.

Returns:

TaggedView& reference to this object.

TaggedView(TaggedView &&rhs) noexcept#

Move constructor.

Parameters:

rhs – Other rvalue TaggedView.

TaggedView &operator=(TaggedView &&rhs) noexcept#

Move assignment operator.

Parameters:

rhs – Other rvalue TaggedView.

Returns:

TaggedView& reference to this object.

virtual std::shared_ptr<IRegion> clone() const override#

Copy this region instance.

Returns:

std::shared_ptr<IRegion> copy of this region.

virtual geometry::Polygon2f polygon() const override#

Get the polygon of the raw image before View transformation.

Returns:

geometry::Polygon2f The polygon of the raw image before View transformation.

virtual geometry::Ring2f bounding_ring() const override#

Get the outer_boundary of the raw image before View transformation.

Returns:

geometry::Ring2f The outer_boundary of the raw image before View transformation.

const SplitTag &split_tag() const#

Get split tag.

Returns:

NO_DISCARD const SplitTag& split tag.

TaggedView &set_split_tag(const SplitTag &split_tag)#

Set the split tag.

Parameters:

split_tag – SplitTag.

Returns:

TaggedView& reference to this object.

const Tags &tags() const#

Get the tags.

Returns:

const Tags& tag.

Tags &tags()#

Get mutable tags.

Returns:

Tags& tags.

TaggedView &set_tags(const Tags &tags)#

Set the tags.

Parameters:

tagsTags.

Returns:

View& reference to this object.

class IRegion#

IRegion is an interface to represent a region in the coordinate system. Each region is defined by a ring and a name string.

Subclassed by aidi::PolygonRegion, aidi::TaggedView

Public Functions

virtual std::shared_ptr<IRegion> clone() const = 0#

Copy this region instance.

Returns:

std::shared_ptr<IRegion> copy of this region.

virtual geometry::Polygon2f polygon() const = 0#

Interface to get polygon of the region.

Returns:

geometry::Polygon2f the polygon representing this region.

inline virtual geometry::Ring2f bounding_ring() const#

Interface to get the outer_boundary of this region.

Returns:

geometry::Ring2f The outer_boundary of this region.

virtual IRegion &set_name(const std::string &name)#

Set the name of this region.

Parameters:

name – The new name of this region.

Returns:

IRegion& This region.

virtual IRegion &set_score(float score)#

Set score of this region.

virtual std::string name() const#

Interface to get name of this region.

Returns:

std::string

virtual float score() const#

Interface to get score of this region.

Default implementation returns 1.0F, Developers can override this method to return the score of the region in their own way. But it’s recommended that the score should be in [0, 1].

Returns:

float The score of this region.

inline virtual geometry::Radian angle() const#

Interface to get rotate angle of this region.

Returns:

geometry::Radian The angle of this region.

inline virtual float area() const#

Get the area of this region.

Default implementation returns the area of the polygon(). Developers can override this method to return the area of the region in their own way.

Returns:

float The area of this region.

class PolygonRegion : public aidi::IRegion#

Label Region descriped with polygon, generally used for segmentation.

Public Functions

virtual std::shared_ptr<IRegion> clone() const override#

Copy this region instance.

Returns:

std::shared_ptr<IRegion> copy of this region.

PolygonRegion &set_polygon(const geometry::Polygon2f &polygon)#

Set the polygon of this region.

Parameters:

polygon – The polygon of this region to be set.

Returns:

PolygonRegion& This region.

virtual geometry::Polygon2f polygon() const override#

Get the Polygon of segmentation region.

Returns:

geometry::Polygon2f The Polygon of segmentation region.

inline virtual PolygonRegion &set_name(const std::string &name) override#

Set the region name.

Parameters:

name – Name of this region.

Returns:

PolygonRegion& This region.

inline virtual PolygonRegion &set_score(float score) override#

Set the score of this region.

See also

IRegion::score()

Parameters:

score – The region score.

Returns:

PolygonRegion& This region.

PolygonRegion &set_angle(const geometry::Radian &angle)#

Set the rotate angle of this region.

See also

IRegion::angle()

Parameters:

angle – The rotate angle to be set.

Returns:

PolygonRegion& This region.

virtual geometry::Radian angle() const override#

Interface to get the rotate_angle of this region.

Returns:

geometry::Radian The rotate_angle of this region.

virtual geometry::Ring2f bounding_ring() const override#

Interface to get the outer_boundary of this region.

Returns:

geometry::Ring2f The outer_boundary of this region.

virtual float area() const override#

Get the area of this region.

Returns:

float The area of this region.

struct RegionMatchResult#

The region match result information output by the regions match operator. Each one of this structure represents a matching result for a region in the ground truth or the predictions.

Public Members

bool is_match = false#

If this region matches its best matching region. This field should false if the best_match is empty.

std::string best_match = {}#

The best matched region key. If this region is a ground truth, the best match should be in the predicted regions, vice versa. It will be an empty string If there are no regions matching this region.

Note

It’s not means that this region is matched with the best_batched region if this field is not empty, because there may be other region that is more suitable for matching the best_batched region of this region. The only way to know if this region matches its best matching region is the is_match field.

float iou#

The IoU value between this region and its best matched region. It should be 0 if not matched.