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
UnityCoordinateMappingManager Class Reference

The UnityCoordinateMappingManager class is a class that is responsible for converting coordinates values from a coordinates' space to Unity coordinates' space whose parameters are specified at the top of this header file. More...

#include <CoordinateMappingManager.hpp>

Inheritance diagram for UnityCoordinateMappingManager:
CoordinateMappingManager

Public Member Functions

 UnityCoordinateMappingManager (Room room)
 Construct a new Unity Coordinate Mapping Manager object. More...
 
std::vector< Point3D * > * mapToMeters (std::vector< Point3D * > pointsToMap, std::vector< bool > bodyKeyPointsMap, float xOrigin, float zOrigin) override
 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 this case, the method converts the values to Unity coordinates' space values whose configuration parameters are specified at the top of this header file. 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 UnityCoordinateMappingManager class is a class that is responsible for converting coordinates values from a coordinates' space to Unity coordinates' space whose parameters are specified at the top of this header file.

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

Definition at line 86 of file CoordinateMappingManager.hpp.

Constructor & Destructor Documentation

◆ UnityCoordinateMappingManager()

UnityCoordinateMappingManager::UnityCoordinateMappingManager ( Room  room)

Construct a new Unity Coordinate Mapping Manager object.

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

Definition at line 15 of file UnityCoordinateMappingManager.cpp.

const Room room
Specific room within which the coordinate mapping will be done.
CoordinateMappingManager(Room room)
Construct a new Coordinate Mapping Manager object.

Member Function Documentation

◆ getRoom()

Room CoordinateMappingManager::getRoom ( void  )
protectedinherited

◆ inverseTransform()

float CoordinateMappingManager::inverseTransform ( float  inputNumber)
protectedinherited

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 * > * UnityCoordinateMappingManager::mapToMeters ( std::vector< Point3D * >  pointsToMap,
std::vector< bool >  bodyKeyPointsMap,
float  xOrigin,
float  zOrigin 
)
overridevirtual

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 this case, the method converts the values to Unity coordinates' space values whose configuration parameters are specified at the top of this header file.

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

Reimplemented from CoordinateMappingManager.

Definition at line 17 of file UnityCoordinateMappingManager.cpp.

17 {
18 std::vector <Point3D *> * newPoints = new std::vector <Point3D *>;
19 for (unsigned char i = 0; i < bodyKeyPointsMap.size(); i++) {
20 if (!bodyKeyPointsMap.at(i)) {
21 newPoints->push_back(new Point3D(0, 0, 0, new BodyKeyPoint(0, 0, 0)));
22 } else {
23 newPoints->push_back(new Point3D(
24 transformWidthCoordinate(pointsToMap.at(i)->getX()) - std::abs(xOrigin),
25 transformHeightCoordinate(pointsToMap.at(i)->getY()),
26 - (std::abs(pointsToMap.at(i)->getZ()) + std::abs(zOrigin) + getRoom().getDistanceCameraFromBackWall()),
27 new BodyKeyPoint(0, 0, ((BodyKeyPoint *) pointsToMap.at(i)->getDecorated())->getConfidence()))
28 );
29 }
30 }
31
32 return newPoints;
33}
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 CoordinateMappingManager::getRoom(), CoordinateMappingManager::transformHeightCoordinate(), and CoordinateMappingManager::transformWidthCoordinate().

◆ transformHeightCoordinate()

float CoordinateMappingManager::transformHeightCoordinate ( float  heightCoordinate)
protectedinherited

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 CoordinateMappingManager::getRoom().

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

◆ transformWidthCoordinate()

float CoordinateMappingManager::transformWidthCoordinate ( float  widthCoordinate)
protectedinherited

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 CoordinateMappingManager::getRoom().

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

Member Data Documentation

◆ room

const Room CoordinateMappingManager::room
protectedinherited

Specific room within which the coordinate mapping will be done.

Definition at line 33 of file CoordinateMappingManager.hpp.

Referenced by CoordinateMappingManager::getRoom().


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