AI Watch A1
Multi-person 3D skeleton detection using Intel RealSense and OpenPose with Kafka support.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CoordinateMappingManager Class Reference

The CoordinateMappingManager class is a class that is responsible for converting coordinates values from a coordinates' space to another one. A certain coordinates' space has to inherit from this class and implement its own conversion method, overriding the base class method. More...

#include <CoordinateMappingManager.hpp>

Inheritance diagram for CoordinateMappingManager:
UnityCoordinateMappingManager

Public Member Functions

 CoordinateMappingManager (Room room)
 Construct a new Coordinate Mapping Manager object. More...
 
virtual std::vector< Point3D * > * mapToMeters (std::vector< Point3D * > pointsToMap, std::vector< bool > bodyKeyPointsMap, float xOrigin, float zOrigin)
 This method requires pointers' Point3D's vector, the related vector map, and the original coordinates' space origins. It returns a pointer to pointers' Point3D's vector that actually contains all input Points whose coordinates' values have been converted to the new coordinates' space. In the parent class, the conversion just converts the RealSense's values to more accessible axes' origins. More...
 

Protected Member Functions

Room getRoom (void)
 Returns the room object. More...
 
float transformWidthCoordinate (float widthCoordinate)
 Converts width value. More...
 
float transformHeightCoordinate (float heightCoordinate)
 Converts height value. More...
 
float inverseTransform (float inputNumber)
 Implements the inverse conversion on the input value. More...
 

Protected Attributes

const Room room
 Specific room within which the coordinate mapping will be done. More...
 

Detailed Description

The CoordinateMappingManager class is a class that is responsible for converting coordinates values from a coordinates' space to another one. A certain coordinates' space has to inherit from this class and implement its own conversion method, overriding the base class method.

See also
https://math.stackexchange.com/questions/685110/how-to-determine-coordinates-on-two-different-size-rectangles

Definition at line 28 of file CoordinateMappingManager.hpp.

Constructor & Destructor Documentation

◆ CoordinateMappingManager()

CoordinateMappingManager::CoordinateMappingManager ( Room  room)
inline

Construct a new Coordinate Mapping Manager object.

Parameters
roomSpecific room within which the coordinate mapping will be done.

Definition at line 63 of file CoordinateMappingManager.hpp.

63: room(room) { }
const Room room
Specific room within which the coordinate mapping will be done.

Member Function Documentation

◆ getRoom()

Room CoordinateMappingManager::getRoom ( void  )
protected

Returns the room object.

Returns
Room

Definition at line 16 of file CoordinateMappingManager.cpp.

16 {
17 return this->room;
18}

References room.

Referenced by mapToMeters(), UnityCoordinateMappingManager::mapToMeters(), transformHeightCoordinate(), and transformWidthCoordinate().

◆ inverseTransform()

float CoordinateMappingManager::inverseTransform ( float  inputNumber)
protected

Implements the inverse conversion on the input value.

Parameters
inputNumberInput value to convert.
Returns
float

Definition at line 42 of file CoordinateMappingManager.cpp.

42 {
43 float outputNumber = 0.0;
44 if (inputNumber >= 1) {
45 outputNumber = (1 - 2 * inputNumber);
46 } else if (inputNumber <= -1) {
47 outputNumber = (-(1 + 2 * inputNumber));
48 } else {
49 outputNumber = (1 - std::abs(inputNumber) + 0.25);
50 }
51
52 return outputNumber;
53}

◆ mapToMeters()

std::vector< Point3D * > * CoordinateMappingManager::mapToMeters ( std::vector< Point3D * >  pointsToMap,
std::vector< bool >  bodyKeyPointsMap,
float  xOrigin,
float  zOrigin 
)
virtual

This method requires pointers' Point3D's vector, the related vector map, and the original coordinates' space origins. It returns a pointer to pointers' Point3D's vector that actually contains all input Points whose coordinates' values have been converted to the new coordinates' space. In the parent class, the conversion just converts the RealSense's values to more accessible axes' origins.

Parameters
pointsToMap
bodyKeyPointsMap
xOrigin
zOrigin
Returns
std::vector <Point3D *> *

Reimplemented in UnityCoordinateMappingManager.

Definition at line 57 of file CoordinateMappingManager.cpp.

57 {
58 std::vector <Point3D *> * newPoints = new std::vector <Point3D *>;
59
60 for (unsigned char i = 0; i < bodyKeyPointsMap.size(); i++) {
61 if (!bodyKeyPointsMap.at(i)) {
62 newPoints->push_back(new Point3D(0, 0, 0, new BodyKeyPoint(0, 0, 0)));
63 } else {
64 newPoints->push_back(new Point3D(
65 transformWidthCoordinate(pointsToMap.at(i)->getX()),
66 transformHeightCoordinate(pointsToMap.at(i)->getY()),
67 pointsToMap.at(i)->getZ() - zOrigin + getRoom().getDistanceCameraFromBackWall(),
68 new BodyKeyPoint(0, 0, ((BodyKeyPoint *) pointsToMap.at(i)->getDecorated())->getConfidence()))
69 );
70 }
71 }
72
73 return newPoints;
74}
BodyKeyPoint class is used for body keypoint creations and manipulations.
float transformWidthCoordinate(float widthCoordinate)
Converts width value.
float transformHeightCoordinate(float heightCoordinate)
Converts height value.
Room getRoom(void)
Returns the room object.
Point3D class is used for Point3D creations and manipulations.
Definition: Point3D.hpp:23

References getRoom(), transformHeightCoordinate(), and transformWidthCoordinate().

Referenced by Skeleton::generateSkeleton().

◆ transformHeightCoordinate()

float CoordinateMappingManager::transformHeightCoordinate ( float  heightCoordinate)
protected

Converts height value.

Parameters
heightCoordinateInput height value.
Returns
float

Definition at line 26 of file CoordinateMappingManager.cpp.

26 {
27// float environmentHeight = std::abs(getRoom().getMinHeight()) + std::abs(getRoom().getMaxHeight());
28// float environmentHeightRS = std::abs(getRoom().getMinHeightRS()) + std::abs(getRoom().getMaxHeightRS());
29// float tempHeight = -(((heightCoordinate - getRoom().getMaxHeightRS()) / environmentHeightRS) * environmentHeight) + getRoom().getMinHeight();
30// return std::abs(tempHeight) - 0.9;
31
32 float newHeightCoordinate = -heightCoordinate + getRoom().getMaxHeightRS() - getRoom().getHeightOffset();
33 if (newHeightCoordinate >= getRoom().getMaxHeight()) {
34 return getRoom().getMaxHeight();
35 } else if (newHeightCoordinate <= 0) {
36 return 0;
37 }
38
39 return newHeightCoordinate;
40}
float getMaxHeightRS(void)
Get the RealSense environment's maximum height.
Definition: Room.cpp:117
float getHeightOffset(void)
Get the height offset.
Definition: Room.cpp:133
float getMaxHeight(void)
Get the Room's maximum height.
Definition: Room.cpp:97

References Room::getHeightOffset(), Room::getMaxHeight(), Room::getMaxHeightRS(), and getRoom().

Referenced by mapToMeters(), and UnityCoordinateMappingManager::mapToMeters().

◆ transformWidthCoordinate()

float CoordinateMappingManager::transformWidthCoordinate ( float  widthCoordinate)
protected

Converts width value.

Parameters
widthCoordinateInput width value.
Returns
float

Definition at line 20 of file CoordinateMappingManager.cpp.

20 {
21 float environmentWidth = std::abs(getRoom().getMinWidth()) + std::abs(getRoom().getMaxWidth());
22 float environmentWidthRS = std::abs(getRoom().getMinWidthRS()) + std::abs(getRoom().getMaxWidthRS());
23 return (((widthCoordinate - getRoom().getMinWidthRS()) / environmentWidthRS) * environmentWidth) + getRoom().getMinWidth();
24}
float getMinWidth(void)
Get the Room's minimum width.
Definition: Room.cpp:85

References Room::getMinWidth(), and getRoom().

Referenced by mapToMeters(), and UnityCoordinateMappingManager::mapToMeters().

Member Data Documentation

◆ room

const Room CoordinateMappingManager::room
protected

Specific room within which the coordinate mapping will be done.

Definition at line 33 of file CoordinateMappingManager.hpp.

Referenced by getRoom().


The documentation for this class was generated from the following files: