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

Skeleton class is used for skeleton creations and manipulations. More...

#include <Skeleton.hpp>

Public Member Functions

 Skeleton (cv::Mat &rgbImage, cv::Mat &distanceImage, cv::Mat &skeletonImage, Json::Value skeletonData)
 Construct a new Skeleton object. More...
 
 ~Skeleton (void)
 Destroy the Skeleton object. More...
 
void generateSkeleton (void)
 A high-level method that abstracts all the internal structure and operations of the Skeleton class. It first calls calcBodyKeypoints(), then calcBodyEdges(), deprojectSkeletonPoints3D(), convert the coordinates in a specific format and then write them on the RGB image with writeCoordinates(). More...
 
std::vector< bool > getBodyKeyPointsMap (void)
 Get the BodyKeyPoints Map vector. More...
 
std::vector< Point3D * > getSkeletonPoints3D_RS (void)
 Get the SkeletonPoints3D RS vector. More...
 
std::vector< Point3D * > * getSkeletonPoints3D (void)
 Get the Skeleton Points3D vector's pointer. More...
 
float getConsistency (void)
 Get the Consistency float value. More...
 

Private Member Functions

void setRGB_Image (cv::Mat &rgbImage)
 Set the RGB Image object. More...
 
void setDistance_Image (cv::Mat &distanceImage)
 Set the Distance Image object. More...
 
void setSkeleton_Image (cv::Mat &skeleton_Image)
 Set the Skeleton-only Image object. More...
 
void setBodyKeyPoints (std::vector< BodyKeyPoint > &bodyKeyPoints)
 Set the Body Key Points vector. More...
 
void setBodyKeyPointsMap (std::vector< bool > &bodyKeyPointsMap)
 Set the Body Key Points Map vector. More...
 
void setSkeletonData (Json::Value skeletonData)
 Set the Skeleton Data JSON object. More...
 
void setSkeletonPoints3D_RS (std::vector< Point3D * > skeletonPoints3D_RS)
 Set the SkeletonPoints3D RS vector. More...
 
void setSkeletonPoints3D (std::vector< Point3D * > *skeletonPoints3D)
 Set the Skeleton Points3D pointer to vector. More...
 
void setConsistency (float consistency)
 Set the Consistency float value. More...
 
cv::Mat getRGB_Image (void)
 Get the RGB Image object. More...
 
cv::Mat getDistance_Image (void)
 Get the Distance Image object. More...
 
cv::Mat getSkeleton_Image (void)
 Get the Skeleton-only Image object. More...
 
std::vector< BodyKeyPointgetBodyKeyPoints (void)
 Get the Body Key Points vector. More...
 
Json::Value getSkeletonData (void)
 Get the Skeleton Data JSON object. More...
 
void calcBodyKeypoints (void)
 Retrieve BodyKeyPoints vector and the BodyKeyPoints Map bool vector from OpenPose output, while calculating corresponding Skeleton consistency. More...
 
void calcBodyEdges (void)
 Calculate Skeleton and invoke methods to draw it on the image according to OpenPose skeleton structure. More...
 
void drawLine (unsigned char start, unsigned char end)
 Draw a line that starts from a point and ends at another point. The points are specified as unsigned char, since is possible to access the instance BodyKeyPoints vector and get the point. More...
 
void drawCircle (cv::Point center)
 Draw a circle at the specified point as a parameter. More...
 
void deprojectSkeletonPoints3D (void)
 Deprojection operation takes a 2D pixel location on a stream's images, as well as a depth, specified in meters, and maps it to a 3D point location within the stream's associated 3D coordinate space. It is provided by the header-only function rs2_deproject_pixel_to_point(...). Intrinsic parameters can be retrieved from any rs2::video_stream_profile object via a call to get_intrinsics(). More...
 
void writeCoordinates (void)
 Write specific joint points' coordinates on the RGB image. More...
 

Private Attributes

cv::Mat rgb_Image
 RGB frame related to the frame in which the skeleton may appears. More...
 
cv::Mat distance_Image
 Distance frame related to the frame in which the skeleton may appears. More...
 
cv::Mat skeleton_Image
 A frame that contains only skeleton information such as green legs and red dots, representing connections between body joints. More...
 
std::vector< BodyKeyPointbodyKeyPoints
 A vector that contains each body joint retrieved from OpenPose. More...
 
std::vector< bool > bodyKeyPointsMap
 A vector that contains for each body joint retrieved from OpenPose a corresponding boolean that means if that body joint is a valuable and effective body joint or not. A body joint is a BodyKeyPoint with 3 conditions: "x" coordinate is different from zero, "y" coordinate is different from zero, and "confidence" is greater than 0.0. More...
 
Json::Value skeletonData
 Represents a Skeleton JSON value. This class is a discriminated union wrapper that can represent a: More...
 
std::vector< Point3D * > skeletonPoints3D_RS
 A vector that contains a set of pointers to Point3D. These points have coordinates whose domain is defined by RealSense Camera and project/deproject operations. More...
 
std::vector< Point3D * > * skeletonPoints3D
 A pointer to a vector that contains a set of pointers to Point3D. These points have coordinates in which the domain is defined from boundaries parameters specified in "CoordinateMappingManager.hpp". More...
 
float consistency
 Consistency is a value that represents how accurate is the OpenPose detection for this skeleton. As consequence, a really low consistency value indicates a skeleton that could not there be in the real scene (OpenPose misdetection). Otherwise, a low consistency value indicates a partial skeleton. This value is within the range [0; 1]. More...
 

Detailed Description

Skeleton class is used for skeleton creations and manipulations.

Skeleton class is a class that keeps track of the different frames where a specific skeleton may appears, its body key points, correspondent 3D space points, and other useful information skeleton-related.

Definition at line 37 of file Skeleton.hpp.

Constructor & Destructor Documentation

◆ Skeleton()

Skeleton::Skeleton ( cv::Mat &  rgbImage,
cv::Mat &  distanceImage,
cv::Mat &  skeletonImage,
Json::Value  skeletonData 
)

Construct a new Skeleton object.

Parameters
rgbImageRGB frame.
distanceImageDistance frame.
skeletonImageSkeleton frame.
skeletonDataJSON object of a single person detected by OpenPose.

Definition at line 187 of file Skeleton.cpp.

187 {
188 setRGB_Image(rgbImage);
189 setDistance_Image(dImage);
192 setConsistency(0.0);
193}
void setSkeleton_Image(cv::Mat &skeleton_Image)
Set the Skeleton-only Image object.
Definition: Skeleton.cpp:23
cv::Mat skeleton_Image
A frame that contains only skeleton information such as green legs and red dots, representing connect...
Definition: Skeleton.hpp:50
void setRGB_Image(cv::Mat &rgbImage)
Set the RGB Image object.
Definition: Skeleton.cpp:15
void setDistance_Image(cv::Mat &distanceImage)
Set the Distance Image object.
Definition: Skeleton.cpp:19
void setConsistency(float consistency)
Set the Consistency float value.
Definition: Skeleton.cpp:47
Json::Value skeletonData
Represents a Skeleton JSON value. This class is a discriminated union wrapper that can represent a:
Definition: Skeleton.hpp:78
void setSkeletonData(Json::Value skeletonData)
Set the Skeleton Data JSON object.
Definition: Skeleton.cpp:35

References setConsistency(), setDistance_Image(), setRGB_Image(), setSkeleton_Image(), setSkeletonData(), skeleton_Image, and skeletonData.

◆ ~Skeleton()

Skeleton::~Skeleton ( void  )

Destroy the Skeleton object.

Definition at line 195 of file Skeleton.cpp.

195 {
196 for (auto & point: * getSkeletonPoints3D()) delete point;
197 for (auto & point: getSkeletonPoints3D_RS()) delete point;
198 getSkeletonPoints3D()->clear();
199 if (getSkeletonPoints3D() != nullptr) delete getSkeletonPoints3D();
200 getSkeletonPoints3D_RS().clear();
201}
std::vector< Point3D * > * getSkeletonPoints3D(void)
Get the Skeleton Points3D vector's pointer.
Definition: Skeleton.cpp:218
std::vector< Point3D * > getSkeletonPoints3D_RS(void)
Get the SkeletonPoints3D RS vector.
Definition: Skeleton.cpp:214

References getSkeletonPoints3D(), and getSkeletonPoints3D_RS().

Member Function Documentation

◆ calcBodyEdges()

void Skeleton::calcBodyEdges ( void  )
private

Calculate Skeleton and invoke methods to draw it on the image according to OpenPose skeleton structure.

See also
drawLine (unsigned char start, unsigned char end)
drawCircle (cv::Point center)

Definition at line 99 of file Skeleton.cpp.

99 {
100 for (unsigned char i = 0; i < getBodyKeyPoints().size(); i++) {
101 if (i >= openPoseBodyKeyPointsNumber || (!getBodyKeyPointsMap().at(i))) continue;
102 drawCircle(cv::Point(getBodyKeyPoints().at(i).getX(), getBodyKeyPoints().at(i).getY()));
103
104 switch (i) {
105 case Nose ... RElbow:
106 case LShoulder ... LElbow:
107 case MidHip ... RKnee:
108 case LHip ... LKnee:
109 case LBigToe:
110 case RBigToe:
111 drawLine(i, i + 1);
112 break;
113 default:
114 break;
115 }
116 }
117
129}
@ LHeel
Definition: Skeleton.hpp:26
@ LEar
Definition: Skeleton.hpp:25
@ LAnkle
Definition: Skeleton.hpp:24
@ REar
Definition: Skeleton.hpp:25
@ Nose
Definition: Skeleton.hpp:22
@ RHeel
Definition: Skeleton.hpp:26
@ MidHip
Definition: Skeleton.hpp:23
@ RElbow
Definition: Skeleton.hpp:22
@ LBigToe
Definition: Skeleton.hpp:25
@ LKnee
Definition: Skeleton.hpp:24
@ Neck
Definition: Skeleton.hpp:22
@ LHip
Definition: Skeleton.hpp:24
@ REye
Definition: Skeleton.hpp:25
@ RAnkle
Definition: Skeleton.hpp:24
@ RKnee
Definition: Skeleton.hpp:24
@ LElbow
Definition: Skeleton.hpp:23
@ LEye
Definition: Skeleton.hpp:25
@ LShoulder
Definition: Skeleton.hpp:23
@ RBigToe
Definition: Skeleton.hpp:26
std::vector< BodyKeyPoint > getBodyKeyPoints(void)
Get the Body Key Points vector.
Definition: Skeleton.cpp:65
void drawCircle(cv::Point center)
Draw a circle at the specified point as a parameter.
Definition: Skeleton.cpp:140
std::vector< bool > getBodyKeyPointsMap(void)
Get the BodyKeyPoints Map vector.
Definition: Skeleton.cpp:69
void drawLine(unsigned char start, unsigned char end)
Draw a line that starts from a point and ends at another point. The points are specified as unsigned ...
Definition: Skeleton.cpp:131
static const short int openPoseBodyKeyPointsNumber
Definition: constants.hpp:68

References drawCircle(), drawLine(), getBodyKeyPoints(), getBodyKeyPointsMap(), LAnkle, LBigToe, LEar, LElbow, LEye, LHeel, LHip, LKnee, LShoulder, MidHip, Neck, Nose, openPoseBodyKeyPointsNumber, RAnkle, RBigToe, REar, RElbow, REye, RHeel, and RKnee.

Referenced by generateSkeleton().

◆ calcBodyKeypoints()

void Skeleton::calcBodyKeypoints ( void  )
private

Retrieve BodyKeyPoints vector and the BodyKeyPoints Map bool vector from OpenPose output, while calculating corresponding Skeleton consistency.

See also
OutputManager
OutputManagerJSON
FacadeSingleton

Definition at line 78 of file Skeleton.cpp.

78 {
79 int j = 0;
80 FacadeSingleton * facadeSingletonInstance = FacadeSingleton::getInstance();
81 if (facadeSingletonInstance == nullptr) CV_Error(FACADE_SINGLETON_NULLPTR_ERROR, FACADE_SINGLETON_NULLPTR_SCOPE);
82 OutputManagerJSON * outputManagerJSON = (OutputManagerJSON *) facadeSingletonInstance->getOutputManager();
83 for (Json::Value::ArrayIndex i = 0; i < skeletonData.size(); i++) {
85 outputManagerJSON->getValueAt((unsigned int) i, getSkeletonData()).asInt(),
86 outputManagerJSON->getValueAt((unsigned int) i + 1, getSkeletonData()).asInt(),
87 outputManagerJSON->getValueAt((unsigned int) i + 2, getSkeletonData()).asFloat())
88 );
89
90 bodyKeyPointsMap.push_back(bodyKeyPoints.at(j).getX() > 0 && bodyKeyPoints.at(j).getY() > 0 && bodyKeyPoints.at(j).getConfidence() > 0.00);
91 setConsistency(getConsistency() + bodyKeyPoints.at(j).getConfidence());
92 i += 2;
93 j += 1;
94 }
95
97}
BodyKeyPoint class is used for body keypoint creations and manipulations.
FacadeSingleton class is used as a single access point to a simplified interface.
OutputManager * getOutputManager(void)
Get the OutputManager pointer.
static FacadeSingleton * getInstance(void)
Get the unique class instance. This methods should be called in the following scenario: when we just ...
OutputManagerJSON class is a class that abstracts final JSON output-producing operations.
Json::Value getValueAt(std::string key, Json::Value currentJSON)
Utility method to get the value at a given key in a given JSON node.
std::vector< BodyKeyPoint > bodyKeyPoints
A vector that contains each body joint retrieved from OpenPose.
Definition: Skeleton.hpp:55
float getConsistency(void)
Get the Consistency float value.
Definition: Skeleton.cpp:222
std::vector< bool > bodyKeyPointsMap
A vector that contains for each body joint retrieved from OpenPose a corresponding boolean that means...
Definition: Skeleton.hpp:62
Json::Value getSkeletonData(void)
Get the Skeleton Data JSON object.
Definition: Skeleton.cpp:73
static const short int FACADE_SINGLETON_NULLPTR_ERROR
Definition: constants.hpp:32
static const char * FACADE_SINGLETON_NULLPTR_SCOPE
Definition: constants.hpp:33

References bodyKeyPoints, bodyKeyPointsMap, FACADE_SINGLETON_NULLPTR_ERROR, FACADE_SINGLETON_NULLPTR_SCOPE, getConsistency(), FacadeSingleton::getInstance(), FacadeSingleton::getOutputManager(), getSkeletonData(), OutputManagerJSON::getValueAt(), openPoseBodyKeyPointsNumber, setConsistency(), and skeletonData.

Referenced by generateSkeleton().

◆ deprojectSkeletonPoints3D()

void Skeleton::deprojectSkeletonPoints3D ( void  )
private

Deprojection operation takes a 2D pixel location on a stream's images, as well as a depth, specified in meters, and maps it to a 3D point location within the stream's associated 3D coordinate space. It is provided by the header-only function rs2_deproject_pixel_to_point(...). Intrinsic parameters can be retrieved from any rs2::video_stream_profile object via a call to get_intrinsics().

See also
https://dev.intelrealsense.com/docs/projection-in-intel-realsense-sdk-20
FacadeSingleton
RealSenseManager
get_color_intrin()

Definition at line 145 of file Skeleton.cpp.

145 {
146 FacadeSingleton * facadeSingletonInstance = FacadeSingleton::getInstance();
147 if (facadeSingletonInstance == nullptr) CV_Error(FACADE_SINGLETON_NULLPTR_ERROR, FACADE_SINGLETON_NULLPTR_SCOPE);
148 struct rs2_intrinsics color_intrin = facadeSingletonInstance->getCameraManager()->get_color_intrin();
149 for (unsigned char i = 0; i < getBodyKeyPoints().size(); i++) {
150 float * pixel = new (std::nothrow) float [2], * point = new (std::nothrow) float [3], distance = 0;
151 if (!pixel || !point) CV_Error(NEW_ALLOC_ERROR, NEW_ALLOC_SCOPE);
152
153 if (!getBodyKeyPointsMap().at(i)) {
154 point[0] = point[1] = point[2] = pixel[0] = pixel[1] = 0;
155 } else {
156 pixel[0] = getBodyKeyPoints().at(i).getX();
157 pixel[1] = getBodyKeyPoints().at(i).getY();
158 distance = getDistance_Image().at<float>(pixel[1], pixel[0]);
159 rs2_deproject_pixel_to_point(point, & color_intrin, pixel, distance);
160 }
161
162 Point3D * point3D = new Point3D(point[0], point[1], point[2], new BodyKeyPoint(0, 0, getBodyKeyPoints().at(i).getConfidence()));
163 skeletonPoints3D_RS.push_back(point3D);
164 delete [] pixel;
165 delete [] point;
166 }
167}
RealSenseManager * getCameraManager(void)
Get the RealSenseManager pointer.
Point3D class is used for Point3D creations and manipulations.
Definition: Point3D.hpp:23
struct rs2_intrinsics & get_color_intrin(void)
Get the color intrinsics object.
std::vector< Point3D * > skeletonPoints3D_RS
A vector that contains a set of pointers to Point3D. These points have coordinates whose domain is de...
Definition: Skeleton.hpp:85
cv::Mat getDistance_Image(void)
Get the Distance Image object.
Definition: Skeleton.cpp:57
static const short int NEW_ALLOC_ERROR
Definition: constants.hpp:47
static const char * NEW_ALLOC_SCOPE
Definition: constants.hpp:48

References FACADE_SINGLETON_NULLPTR_ERROR, FACADE_SINGLETON_NULLPTR_SCOPE, RealSenseManager::get_color_intrin(), getBodyKeyPoints(), getBodyKeyPointsMap(), FacadeSingleton::getCameraManager(), getDistance_Image(), FacadeSingleton::getInstance(), NEW_ALLOC_ERROR, NEW_ALLOC_SCOPE, and skeletonPoints3D_RS.

Referenced by generateSkeleton().

◆ drawCircle()

void Skeleton::drawCircle ( cv::Point  center)
private

Draw a circle at the specified point as a parameter.

Parameters
centerpoints where OpenCV will draw the circle.

Definition at line 140 of file Skeleton.cpp.

140 {
141 cv::circle(getRGB_Image(), center, 4, cv::Scalar(0, 0, 255), 8, cv::LINE_8, 0);
142 cv::circle(getSkeleton_Image(), center, 4, cv::Scalar(0, 0, 255), 8, cv::LINE_8, 0); // remove
143}
cv::Mat getRGB_Image(void)
Get the RGB Image object.
Definition: Skeleton.cpp:53
cv::Mat getSkeleton_Image(void)
Get the Skeleton-only Image object.
Definition: Skeleton.cpp:61

References getRGB_Image(), and getSkeleton_Image().

Referenced by calcBodyEdges().

◆ drawLine()

void Skeleton::drawLine ( unsigned char  start,
unsigned char  end 
)
private

Draw a line that starts from a point and ends at another point. The points are specified as unsigned char, since is possible to access the instance BodyKeyPoints vector and get the point.

Parameters
startstart point index in the BodyKeyPoints vector.
endend point index in the BodyKeyPoints vector.

Definition at line 131 of file Skeleton.cpp.

131 {
132 if (getBodyKeyPointsMap().at(start) && getBodyKeyPointsMap().at(end)) {
133 cv::line(getRGB_Image(), cv::Point(getBodyKeyPoints().at(start).getX(), getBodyKeyPoints().at(start).getY()),
134 cv::Point(getBodyKeyPoints().at(end).getX(), getBodyKeyPoints().at(end).getY()), cv::Scalar(0, 255, 0), 3, cv::LINE_8, 0);
135 cv::line(getSkeleton_Image(), cv::Point(getBodyKeyPoints().at(start).getX(), getBodyKeyPoints().at(start).getY()),
136 cv::Point(getBodyKeyPoints().at(end).getX(), getBodyKeyPoints().at(end).getY()), cv::Scalar(0, 255, 0), 3, cv::LINE_8, 0); // remove in future
137 }
138}

References getBodyKeyPoints(), getBodyKeyPointsMap(), getRGB_Image(), and getSkeleton_Image().

Referenced by calcBodyEdges().

◆ generateSkeleton()

void Skeleton::generateSkeleton ( void  )

A high-level method that abstracts all the internal structure and operations of the Skeleton class. It first calls calcBodyKeypoints(), then calcBodyEdges(), deprojectSkeletonPoints3D(), convert the coordinates in a specific format and then write them on the RGB image with writeCoordinates().

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

Definition at line 203 of file Skeleton.cpp.

203 {
207 FacadeSingleton * facadeSingletonInstance = FacadeSingleton::getInstance();
208 if (facadeSingletonInstance == nullptr) CV_Error(FACADE_SINGLETON_NULLPTR_ERROR, FACADE_SINGLETON_NULLPTR_SCOPE);
209 // xOrigin and zOrigin parameters are inverted as the built Unity world requires.
212}
static const float zOriginUnity
Definition: Room.hpp:30
static const float xOriginUnity
Definition: Room.hpp:29
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...
CoordinateMappingManager * getCoordinateMappingManager(void)
Get the CoordinateMappingManager pointer.
void calcBodyEdges(void)
Calculate Skeleton and invoke methods to draw it on the image according to OpenPose skeleton structur...
Definition: Skeleton.cpp:99
void deprojectSkeletonPoints3D(void)
Deprojection operation takes a 2D pixel location on a stream's images, as well as a depth,...
Definition: Skeleton.cpp:145
void writeCoordinates(void)
Write specific joint points' coordinates on the RGB image.
Definition: Skeleton.cpp:169
void calcBodyKeypoints(void)
Retrieve BodyKeyPoints vector and the BodyKeyPoints Map bool vector from OpenPose output,...
Definition: Skeleton.cpp:78
void setSkeletonPoints3D(std::vector< Point3D * > *skeletonPoints3D)
Set the Skeleton Points3D pointer to vector.
Definition: Skeleton.cpp:43

References calcBodyEdges(), calcBodyKeypoints(), deprojectSkeletonPoints3D(), FACADE_SINGLETON_NULLPTR_ERROR, FACADE_SINGLETON_NULLPTR_SCOPE, getBodyKeyPointsMap(), FacadeSingleton::getCoordinateMappingManager(), FacadeSingleton::getInstance(), getSkeletonPoints3D_RS(), CoordinateMappingManager::mapToMeters(), setSkeletonPoints3D(), writeCoordinates(), xOriginUnity, and zOriginUnity.

Referenced by OutputManagerJSON::createJSON().

◆ getBodyKeyPoints()

std::vector< BodyKeyPoint > Skeleton::getBodyKeyPoints ( void  )
private

Get the Body Key Points vector.

Returns
std::vector <BodyKeyPoint>

Definition at line 65 of file Skeleton.cpp.

65 {
66 return this->bodyKeyPoints;
67}

References bodyKeyPoints.

Referenced by calcBodyEdges(), deprojectSkeletonPoints3D(), drawLine(), and writeCoordinates().

◆ getBodyKeyPointsMap()

std::vector< bool > Skeleton::getBodyKeyPointsMap ( void  )

Get the BodyKeyPoints Map vector.

Returns
std::vector <bool>

Definition at line 69 of file Skeleton.cpp.

69 {
70 return this->bodyKeyPointsMap;
71}

References bodyKeyPointsMap.

Referenced by calcBodyEdges(), OutputManagerJSON::createJSON(), deprojectSkeletonPoints3D(), drawLine(), and generateSkeleton().

◆ getConsistency()

float Skeleton::getConsistency ( void  )

Get the Consistency float value.

Returns
float

Definition at line 222 of file Skeleton.cpp.

222 {
223 return this->consistency;
224}
float consistency
Consistency is a value that represents how accurate is the OpenPose detection for this skeleton....
Definition: Skeleton.hpp:99

References consistency.

Referenced by calcBodyKeypoints(), and OutputManagerJSON::createJSON().

◆ getDistance_Image()

cv::Mat Skeleton::getDistance_Image ( void  )
private

Get the Distance Image object.

Returns
cv::Mat

Definition at line 57 of file Skeleton.cpp.

57 {
58 return this->distance_Image;
59}
cv::Mat distance_Image
Distance frame related to the frame in which the skeleton may appears.
Definition: Skeleton.hpp:46

References distance_Image.

Referenced by deprojectSkeletonPoints3D().

◆ getRGB_Image()

cv::Mat Skeleton::getRGB_Image ( void  )
private

Get the RGB Image object.

Returns
cv::Mat

Definition at line 53 of file Skeleton.cpp.

53 {
54 return this->rgb_Image;
55}
cv::Mat rgb_Image
RGB frame related to the frame in which the skeleton may appears.
Definition: Skeleton.hpp:42

References rgb_Image.

Referenced by drawCircle(), drawLine(), and writeCoordinates().

◆ getSkeleton_Image()

cv::Mat Skeleton::getSkeleton_Image ( void  )
private

Get the Skeleton-only Image object.

Returns
cv::Mat

Definition at line 61 of file Skeleton.cpp.

61 {
62 return this->skeleton_Image;
63}

References skeleton_Image.

Referenced by drawCircle(), and drawLine().

◆ getSkeletonData()

Json::Value Skeleton::getSkeletonData ( void  )
private

Get the Skeleton Data JSON object.

Returns
Json::Value

Definition at line 73 of file Skeleton.cpp.

73 {
74 return this->skeletonData;
75}

References skeletonData.

Referenced by calcBodyKeypoints().

◆ getSkeletonPoints3D()

std::vector< Point3D * > * Skeleton::getSkeletonPoints3D ( void  )

Get the Skeleton Points3D vector's pointer.

Returns
std::vector <Point3D *>*

Definition at line 218 of file Skeleton.cpp.

218 {
219 return this->skeletonPoints3D;
220}
std::vector< Point3D * > * skeletonPoints3D
A pointer to a vector that contains a set of pointers to Point3D. These points have coordinates in wh...
Definition: Skeleton.hpp:93

References skeletonPoints3D.

Referenced by OutputManagerJSON::createJSON(), writeCoordinates(), and ~Skeleton().

◆ getSkeletonPoints3D_RS()

std::vector< Point3D * > Skeleton::getSkeletonPoints3D_RS ( void  )

Get the SkeletonPoints3D RS vector.

Returns
std::vector <Point3D *>

Definition at line 214 of file Skeleton.cpp.

214 {
215 return this->skeletonPoints3D_RS;
216}

References skeletonPoints3D_RS.

Referenced by generateSkeleton(), and ~Skeleton().

◆ setBodyKeyPoints()

void Skeleton::setBodyKeyPoints ( std::vector< BodyKeyPoint > &  bodyKeyPoints)
private

Set the Body Key Points vector.

Parameters
bodyKeyPoints

Definition at line 27 of file Skeleton.cpp.

27 {
29}

References bodyKeyPoints.

◆ setBodyKeyPointsMap()

void Skeleton::setBodyKeyPointsMap ( std::vector< bool > &  bodyKeyPointsMap)
private

Set the Body Key Points Map vector.

Parameters
bodyKeyPointsMap

Definition at line 31 of file Skeleton.cpp.

31 {
33}

References bodyKeyPointsMap.

◆ setConsistency()

void Skeleton::setConsistency ( float  consistency)
private

Set the Consistency float value.

Parameters
consistency

Definition at line 47 of file Skeleton.cpp.

47 {
49}

References consistency.

Referenced by calcBodyKeypoints(), and Skeleton().

◆ setDistance_Image()

void Skeleton::setDistance_Image ( cv::Mat &  distanceImage)
private

Set the Distance Image object.

Parameters
distanceImage

Definition at line 19 of file Skeleton.cpp.

19 {
20 this->distance_Image = myImage;
21}

References distance_Image.

Referenced by Skeleton().

◆ setRGB_Image()

void Skeleton::setRGB_Image ( cv::Mat &  rgbImage)
private

Set the RGB Image object.

Parameters
rgbImage

Definition at line 15 of file Skeleton.cpp.

15 {
16 this->rgb_Image = myImage;
17}

References rgb_Image.

Referenced by Skeleton().

◆ setSkeleton_Image()

void Skeleton::setSkeleton_Image ( cv::Mat &  skeleton_Image)
private

Set the Skeleton-only Image object.

Parameters
skeleton_Image

Definition at line 23 of file Skeleton.cpp.

23 {
24 this->skeleton_Image = myImage;
25}

References skeleton_Image.

Referenced by Skeleton().

◆ setSkeletonData()

void Skeleton::setSkeletonData ( Json::Value  skeletonData)
private

Set the Skeleton Data JSON object.

Parameters
skeletonData

Definition at line 35 of file Skeleton.cpp.

35 {
37}

References skeletonData.

Referenced by Skeleton().

◆ setSkeletonPoints3D()

void Skeleton::setSkeletonPoints3D ( std::vector< Point3D * > *  skeletonPoints3D)
private

Set the Skeleton Points3D pointer to vector.

Parameters
skeletonPoints3D

Definition at line 43 of file Skeleton.cpp.

43 {
45}

References skeletonPoints3D.

Referenced by generateSkeleton().

◆ setSkeletonPoints3D_RS()

void Skeleton::setSkeletonPoints3D_RS ( std::vector< Point3D * >  skeletonPoints3D_RS)
private

Set the SkeletonPoints3D RS vector.

Parameters
skeletonPoints3D_RS

Definition at line 39 of file Skeleton.cpp.

References skeletonPoints3D_RS.

◆ writeCoordinates()

void Skeleton::writeCoordinates ( void  )
private

Write specific joint points' coordinates on the RGB image.

See also
getSkeletonPoints3D()
getBodyKeyPoints()
Point

Definition at line 169 of file Skeleton.cpp.

169 {
170 for (unsigned char i = 0; i < getSkeletonPoints3D()->size(); i++) {
171 std::stringstream labelTextX, labelTextY, labelTextZ, labelTextConfidence;
172 labelTextX << getSkeletonPoints3D()->at(i)->getX();
173 labelTextY << getSkeletonPoints3D()->at(i)->getY();
174 labelTextZ << getSkeletonPoints3D()->at(i)->getZ();
175 labelTextConfidence << ((BodyKeyPoint *) getSkeletonPoints3D()->at(i)->getDecorated())->getConfidence();
176
177 if (i == 0 || i == 12 || i == 14) {
178 cv::putText(getRGB_Image(), labelTextX.str(), cv::Point(getBodyKeyPoints().at(i).getX() + 10, getBodyKeyPoints().at(i).getY() + 10), cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(255, 0, 0), 1, cv::LINE_8);
179 cv::putText(getRGB_Image(), labelTextY.str(), cv::Point(getBodyKeyPoints().at(i).getX() + 10, getBodyKeyPoints().at(i).getY() + 25), cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(255, 0, 0), 1, cv::LINE_8);
180 cv::putText(getRGB_Image(), labelTextZ.str(), cv::Point(getBodyKeyPoints().at(i).getX() + 10, getBodyKeyPoints().at(i).getY() + 40), cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(255, 0, 0), 1, cv::LINE_8);
181 }
182 }
183}

References getBodyKeyPoints(), getRGB_Image(), and getSkeletonPoints3D().

Referenced by generateSkeleton().

Member Data Documentation

◆ bodyKeyPoints

std::vector<BodyKeyPoint> Skeleton::bodyKeyPoints
private

A vector that contains each body joint retrieved from OpenPose.

See also
BodyKeyPoint

Definition at line 55 of file Skeleton.hpp.

Referenced by calcBodyKeypoints(), getBodyKeyPoints(), and setBodyKeyPoints().

◆ bodyKeyPointsMap

std::vector<bool> Skeleton::bodyKeyPointsMap
private

A vector that contains for each body joint retrieved from OpenPose a corresponding boolean that means if that body joint is a valuable and effective body joint or not. A body joint is a BodyKeyPoint with 3 conditions: "x" coordinate is different from zero, "y" coordinate is different from zero, and "confidence" is greater than 0.0.

See also
BodyKeyPoint

Definition at line 62 of file Skeleton.hpp.

Referenced by calcBodyKeypoints(), getBodyKeyPointsMap(), and setBodyKeyPointsMap().

◆ consistency

float Skeleton::consistency
private

Consistency is a value that represents how accurate is the OpenPose detection for this skeleton. As consequence, a really low consistency value indicates a skeleton that could not there be in the real scene (OpenPose misdetection). Otherwise, a low consistency value indicates a partial skeleton. This value is within the range [0; 1].

Definition at line 99 of file Skeleton.hpp.

Referenced by getConsistency(), and setConsistency().

◆ distance_Image

cv::Mat Skeleton::distance_Image
private

Distance frame related to the frame in which the skeleton may appears.

Definition at line 46 of file Skeleton.hpp.

Referenced by getDistance_Image(), and setDistance_Image().

◆ rgb_Image

cv::Mat Skeleton::rgb_Image
private

RGB frame related to the frame in which the skeleton may appears.

Definition at line 42 of file Skeleton.hpp.

Referenced by getRGB_Image(), and setRGB_Image().

◆ skeleton_Image

cv::Mat Skeleton::skeleton_Image
private

A frame that contains only skeleton information such as green legs and red dots, representing connections between body joints.

Definition at line 50 of file Skeleton.hpp.

Referenced by getSkeleton_Image(), setSkeleton_Image(), and Skeleton().

◆ skeletonData

Json::Value Skeleton::skeletonData
private

Represents a Skeleton JSON value. This class is a discriminated union wrapper that can represent a:

  • signed integer [range: Value::minInt - Value::maxInt]
  • unsigned integer (range: 0 - Value::maxUInt)
  • double
  • UTF-8 string
  • boolean
  • 'null'
  • an ordered list of Value
  • collection of name/value pairs (javascript object)

In this case this JSON Value contains all informations about body joints retrieved from OpenPose JSON output.

See also
https://github.com/open-source-parsers/jsoncpp
BodyKeyPoint

Definition at line 78 of file Skeleton.hpp.

Referenced by calcBodyKeypoints(), getSkeletonData(), setSkeletonData(), and Skeleton().

◆ skeletonPoints3D

std::vector<Point3D *>* Skeleton::skeletonPoints3D
private

A pointer to a vector that contains a set of pointers to Point3D. These points have coordinates in which the domain is defined from boundaries parameters specified in "CoordinateMappingManager.hpp".

See also
https://dev.intelrealsense.com/docs/projection-in-intel-realsense-sdk-20
Point3D
constants.hpp

Definition at line 93 of file Skeleton.hpp.

Referenced by getSkeletonPoints3D(), and setSkeletonPoints3D().

◆ skeletonPoints3D_RS

std::vector<Point3D *> Skeleton::skeletonPoints3D_RS
private

A vector that contains a set of pointers to Point3D. These points have coordinates whose domain is defined by RealSense Camera and project/deproject operations.

See also
https://dev.intelrealsense.com/docs/projection-in-intel-realsense-sdk-20
Point3D

Definition at line 85 of file Skeleton.hpp.

Referenced by deprojectSkeletonPoints3D(), getSkeletonPoints3D_RS(), and setSkeletonPoints3D_RS().


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