namespace utils — HIRO 0.7.0 documentation

# namespace utils

## Overview

General namespace for utilities. More…

    namespace utils {

    // typedefs

    typedef utils::StrongOptionalType<float, class LogReader> ProgressPercentage;
    typedef DelegatedNotifier<const LogEntry::Type> LogEntryNotifier;
    typedef DelegatedNotifier<const ProgressPercentage> ProgressNotifier;

    // enums

    enum BaseAxis;
    enum Handedness;
    enum SpaceCategory;
    enum Units;

    // structs

    struct BasisDefinition;
    struct IntrinsicParams;

    template <typename C, typename T, T(C::*)() const getter, void(C::*)(const T&) setter>
    struct Property;

    template <typename C, typename T, T(C::*)() const getter, void(C::*)(T) setter>
    struct PropertyByValue;

    struct ScannerParams;
    struct SerializableJson;
    struct SpaceDefinition;

    template <typename PhantomType>
    struct StrongId;

    template <typename ValueType, typename PhantomType>
    struct StrongOptionalType;

    template <typename ValueType, typename PhantomType>
    struct StrongType;

    struct UnitNames;
    struct Version;

    // classes

    class CallbackTimer;

    template <typename T>
    class ConcurrentBinding;

    class ConsoleArgs;

    template <typename Type>
    class Couple;

    template <typename... Args>
    class DelegatedNotifier;

    class Dictionary;

    template <class T, class TMask = uint32_t>
    class EnumFlags;

    class EventHandler;
    class GlmQuatSerializable;
    class GlmVec3Serializable;

    template <typename IdType>
    class Identifiable;

    class IniParser;
    class Interval;
    class LogEntry;
    class LogReader;
    class LogWriter;
    class Logger;

    template <typename T>
    class NamedClass;

    template <typename... Args>
    class Notifier;

    class OnEnd;

    template <typename Type, typename SerializableType>
    class Serializer;

    template <typename Type>
    class Statistics;

    template <typename Type>
    class Triplet;

    // global variables

    const ScannerParams PHOXI_XS = []()   {     ScannerParams phoxi_xs;     phoxi_xs.resolution = glm::uvec2(2064, 1544);     phoxi_xs.fx = 3626.18f;     phoxi_xs.fy = 3627.91f;     phoxi_xs.cx = 1188.59f;     phoxi_xs.cy = 684.239f;     phoxi_xs.baseline = 85.0f;     phoxi_xs.camera_angle = 0.0f;     phoxi_xs.projector_angle = 17.0f;     phoxi_xs.projector_fovx = 47.5f;     phoxi_xs.projector_fovy = 36.0f;     phoxi_xs.near_range = 161.0f;     phoxi_xs.far_range = 205.0f;     return phoxi_xs;   }();
    const ScannerParams PHOXI_S = []()   {     ScannerParams phoxi_s;     phoxi_s.resolution = glm::uvec2(2064, 1544);     phoxi_s.fx = 2245.92f;     phoxi_s.fy = 2246.5f;     phoxi_s.cx = 1042.98f;     phoxi_s.cy = 772.933f;     phoxi_s.baseline = 230.0f;     phoxi_s.camera_angle = 15.45f;     phoxi_s.projector_angle = 15.45f;     phoxi_s.projector_fovx = 47.5f;     phoxi_s.projector_fovy = 36.0f;     phoxi_s.near_range = 384.0f;     phoxi_s.far_range = 520.0f;     return phoxi_s;   }();
    const ScannerParams PHOXI_M = []()   {     ScannerParams phoxi_m;     phoxi_m.resolution = glm::uvec2(2064, 1544);     phoxi_m.fx = 2268.68f;     phoxi_m.fy = 2268.88f;     phoxi_m.cx = 1032.65f;     phoxi_m.cy = 799.183f;     phoxi_m.baseline = 350.0f;     phoxi_m.camera_angle = 11.75f;     phoxi_m.projector_angle = 11.75f;     phoxi_m.projector_fovx = 47.5f;     phoxi_m.projector_fovy = 36.0f;     phoxi_m.near_range = 458.0f;     phoxi_m.far_range = 1118.0f;     return phoxi_m;   }();
    const ScannerParams PHOXI_L = []()   {     ScannerParams phoxi_l;     phoxi_l.resolution = glm::uvec2(2064, 1544);     phoxi_l.fx = 2263.31f;     phoxi_l.fy = 2263.29f;     phoxi_l.cx = 1054.4f;     phoxi_l.cy = 770.566f;     phoxi_l.baseline = 550.0f;     phoxi_l.camera_angle = 9.45f;     phoxi_l.projector_angle = 9.45f;     phoxi_l.projector_fovx = 47.5f;     phoxi_l.projector_fovy = 36.0f;     phoxi_l.near_range = 870.0f;     phoxi_l.far_range = 2150.0f;     return phoxi_l;   }();
    const ScannerParams PHOXI_XL = []()   {     ScannerParams phoxi_xl;     phoxi_xl.resolution = glm::uvec2(2064, 1544);     phoxi_xl.fx = 2245.37f;     phoxi_xl.fy = 2244.88f;     phoxi_xl.cx = 998.051f;     phoxi_xl.cy = 756.269f;     phoxi_xl.baseline = 850.0f;     phoxi_xl.camera_angle = 7.5f;     phoxi_xl.projector_angle = 7.5f;     phoxi_xl.projector_fovx = 47.5f;     phoxi_xl.projector_fovy = 36.0f;     phoxi_xl.near_range = 1680.0f;     phoxi_xl.far_range = 3780.0f;     return phoxi_xl;   }();
    const uint8_t BASIS_DEFINITION_VERSION = 1;
    const uint8_t SPACE_DEFINITION_VERSION = 2;
    const SpaceDefinition PHOXI_MARKER_SPACE = []()   {     SpaceDefinition space;     space.id = "PhoXi Marker";     space.category = SpaceCategory::marker;     space.up = BaseAxis::positive_z;     space.forward = BaseAxis::negative_x;     space.units = Units::mm;     space.handedness = Handedness::right;     return space;   }();
    const SpaceDefinition COGS_MARKER_SPACE = []()   {     SpaceDefinition space;     space.id = "COGS Marker";     space.category = SpaceCategory::marker;     space.up = BaseAxis::positive_y;     space.forward = BaseAxis::positive_z;     space.units = Units::m;     space.handedness = Handedness::right;     return space;   }();
    const SpaceDefinition PHOXI_CAMERA_SPACE = []()   {     SpaceDefinition space;     space.id = "PhoXi Camera";     space.category = SpaceCategory::camera;     space.up = BaseAxis::negative_y;     space.forward = BaseAxis::positive_z;     space.units = Units::mm;     space.handedness = Handedness::right;     return space;   }();
    const SpaceDefinition COGS_CAMERA_SPACE = []()   {     SpaceDefinition space;     space.id = "COGS Camera";     space.category = SpaceCategory::camera;     space.up = BaseAxis::positive_y;     space.forward = BaseAxis::negative_z;     space.units = Units::m;     space.handedness = Handedness::right;     return space;   }();
    const std::map<std::string, SpaceDefinition> SPACE_DEFINITION_OF_ID =   {     {PHOXI_MARKER_SPACE.id, PHOXI_MARKER_SPACE},     {PHOXI_CAMERA_SPACE.id, PHOXI_CAMERA_SPACE},     {COGS_MARKER_SPACE.id, COGS_MARKER_SPACE},     {COGS_CAMERA_SPACE.id, COGS_CAMERA_SPACE}   };

    // global functions

    glm::vec3 BulletToGlmVec(const btVector3& bt_vec);
    glm::quat BulletToGlmQuat(const btQuaternion& bt_quat);
    Eigen::Vector3d BulletToEigenVec(const btVector3& bt_vec);
    Eigen::Quaterniond BulletToEigenQuat(const btQuaternion& bt_quat);
    btVector3 GlmToBulletVec(const glm::vec3& vec);
    btQuaternion GlmToBulletQuat(const glm::quat& glm_quat);
    bool HasPermissionToWriteHere();
    std::string CvMatTypeToString(const int mat_type);
    gl::GLenum CvMatTypeToGlType(const int mat_type);
    unsigned int GetNumOfChannels(const int mat_type);
    glw::PTexture2D MatToTexture(const cv::Mat& image, bool flip_vertically);
    cv::Mat TextureToMat(const glw::PTexture2D& texture, bool flip_vertically, const int mat_type);

    template <typename T, int m, int n, typename OutT = float>
    glm::mat<m, n, OutT, glm::precision::highp> EigenToGlmMat(const Eigen::Matrix<T, m, n>& em);

    template <typename T, int m, int n>
    Eigen::Matrix<T, m, n> GlmToEigenMat(const glm::mat<m, n, float, glm::precision::highp>& glm_mat);

    template <typename T, int m>
    glm::vec<m, float, glm::precision::highp> EigenToGlmVec(const Eigen::Matrix<T, m, 1>& em);

    template <typename T>
    glm::quat EigenToGlmQuat(const Eigen::Quaternion<T>& q);

    Eigen::Vector3d GlmToEigenVec(const glm::vec3& glm_vec);

    template <typename T>
    Eigen::Quaternion<T> GlmToEigenQuat(const glm::quat& q);

    glm::vec2 GetPrincipalPoint(float focal_length, float fovx, float fovy);
    IntrinsicParams GetIntrinsicParamsFromResolution(const glm::uvec2& resolution, float fovx, float fovy);
    IntrinsicParams GetIntrinsicParamsFromDepth(float focal_length, float fovx, float fovy);
    UTILS_API bool operator==(const IntrinsicParams& p1, const IntrinsicParams& p2);
    UTILS_API bool operator!=(const IntrinsicParams& p1, const IntrinsicParams& p2);
    UTILS_API bool operator==(const ScannerParams& p1, const ScannerParams& p2);
    UTILS_API bool operator!=(const ScannerParams& p1, const ScannerParams& p2);
    static float GetUnitConversionRatio(utils::Units source_units, utils::Units target_units);
    static const UnitNames& GetUnitName(utils::Units unit);
    static size_t BaseAxisToId(BaseAxis axis);
    static float BaseAxisToSign(BaseAxis axis);
    static glm::vec3 BaseAxisToVec3(BaseAxis axis);
    static glm::vec4 BaseAxisToVec4(BaseAxis axis, float w = 0.0f);
    static bool AreCollinear(BaseAxis axis_a, BaseAxis axis_b);
    std::string SpaceCategoryToString(SpaceCategory categ);
    bool operator<(const Version& a, const Version& b);
    bool operator>(const Version& a, const Version& b);
    bool operator<=(const Version& a, const Version& b);
    bool operator>=(const Version& a, const Version& b);
    bool operator==(const Version& a, const Version& b);
    bool operator!=(const Version& a, const Version& b);

    } // namespace utils

## Detailed Documentation

General namespace for utilities.

### Global Variables

    const ScannerParams PHOXI_XS = []()   {     ScannerParams phoxi_xs;     phoxi_xs.resolution = glm::uvec2(2064, 1544);     phoxi_xs.fx = 3626.18f;     phoxi_xs.fy = 3627.91f;     phoxi_xs.cx = 1188.59f;     phoxi_xs.cy = 684.239f;     phoxi_xs.baseline = 85.0f;     phoxi_xs.camera_angle = 0.0f;     phoxi_xs.projector_angle = 17.0f;     phoxi_xs.projector_fovx = 47.5f;     phoxi_xs.projector_fovy = 36.0f;     phoxi_xs.near_range = 161.0f;     phoxi_xs.far_range = 205.0f;     return phoxi_xs;   }()

Scanner parameter definition for PhoXi XS device.

    const ScannerParams PHOXI_S = []()   {     ScannerParams phoxi_s;     phoxi_s.resolution = glm::uvec2(2064, 1544);     phoxi_s.fx = 2245.92f;     phoxi_s.fy = 2246.5f;     phoxi_s.cx = 1042.98f;     phoxi_s.cy = 772.933f;     phoxi_s.baseline = 230.0f;     phoxi_s.camera_angle = 15.45f;     phoxi_s.projector_angle = 15.45f;     phoxi_s.projector_fovx = 47.5f;     phoxi_s.projector_fovy = 36.0f;     phoxi_s.near_range = 384.0f;     phoxi_s.far_range = 520.0f;     return phoxi_s;   }()

Scanner parameter definition for PhoXi S device.

    const ScannerParams PHOXI_M = []()   {     ScannerParams phoxi_m;     phoxi_m.resolution = glm::uvec2(2064, 1544);     phoxi_m.fx = 2268.68f;     phoxi_m.fy = 2268.88f;     phoxi_m.cx = 1032.65f;     phoxi_m.cy = 799.183f;     phoxi_m.baseline = 350.0f;     phoxi_m.camera_angle = 11.75f;     phoxi_m.projector_angle = 11.75f;     phoxi_m.projector_fovx = 47.5f;     phoxi_m.projector_fovy = 36.0f;     phoxi_m.near_range = 458.0f;     phoxi_m.far_range = 1118.0f;     return phoxi_m;   }()

Scanner parameter definition for PhoXi M device.

    const ScannerParams PHOXI_L = []()   {     ScannerParams phoxi_l;     phoxi_l.resolution = glm::uvec2(2064, 1544);     phoxi_l.fx = 2263.31f;     phoxi_l.fy = 2263.29f;     phoxi_l.cx = 1054.4f;     phoxi_l.cy = 770.566f;     phoxi_l.baseline = 550.0f;     phoxi_l.camera_angle = 9.45f;     phoxi_l.projector_angle = 9.45f;     phoxi_l.projector_fovx = 47.5f;     phoxi_l.projector_fovy = 36.0f;     phoxi_l.near_range = 870.0f;     phoxi_l.far_range = 2150.0f;     return phoxi_l;   }()

Scanner parameter definition for PhoXi L device.

    const ScannerParams PHOXI_XL = []()   {     ScannerParams phoxi_xl;     phoxi_xl.resolution = glm::uvec2(2064, 1544);     phoxi_xl.fx = 2245.37f;     phoxi_xl.fy = 2244.88f;     phoxi_xl.cx = 998.051f;     phoxi_xl.cy = 756.269f;     phoxi_xl.baseline = 850.0f;     phoxi_xl.camera_angle = 7.5f;     phoxi_xl.projector_angle = 7.5f;     phoxi_xl.projector_fovx = 47.5f;     phoxi_xl.projector_fovy = 36.0f;     phoxi_xl.near_range = 1680.0f;     phoxi_xl.far_range = 3780.0f;     return phoxi_xl;   }()

Scanner parameter definition for PhoXi XL device.

### Global Functions

    glm::vec3 BulletToGlmVec(const btVector3& bt_vec)

Converts bullet vector to glm vector.

    glm::quat BulletToGlmQuat(const btQuaternion& bt_quat)

Converts bullet quaternion to glm quaternion.

    Eigen::Vector3d BulletToEigenVec(const btVector3& bt_vec)

Converts bullet vector to Eigen vector.

    Eigen::Quaterniond BulletToEigenQuat(const btQuaternion& bt_quat)

Converts bullet quaternion to Eigen quaternion.

    btVector3 GlmToBulletVec(const glm::vec3& vec)

Converts glm vector to bullet vector.

    btQuaternion GlmToBulletQuat(const glm::quat& glm_quat)

Converts glm quaternion to bullet quaternion.

    bool HasPermissionToWriteHere()

Function returns if the current user has the right to write into the project directory.

    template <typename T, int m, int n, typename OutT = float>
    glm::mat<m, n, OutT, glm::precision::highp> EigenToGlmMat(const Eigen::Matrix<T, m, n>& em)

Converts Eigen matrix to glm matrix.

    template <typename T, int m, int n>
    Eigen::Matrix<T, m, n> GlmToEigenMat(const glm::mat<m, n, float, glm::precision::highp>& glm_mat)

Converts glm matrix to Eigen matrix.

    template <typename T, int m>
    glm::vec<m, float, glm::precision::highp> EigenToGlmVec(const Eigen::Matrix<T, m, 1>& em)

Converts Eigen matrix to glm vector.

    template <typename T>
    glm::quat EigenToGlmQuat(const Eigen::Quaternion<T>& q)

Converts Eigen quaternion to glm quaternion.

    Eigen::Vector3d GlmToEigenVec(const glm::vec3& glm_vec)

Converts glm vector to Eigen vector.

    template <typename T>
    Eigen::Quaternion<T> GlmToEigenQuat(const glm::quat& q)

Converts glm quaternion to Eigen quaternion.

    glm::vec2 GetPrincipalPoint(float focal_length, float fovx, float fovy)

Returns intrinsic cx, cy parameters for defined projection depth and field of view angles.

    IntrinsicParams GetIntrinsicParamsFromResolution(const glm::uvec2& resolution, float fovx, float fovy)

Calculates intrinsic projection parameters from resolution and field of view angles.

    IntrinsicParams GetIntrinsicParamsFromDepth(float focal_length, float fovx, float fovy)

Calculates intrinsic projection parameters from projection depth and field of view angles.

    UTILS_API bool operator==(const IntrinsicParams& p1, const IntrinsicParams& p2)

Compare equality of two parameter structures.

    UTILS_API bool operator!=(const IntrinsicParams& p1, const IntrinsicParams& p2)

Compare unequality of two parameter structures.

    UTILS_API bool operator==(const ScannerParams& p1, const ScannerParams& p2)

Compare equality of two parameter structures.

    UTILS_API bool operator!=(const ScannerParams& p1, const ScannerParams& p2)

Compare unequality of two parameter structures.

    static float GetUnitConversionRatio(utils::Units source_units, utils::Units target_units)

Gets ratio that describes relation between two provided units. target_value = source_value * ratio.

    static const UnitNames& GetUnitName(utils::Units unit)

Gets ratio that describes relation between two provided unit: target_value = source_value * ratio.

    static size_t BaseAxisToId(BaseAxis axis)

Converts base axis x,y,z hints to 0,1,2 respectively.

    static float BaseAxisToSign(BaseAxis axis)

Converts base axis positive,negative hints to 1,-1 respectively.

    static glm::vec3 BaseAxisToVec3(BaseAxis axis)

Converts base axis to vec3.

    static glm::vec4 BaseAxisToVec4(BaseAxis axis, float w = 0.0f)

Converts base axis to vec4, with possible custom w element value.