Utilities
Utilities header only library
utils Namespace Reference

General namespace for utilities. More...

Data Structures

struct  BasisDefinition
 Definition of an arbitrary basis. More...
 
class  ConcurrentBinding
 Controller for binding asynchronous processes. More...
 
class  Couple
 Structure holding two variables of the same type. More...
 
class  DelegatedNotifier
 An extension to Notifier - does not notify by itself. Instead it collects notifications and allows external code to call them when it pleases. More...
 
class  Dictionary
 Enables mapping string keys to string words efficiently. More...
 
class  EnumFlags
 Template implementation of Enum Flags. Allows the setting and checking of enum values. More...
 
class  EventHandler
 Provides an interface for registering and processing events for inherited classes. More...
 
class  GlmQuatSerializable
 Serializable extension of glm::quat. More...
 
class  GlmVec3Serializable
 Serializable extension of glm::vec3. More...
 
class  Identifiable
 An object that has an id (ideally a strong id). More...
 
class  Interval
 Holds float interval and performs operations on it. More...
 
struct  IntrinsicParams
 Holds camera intrinsic projection parameters. More...
 
class  LogEntry
 A single entry for the logging system. More...
 
class  Logger
 Class for log initialization. More...
 
class  LogReader
 Log - accumulate typed messages reported by the application. Includes percentage value in range <0,1>. More...
 
class  LogWriter
 Extension to LogReader. Provide write access to the log. More...
 
class  NamedClass
 A simple parent class to guarantee that all who derive from it will have a human-readable name. More...
 
class  Notifier
 A notifier is a mechanism to allow inter-object notifications. More...
 
class  OnEnd
 Helper class that performs an action when it is destroyed. More...
 
struct  ScannerParams
 Parameters of a virtual scanner. More...
 
struct  SerializableJson
 Abstration of a class that supports serialization to json strings. More...
 
class  Serializer
 Serialization utility class. Can perform automatic read and write. More...
 
struct  SpaceDefinition
 Definition of an arbitrary space. More...
 
class  Statistics
 Calculates statistical evaluation on a data set. More...
 
struct  StrongId
 Template class implementation of a Named Strong Id (a Strong Type with an underlying unsigned integer type (uint32_t)). More...
 
struct  StrongOptionalType
 std::optional specialization of the Strong type pattern. More...
 
struct  StrongType
 Template class implementation of a Named Strong Type. More...
 
class  Triplet
 Structure which holds three variables of same type. More...
 
struct  UnitNames
 String names for a specific unit. More...
 
struct  Version
 Holder for project version. More...
 

Typedefs

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

Enumerations

enum  Units : uint8_t {
  Units::km, Units::m, Units::dm, Units::cm,
  Units::mm, Units::um, Units::nm, Units::mi,
  Units::ft, Units::in
}
 Distance measurement units. More...
 
enum  BaseAxis : uint8_t {
  positive_x, positive_y, positive_z, negative_x,
  negative_y, negative_z
}
 Base axis.
 
enum  Handedness : uint8_t { left, right }
 Which hand to use.
 
enum  SpaceCategory : uint8_t { custom, camera, marker }
 Defines logical categories of spaces. Only spaces within same categories can be converted onto one another directly.
 

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.
 
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)
 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.
 
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)
 

Variables

const std::unordered_map< int, std::string > CV_MAT_TYPE_TO_STRING
 
const ScannerParams PHOXI_XS
 Scanner parameter definition for PhoXi XS device. More...
 
const ScannerParams PHOXI_S
 Scanner parameter definition for PhoXi S device. More...
 
const ScannerParams PHOXI_M
 Scanner parameter definition for PhoXi M device. More...
 
const ScannerParams PHOXI_L
 Scanner parameter definition for PhoXi L device. More...
 
const ScannerParams PHOXI_XL
 Scanner parameter definition for PhoXi XL device. More...
 
const uint8_t BASIS_DEFINITION_VERSION = 1
 
const uint8_t SPACE_DEFINITION_VERSION = 2
 
const SpaceDefinition PHOXI_MARKER_SPACE
 
const SpaceDefinition COGS_MARKER_SPACE
 
const SpaceDefinition PHOXI_CAMERA_SPACE
 
const SpaceDefinition COGS_CAMERA_SPACE
 
const std::map< std::string, SpaceDefinition > SPACE_DEFINITION_OF_ID
 

Detailed Description

General namespace for utilities.

Enumeration Type Documentation

◆ Units

enum utils::Units : uint8_t
strong

Distance measurement units.

Enumerator
km 

kilometer

m 

meter

dm 

decimeter

cm 

centimeter

mm 

millimeter

um 

micrometer

nm 

nanometer

mi 

mile

ft 

feet

in 

inch

Variable Documentation

◆ COGS_CAMERA_SPACE

const SpaceDefinition utils::COGS_CAMERA_SPACE
Initial value:
= []()
{
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;
}
()

◆ COGS_MARKER_SPACE

const SpaceDefinition utils::COGS_MARKER_SPACE
Initial value:
= []()
{
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;
}
()

◆ PHOXI_CAMERA_SPACE

const SpaceDefinition utils::PHOXI_CAMERA_SPACE
Initial value:
= []()
{
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;
}
()

◆ PHOXI_L

const ScannerParams utils::PHOXI_L
Initial value:
= []()
{
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.

◆ PHOXI_M

const ScannerParams utils::PHOXI_M
Initial value:
= []()
{
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.

◆ PHOXI_MARKER_SPACE

const SpaceDefinition utils::PHOXI_MARKER_SPACE
Initial value:
= []()
{
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;
}
()

◆ PHOXI_S

const ScannerParams utils::PHOXI_S
Initial value:
= []()
{
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.

◆ PHOXI_XL

const ScannerParams utils::PHOXI_XL
Initial value:
= []()
{
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.

◆ PHOXI_XS

const ScannerParams utils::PHOXI_XS
Initial value:
= []()
{
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.

◆ SPACE_DEFINITION_OF_ID

const std::map<std::string, SpaceDefinition> utils::SPACE_DEFINITION_OF_ID
Initial value:
=
{
{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}
}