AI Watch A1
Multi-person 3D skeleton detection using Intel RealSense and OpenPose with Kafka support.
CoordinateMappingManager.cpp
Go to the documentation of this file.
1//
2// CoordinateMappingManager.cpp
3// AI Watch A1
4//
5// Created by Denny Caruso on 26/07/22.
6//
7
8// License: Apache 2.0. See LICENSE file in root directory.
9// Copyright(c) 2022. All Rights Reserved.
10
12#include <iostream>
13
14
15
17 return this->room;
18}
19
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}
25
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}
41
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}
54
55
56
57std::vector <Point3D *> * CoordinateMappingManager::mapToMeters (std::vector <Point3D *> pointsToMap, std::vector <bool> bodyKeyPointsMap, float xOrigin, float zOrigin) {
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 inverseTransform(float inputNumber)
Implements the inverse conversion on the input value.
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...
float transformWidthCoordinate(float widthCoordinate)
Converts width value.
const Room room
Specific room within which the coordinate mapping will be done.
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
Room class represents the Room abstraction. A Room object has different specifications,...
Definition: Room.hpp:64
float getMaxHeightRS(void)
Get the RealSense environment's maximum height.
Definition: Room.cpp:117
float getMinWidth(void)
Get the Room's minimum width.
Definition: Room.cpp:85
float getHeightOffset(void)
Get the height offset.
Definition: Room.cpp:133
float getMaxHeight(void)
Get the Room's maximum height.
Definition: Room.cpp:97