AI Watch A1
Multi-person 3D skeleton detection using Intel RealSense and OpenPose with Kafka support.
Skeleton.hpp
Go to the documentation of this file.
1//
2// Skeleton.hpp
3// AI Watch A1
4//
5// Created by Denny Caruso on 17/07/22.
6//
7
8// License: Apache 2.0. See LICENSE file in root directory.
9// Copyright(c) 2022. All Rights Reserved.
10
11#ifndef Skeleton_h
12#define Skeleton_h
13
15
16
17
22enum BodyKeypoint { Nose = 0, Neck = 1, RShoulder = 2, RElbow = 3, RWrist = 4,
23 LShoulder = 5, LElbow = 6, LWrist = 7, MidHip = 8, RHip = 9,
24 RKnee = 10, RAnkle = 11, LHip = 12, LKnee = 13, LAnkle = 14,
25 REye = 15, LEye = 16, REar = 17, LEar = 18, LBigToe = 19,
26 LSmallToe = 20, LHeel = 21, RBigToe = 22, RSmallToe = 23, RHeel = 24,
27 Background = 25
28 };
29
30
31
37class Skeleton {
38private:
42 cv::Mat rgb_Image;
50 cv::Mat skeleton_Image; // remove
55 std::vector <BodyKeyPoint> bodyKeyPoints;
62 std::vector <bool> bodyKeyPointsMap;
78 Json::Value skeletonData;
85 std::vector <Point3D *> skeletonPoints3D_RS;
93 std::vector <Point3D *> * skeletonPoints3D;
100
101
102
107 void setRGB_Image (cv::Mat & rgbImage);
112 void setDistance_Image (cv::Mat & distanceImage);
117 void setSkeleton_Image (cv::Mat & skeleton_Image);
122 void setBodyKeyPoints (std::vector <BodyKeyPoint> & bodyKeyPoints);
127 void setBodyKeyPointsMap (std::vector <bool> & bodyKeyPointsMap);
132 void setSkeletonData (Json::Value skeletonData);
137 void setSkeletonPoints3D_RS (std::vector <Point3D *> skeletonPoints3D_RS);
142 void setSkeletonPoints3D (std::vector <Point3D *> * skeletonPoints3D);
147 void setConsistency (float consistency);
148
149
150
155 cv::Mat getRGB_Image (void);
160 cv::Mat getDistance_Image (void);
165 cv::Mat getSkeleton_Image (void);
170 std::vector <BodyKeyPoint> getBodyKeyPoints (void);
175 Json::Value getSkeletonData (void);
176
177
178
186 void calcBodyKeypoints (void);
193 void calcBodyEdges (void);
200 void drawLine (unsigned char start, unsigned char end);
205 void drawCircle (cv::Point center);
216 void deprojectSkeletonPoints3D (void);
223 void writeCoordinates (void);
224public:
232 Skeleton (cv::Mat & rgbImage, cv::Mat & distanceImage, cv::Mat & skeletonImage, Json::Value skeletonData);
236 ~Skeleton (void);
243 void generateSkeleton (void);
248 std::vector <bool> getBodyKeyPointsMap (void);
253 std::vector <Point3D *> getSkeletonPoints3D_RS (void);
258 std::vector <Point3D *> * getSkeletonPoints3D (void);
263 float getConsistency (void);
264};
265
266#endif /* Skeleton_h */
BodyKeypoint
Enumeration for body keypoints produced from OpenPose.
Definition: Skeleton.hpp:22
@ 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
@ LSmallToe
Definition: Skeleton.hpp:26
@ Background
Definition: Skeleton.hpp:27
@ MidHip
Definition: Skeleton.hpp:23
@ RElbow
Definition: Skeleton.hpp:22
@ RShoulder
Definition: Skeleton.hpp:22
@ LBigToe
Definition: Skeleton.hpp:25
@ RSmallToe
Definition: Skeleton.hpp:26
@ LKnee
Definition: Skeleton.hpp:24
@ LWrist
Definition: Skeleton.hpp:23
@ Neck
Definition: Skeleton.hpp:22
@ RHip
Definition: Skeleton.hpp:23
@ 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
@ RWrist
Definition: Skeleton.hpp:22
Skeleton class is used for skeleton creations and manipulations.
Definition: Skeleton.hpp:37
cv::Mat getRGB_Image(void)
Get the RGB Image object.
Definition: Skeleton.cpp:53
void setSkeletonPoints3D_RS(std::vector< Point3D * > skeletonPoints3D_RS)
Set the SkeletonPoints3D RS vector.
Definition: Skeleton.cpp:39
std::vector< BodyKeyPoint > getBodyKeyPoints(void)
Get the Body Key Points vector.
Definition: Skeleton.cpp:65
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
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 setBodyKeyPoints(std::vector< BodyKeyPoint > &bodyKeyPoints)
Set the Body Key Points vector.
Definition: Skeleton.cpp:27
~Skeleton(void)
Destroy the Skeleton object.
Definition: Skeleton.cpp:195
std::vector< Point3D * > * getSkeletonPoints3D(void)
Get the Skeleton Points3D vector's pointer.
Definition: Skeleton.cpp:218
void setBodyKeyPointsMap(std::vector< bool > &bodyKeyPointsMap)
Set the Body Key Points Map vector.
Definition: Skeleton.cpp:31
void setDistance_Image(cv::Mat &distanceImage)
Set the Distance Image object.
Definition: Skeleton.cpp:19
void drawCircle(cv::Point center)
Draw a circle at the specified point as a parameter.
Definition: Skeleton.cpp:140
void setConsistency(float consistency)
Set the Consistency float value.
Definition: Skeleton.cpp:47
std::vector< bool > bodyKeyPointsMap
A vector that contains for each body joint retrieved from OpenPose a corresponding boolean that means...
Definition: Skeleton.hpp:62
std::vector< bool > getBodyKeyPointsMap(void)
Get the BodyKeyPoints Map vector.
Definition: Skeleton.cpp:69
void calcBodyEdges(void)
Calculate Skeleton and invoke methods to draw it on the image according to OpenPose skeleton structur...
Definition: Skeleton.cpp:99
Json::Value getSkeletonData(void)
Get the Skeleton Data JSON object.
Definition: Skeleton.cpp:73
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
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
void calcBodyKeypoints(void)
Retrieve BodyKeyPoints vector and the BodyKeyPoints Map bool vector from OpenPose output,...
Definition: Skeleton.cpp:78
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
Skeleton(cv::Mat &rgbImage, cv::Mat &distanceImage, cv::Mat &skeletonImage, Json::Value skeletonData)
Construct a new Skeleton object.
Definition: Skeleton.cpp:187
cv::Mat rgb_Image
RGB frame related to the frame in which the skeleton may appears.
Definition: Skeleton.hpp:42
void setSkeletonPoints3D(std::vector< Point3D * > *skeletonPoints3D)
Set the Skeleton Points3D pointer to vector.
Definition: Skeleton.cpp:43
Json::Value skeletonData
Represents a Skeleton JSON value. This class is a discriminated union wrapper that can represent a:
Definition: Skeleton.hpp:78
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
void setSkeletonData(Json::Value skeletonData)
Set the Skeleton Data JSON object.
Definition: Skeleton.cpp:35
cv::Mat distance_Image
Distance frame related to the frame in which the skeleton may appears.
Definition: Skeleton.hpp:46
float consistency
Consistency is a value that represents how accurate is the OpenPose detection for this skeleton....
Definition: Skeleton.hpp:99
void generateSkeleton(void)
A high-level method that abstracts all the internal structure and operations of the Skeleton class....
Definition: Skeleton.cpp:203
cv::Mat getSkeleton_Image(void)
Get the Skeleton-only Image object.
Definition: Skeleton.cpp:61
cv::Mat getDistance_Image(void)
Get the Distance Image object.
Definition: Skeleton.cpp:57
std::vector< Point3D * > getSkeletonPoints3D_RS(void)
Get the SkeletonPoints3D RS vector.
Definition: Skeleton.cpp:214