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

FacadeSingleton class is used as a single access point to a simplified interface. More...

#include <FacadeSingleton.hpp>

Public Member Functions

 FacadeSingleton (FacadeSingleton &other)=delete
 Disabling the possibility to clone the Singleton object. Singletons should not be cloneable. More...
 
void operator= (const FacadeSingleton &)=delete
 Disabling the possibility to assign a Singleton object. Singletons should not be assignable. More...
 
RealSenseManagergetCameraManager (void)
 Get the RealSenseManager pointer. More...
 
OutputManagergetOutputManager (void)
 Get the OutputManager pointer. More...
 
OpenCV_ManagergetOpenCV_Manager (void)
 Get the OpenCV_Manager pointer. More...
 
UsageManagergetUsageManager (void)
 Get the UsageManager pointer. More...
 
CoordinateMappingManagergetCoordinateMappingManager (void)
 Get the CoordinateMappingManager pointer. More...
 
ImageManagergetImageManager (void)
 Get the ImageManager pointer. More...
 
KafkaManagergetKafkaManager (void)
 Get the KafkaManager pointer. More...
 
void startEnvironment (rs2::pipeline &pipelineStream, struct rs2_intrinsics &color_intrin, float *scale, unsigned short int resX, unsigned short int resY, const char *destinationKafkaTopic, Room room)
 This method is useful to invoke at the boot of the program where we want to initialize the different mangers, start the camera and set up the related environment. More...
 
void getVideoFrames (unsigned int user_nFrame, rs2::pipeline &pipelineStream, float scale, const unsigned short int framesToSkip)
 Get user_nFrame video frames from the pipeline by applying a specific scaling factor. More...
 
void getVideoBodyKeyPoints (int *argc, char ***argv)
 Start and execute OpenPose submodule. More...
 
void showSkeletons (unsigned int user_nFrame, const float skeletonThreshold)
 Retrieve OpenPose's output, convert it to RealSense coordinate's space, show results and save them. More...
 
void sendData (unsigned int user_nFrame)
 Send saved results by getVideoBodyKeyPoints(...) via Kafka using the KafkaManager. More...
 
void cleanBuildFolder (void)
 This method cleans the build folder, in order to prepare the environment for the next loop iteration. It does this by deleting all images and JSON files produced during the current loop iteration. More...
 

Static Public Member Functions

static FacadeSingletongetInstance (const int expected_argc, const char *expectedUsageMessage)
 Get the unique class instance, given input parameters. This method should be called the first time when we want to create a reference to the object of this class. More...
 
static FacadeSingletongetInstance (void)
 Get the unique class instance. This methods should be called in the following scenario: when we just want to retrieve the reference to the object of this class. More...
 

Protected Member Functions

void setCameraManager (RealSenseManager *cameraManager)
 Set the RealSenseManager pointer. More...
 
void setOutputManager (OutputManager *outputManager)
 Set the OutputManager pointer. More...
 
void setOpenCV_Manager (OpenCV_Manager *openCV_Manager)
 Set the OpenCV_Manager pointer. More...
 
void setUsageManager (UsageManager *usageManager)
 Set the UsageManager pointer. More...
 
void setCoordinateMappingManager (CoordinateMappingManager *coordinateMappingManager)
 Set the CoordinateMappingManager pointer. More...
 
void setImageManager (ImageManager *imageManager)
 Set the ImageManager pointer. More...
 
void setKafkaManager (KafkaManager *kafkaManager)
 Set the KafkaManager pointer. More...
 

Private Member Functions

 FacadeSingleton (const int expected_argc=0, const char *expectedUsageMessage=nullptr)
 Construct a new Facade Singleton object. More...
 
 ~FacadeSingleton (void)
 Destroy the Facade Singleton object. More...
 

Private Attributes

RealSenseManagercameraManager
 A pointer to RealSenseManager object. A RealSenseManager object is responsible for handling the camera setup, frames acquisition and frames post-processing. More...
 
OutputManageroutputManager
 A pointer to OutputManager object. An OutputManager object is responsible for handling the final output generation to send via Kafka later on. More...
 
OpenCV_ManageropenCV_Manager
 A pointer to OpenCV_Manager object. An OpenCV_Manager object is responsible for converting camera frame to an OpenCV matrix and booting building skeletons into the image. More...
 
UsageManagerusageManager
 A pointer to UsageManager object. An UsageManager object is responsible for checking if the parameters read from configuration file are fine, correct and valid. Furthermore this class provides methods to access this parameters. More...
 
CoordinateMappingManagercoordinateMappingManager
 A pointer to CoordinateMappingManager object. A CoordinateMappingManager object is responsible for transforming one coordinate range values' space into another one. For instance, it can transform a RealSense coordinates space to meters or to Unity coordinates. In both cases, there are several parameters to set up regarding the scene and the room where the camera is installed. More...
 
ImageManagerimageManager
 A pointer to CoordinateMappingManager object. A CoordinateMappingManager object is responsible for broad tasks such as loading, saving, and showing images, as well as releasing the memory allocated for those images. More...
 
KafkaManagerkafkaManager
 A pointer to KafkaManager object. A KafkaManager object is responsible for sending previously produced JSON output via Kafka. More...
 

Static Private Attributes

static FacadeSingletonsharedInstance { nullptr }
 The field for storing the singleton instance. More...
 
static std::mutex singletonMutex
 Mutex for thread-safe access. More...
 

Detailed Description

FacadeSingleton class is used as a single access point to a simplified interface.

A facade is a structural design pattern that provides a simplified interface to a library, a framework, or any other complex set of classes. A Facade class can often be transformed into a Singleton since a single facade object is sufficient in most cases. Since we need just one access point to this class and since the internal submodules are complex, a class FacadeSingleton implements both behaviors.

Definition at line 44 of file FacadeSingleton.hpp.

Constructor & Destructor Documentation

◆ FacadeSingleton() [1/2]

FacadeSingleton::FacadeSingleton ( const int  expected_argc = 0,
const char *  expectedUsageMessage = nullptr 
)
private

Construct a new Facade Singleton object.

Parameters
expected_argcthe number of parameters that the program expects to find in the configuration file.
expectedUsageMessagea simple message that lets the user understand how to properly run the executable.

Definition at line 20 of file FacadeSingleton.cpp.

20 {
21 std::ifstream inputFile(CONF_FILE_PATH);
22 std::string singleLineConfigurationFile;
23
24 int * fileArgc = new (std::nothrow) int;
25 * fileArgc = (int) totalFileParameters;
26 char *** fileArgv = new (std::nothrow) char **;
27 * fileArgv = new (std::nothrow) char *[totalFileParameters];
28 unsigned char rowCounter = 0;
29
30 if (!fileArgc || !fileArgv || ! * fileArgv) CV_Error(NEW_ALLOC_ERROR, NEW_ALLOC_SCOPE);
31 // Read usage's configuration parameters from file
32 while (inputFile >> singleLineConfigurationFile) {
33 (* fileArgv)[rowCounter] = new (std::nothrow) char [(unsigned int) singleLineConfigurationFile.size()];
34 if (!(* fileArgv)[rowCounter]) CV_Error(NEW_ALLOC_ERROR, NEW_ALLOC_SCOPE);
35 strcpy((* fileArgv)[rowCounter], singleLineConfigurationFile.c_str());
36 rowCounter++;
37 }
38
40}
void setUsageManager(UsageManager *usageManager)
Set the UsageManager pointer.
static UsageManager * getInstance(void)
Get the unique class instance. This methods should be called in the following scenario: when we just ...
static const char * CONF_FILE_PATH
Definition: constants.hpp:59
static const short int totalFileParameters
Definition: constants.hpp:66
static const short int NEW_ALLOC_ERROR
Definition: constants.hpp:47
static const char * NEW_ALLOC_SCOPE
Definition: constants.hpp:48
const char * expectedUsageMessage
Definition: main.cpp:214
const int expected_argc
Definition: main.cpp:213

References CONF_FILE_PATH, expected_argc, expectedUsageMessage, UsageManager::getInstance(), NEW_ALLOC_ERROR, NEW_ALLOC_SCOPE, setUsageManager(), and totalFileParameters.

Referenced by getInstance().

◆ ~FacadeSingleton()

FacadeSingleton::~FacadeSingleton ( void  )
private

Destroy the Facade Singleton object.

Definition at line 42 of file FacadeSingleton.cpp.

42 {
43 delete getCameraManager();
44 delete getOutputManager();
45 delete getOpenCV_Manager();
46 delete getUsageManager();
48 delete getImageManager();
49 delete getKafkaManager();
50 delete sharedInstance;
51}
CoordinateMappingManager * getCoordinateMappingManager(void)
Get the CoordinateMappingManager pointer.
OpenCV_Manager * getOpenCV_Manager(void)
Get the OpenCV_Manager pointer.
ImageManager * getImageManager(void)
Get the ImageManager pointer.
static FacadeSingleton * sharedInstance
The field for storing the singleton instance.
OutputManager * getOutputManager(void)
Get the OutputManager pointer.
UsageManager * getUsageManager(void)
Get the UsageManager pointer.
RealSenseManager * getCameraManager(void)
Get the RealSenseManager pointer.
KafkaManager * getKafkaManager(void)
Get the KafkaManager pointer.

References getCameraManager(), getCoordinateMappingManager(), getImageManager(), getKafkaManager(), getOpenCV_Manager(), getOutputManager(), getUsageManager(), and sharedInstance.

◆ FacadeSingleton() [2/2]

FacadeSingleton::FacadeSingleton ( FacadeSingleton other)
delete

Disabling the possibility to clone the Singleton object. Singletons should not be cloneable.

Parameters
other

Member Function Documentation

◆ cleanBuildFolder()

void FacadeSingleton::cleanBuildFolder ( void  )

This method cleans the build folder, in order to prepare the environment for the next loop iteration. It does this by deleting all images and JSON files produced during the current loop iteration.

Definition at line 166 of file FacadeSingleton.cpp.

166 {
167 SystemCommand * cleanCommand = new CleanCommand();
168 cleanCommand->executeCommand(getUsageManager()->get_argc(), getUsageManager()->get_argv());
169 delete cleanCommand;
170}
The CleanCommand class is a class that implements a command to clean the build folder by deleting old...
SystemCommand class is a class that represents a command given by the program to the system.
void executeCommand(int *argc, char ***argv)
This method is responsible for executing commands on the system based on the filled command string....

References SystemCommand::executeCommand(), and getUsageManager().

Referenced by main(), and startEnvironment().

◆ getCameraManager()

RealSenseManager * FacadeSingleton::getCameraManager ( void  )

Get the RealSenseManager pointer.

Returns
RealSenseManager *
See also
RealSenseManager.hpp

Definition at line 95 of file FacadeSingleton.cpp.

95 {
96 return this->cameraManager;
97}
RealSenseManager * cameraManager
A pointer to RealSenseManager object. A RealSenseManager object is responsible for handling the camer...

References cameraManager.

Referenced by Skeleton::deprojectSkeletonPoints3D(), OpenCV_Manager::getVideoFramesCV(), sendData(), OpenCV_Manager::showSkeletonsCV(), startEnvironment(), and ~FacadeSingleton().

◆ getCoordinateMappingManager()

CoordinateMappingManager * FacadeSingleton::getCoordinateMappingManager ( void  )

Get the CoordinateMappingManager pointer.

Returns
CoordinateMappingManager *
See also
constants.hpp
CoordinateMappingManager.hpp

Definition at line 111 of file FacadeSingleton.cpp.

111 {
112 return this->coordinateMappingManager;
113}
CoordinateMappingManager * coordinateMappingManager
A pointer to CoordinateMappingManager object. A CoordinateMappingManager object is responsible for tr...

References coordinateMappingManager.

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

◆ getImageManager()

ImageManager * FacadeSingleton::getImageManager ( void  )

Get the ImageManager pointer.

Returns
ImageManager *
See also
ImageManager.hpp

Definition at line 115 of file FacadeSingleton.cpp.

115 {
116 return this->imageManager;
117}
ImageManager * imageManager
A pointer to CoordinateMappingManager object. A CoordinateMappingManager object is responsible for br...

References imageManager.

Referenced by OpenCV_Manager::getVideoFramesCV(), OpenCV_Manager::showSkeletonsCV(), and ~FacadeSingleton().

◆ getInstance() [1/2]

FacadeSingleton * FacadeSingleton::getInstance ( const int  expected_argc,
const char *  expectedUsageMessage 
)
static

Get the unique class instance, given input parameters. This method should be called the first time when we want to create a reference to the object of this class.

Parameters
expected_argcthe number of parameters that the program expects to find in the configuration file.
expectedUsageMessagea simple message that lets the user understand how to properly run the
Returns
FacadeSingleton *

Definition at line 83 of file FacadeSingleton.cpp.

83 {
84 std::lock_guard <std::mutex> lock(singletonMutex);
86 return sharedInstance;
87}
static std::mutex singletonMutex
Mutex for thread-safe access.
FacadeSingleton(const int expected_argc=0, const char *expectedUsageMessage=nullptr)
Construct a new Facade Singleton object.

References expected_argc, expectedUsageMessage, FacadeSingleton(), sharedInstance, and singletonMutex.

◆ getInstance() [2/2]

FacadeSingleton * FacadeSingleton::getInstance ( void  )
static

Get the unique class instance. This methods should be called in the following scenario: when we just want to retrieve the reference to the object of this class.

Returns
FacadeSingleton *

Definition at line 89 of file FacadeSingleton.cpp.

89 {
90 std::lock_guard <std::mutex> lock(singletonMutex);
91 if (sharedInstance == nullptr) return nullptr;
92 return sharedInstance;
93}

References sharedInstance, and singletonMutex.

Referenced by Skeleton::calcBodyKeypoints(), Skeleton::deprojectSkeletonPoints3D(), Skeleton::generateSkeleton(), OpenCV_Manager::getVideoFramesCV(), main(), and OpenCV_Manager::showSkeletonsCV().

◆ getKafkaManager()

KafkaManager * FacadeSingleton::getKafkaManager ( void  )

Get the KafkaManager pointer.

Returns
KafkaManager *
See also
KafkaManager.hpp

Definition at line 119 of file FacadeSingleton.cpp.

119 {
120 return this->kafkaManager;
121}
KafkaManager * kafkaManager
A pointer to KafkaManager object. A KafkaManager object is responsible for sending previously produce...

References kafkaManager.

Referenced by sendData(), and ~FacadeSingleton().

◆ getOpenCV_Manager()

OpenCV_Manager * FacadeSingleton::getOpenCV_Manager ( void  )

Get the OpenCV_Manager pointer.

Returns
OpenCV_Manager *
See also
OpenCV_Manager.hpp

Definition at line 103 of file FacadeSingleton.cpp.

103 {
104 return this->openCV_Manager;
105}
OpenCV_Manager * openCV_Manager
A pointer to OpenCV_Manager object. An OpenCV_Manager object is responsible for converting camera fra...

References openCV_Manager.

Referenced by getVideoFrames(), showSkeletons(), and ~FacadeSingleton().

◆ getOutputManager()

OutputManager * FacadeSingleton::getOutputManager ( void  )

Get the OutputManager pointer.

Returns
OutputManager *
See also
OutputManager.hpp

Definition at line 99 of file FacadeSingleton.cpp.

99 {
100 return this->outputManager;
101}
OutputManager * outputManager
A pointer to OutputManager object. An OutputManager object is responsible for handling the final outp...

References outputManager.

Referenced by Skeleton::calcBodyKeypoints(), sendData(), OpenCV_Manager::showSkeletonsCV(), and ~FacadeSingleton().

◆ getUsageManager()

UsageManager * FacadeSingleton::getUsageManager ( void  )

Get the UsageManager pointer.

Returns
UsageManager *
See also
UsageManager.hpp

Definition at line 107 of file FacadeSingleton.cpp.

107 {
108 return this->usageManager;
109}
UsageManager * usageManager
A pointer to UsageManager object. An UsageManager object is responsible for checking if the parameter...

References usageManager.

Referenced by cleanBuildFolder(), sendData(), OpenCV_Manager::showSkeletonsCV(), and ~FacadeSingleton().

◆ getVideoBodyKeyPoints()

void FacadeSingleton::getVideoBodyKeyPoints ( int *  argc,
char ***  argv 
)

Start and execute OpenPose submodule.

Parameters
argcarguments' number specified on launch (from main).
argvarguments' specified on launch (from main).
See also
https://cmu-perceptual-computing-lab.github.io/openpose/web/html/doc/md_doc_00_index.html

Definition at line 139 of file FacadeSingleton.cpp.

139 {
140 SystemCommand * openPoseCommand = new OpenPoseCommand();
141 openPoseCommand->executeCommand(argc, argv);
142 delete openPoseCommand;
143}
The OpenPoseCommand class is a class that implements a command to start and run OpenPose.

References SystemCommand::executeCommand().

Referenced by main().

◆ getVideoFrames()

void FacadeSingleton::getVideoFrames ( unsigned int  user_nFrame,
rs2::pipeline &  pipelineStream,
float  scale,
const unsigned short int  framesToSkip 
)

Get user_nFrame video frames from the pipeline by applying a specific scaling factor.

Parameters
user_nFrameframe's number to capture according to user choice.
pipelineStreamThe pipeline simplifies the user interaction with the device and computer vision processing modules. The class abstracts the camera configuration and streaming, and the vision modules triggering and threading. It lets the application focus on the computer vision output of the modules, or the device output data. The pipeline can manage computer vision modules, which are implemented as a processing block. The pipeline is the consumer of the processing block interface, while the application consumes the computer vision interface.
scaleScaling factor.
framesToSkipFrames' number to skip in order to ignore a certain amount of frames and extend the recording interval. A '0' value means 'capture each frame'.
See also
https://dev.intelrealsense.com/docs/docs-get-started
getVideoFramesCV(unsigned int user_nFrame, rs2::pipeline & pipelineStream, float scale)
getVideoFramesRS(unsigned int user_nFrame, rs2::pipeline & pipelineStream, rs2::depth_frame & depthFrame, rs2::frame & colorFrame, rs2::frame & colorizedDepthFrame)

Definition at line 135 of file FacadeSingleton.cpp.

135 {
136 getOpenCV_Manager()->getVideoFramesCV(user_nFrame, pipelineStream, scale, framesToSkip);
137}
void getVideoFramesCV(unsigned int user_nFrame, rs2::pipeline &pipelineStream, float scale, const unsigned short int framesToSkip)
Get user_nFrame video frames from the pipeline by applying a specific scaling factor.

References getOpenCV_Manager(), and OpenCV_Manager::getVideoFramesCV().

Referenced by main().

◆ operator=()

void FacadeSingleton::operator= ( const FacadeSingleton )
delete

Disabling the possibility to assign a Singleton object. Singletons should not be assignable.

◆ sendData()

void FacadeSingleton::sendData ( unsigned int  user_nFrame)

Send saved results by getVideoBodyKeyPoints(...) via Kafka using the KafkaManager.

Parameters
user_nFrameframe's number to capture according to user choice.
See also
https://kafka.apache.org/documentation/
sendData(const char * key, Json::Value root)

Definition at line 149 of file FacadeSingleton.cpp.

149 {
150 char ** argv = * FacadeSingleton::getUsageManager()->get_argv(), * outputFolder = argv[outputFolderOffset];
151 unsigned int frameID = FacadeSingleton::getCameraManager()->getFrameID(), currentImageID;
153
154 for (unsigned int nFrame = 0; nFrame < user_nFrame; nFrame++) {
155 Json::Value currentJSON;
156 std::stringstream outputJsonFilePath;
157 currentImageID = frameID - user_nFrame + nFrame;
158 outputJsonFilePath << outputFolder << "movement/frame" << currentImageID << "_skeletonsPoints3D.json";
159 if (myOutputManagerJSON->loadJSON(outputJsonFilePath.str(), currentJSON)) {
160 std::string key = std::to_string(currentImageID);
161 FacadeSingleton::getKafkaManager()->sendData(key.c_str(), currentJSON);
162 }
163 }
164}
void sendData(const char *key, Json::Value root)
Send data contained in root via Kafka with ID equal to key.
OutputManagerJSON class is a class that abstracts final JSON output-producing operations.
bool loadJSON(std::string filePathJSON, Json::Value &currentJSON)
Loads a JSON file and returns it as a reference. The JSON file path on disk is given.
unsigned int getFrameID(void)
Get the current frame ID value.
char *** get_argv(void)
Get the argv's pointer.
static const short int outputFolderOffset
Definition: constants.hpp:65

References UsageManager::get_argv(), getCameraManager(), RealSenseManager::getFrameID(), getKafkaManager(), getOutputManager(), getUsageManager(), OutputManagerJSON::loadJSON(), outputFolderOffset, and KafkaManager::sendData().

Referenced by main().

◆ setCameraManager()

void FacadeSingleton::setCameraManager ( RealSenseManager cameraManager)
protected

Set the RealSenseManager pointer.

Parameters
cameraManagerpointer to a RealSenseManager object.
See also
RealSenseManager.hpp

Definition at line 53 of file FacadeSingleton.cpp.

53 {
54 this->cameraManager = cameraManager;
55}

References cameraManager.

Referenced by startEnvironment().

◆ setCoordinateMappingManager()

void FacadeSingleton::setCoordinateMappingManager ( CoordinateMappingManager coordinateMappingManager)
protected

Set the CoordinateMappingManager pointer.

Parameters
coordinateMappingManagerpointer to an CoordinateMappingManager object.
See also
CoordinateMappingManager.hpp

Definition at line 69 of file FacadeSingleton.cpp.

69 {
70 this->coordinateMappingManager = coordinateMappingManager;
71}

References coordinateMappingManager.

Referenced by startEnvironment().

◆ setImageManager()

void FacadeSingleton::setImageManager ( ImageManager imageManager)
protected

Set the ImageManager pointer.

Parameters
imageManagerpointer to an ImageManager object.
See also
ImageManager.hpp

Definition at line 73 of file FacadeSingleton.cpp.

73 {
74 this->imageManager = imageManager;
75}

References imageManager.

Referenced by startEnvironment().

◆ setKafkaManager()

void FacadeSingleton::setKafkaManager ( KafkaManager kafkaManager)
protected

Set the KafkaManager pointer.

Parameters
kafkaManagerpointer to a KafkaManager object.
See also
KafkaManager.hpp

Definition at line 77 of file FacadeSingleton.cpp.

77 {
78 this->kafkaManager = kafkaManager;
79}

References kafkaManager.

Referenced by startEnvironment().

◆ setOpenCV_Manager()

void FacadeSingleton::setOpenCV_Manager ( OpenCV_Manager openCV_Manager)
protected

Set the OpenCV_Manager pointer.

Parameters
openCV_Managerpointer to an OpenCV_Manager object.
See also
OpenCV_Manager.hpp

Definition at line 61 of file FacadeSingleton.cpp.

61 {
62 this->openCV_Manager = openCV_Manager;
63}

References openCV_Manager.

Referenced by startEnvironment().

◆ setOutputManager()

void FacadeSingleton::setOutputManager ( OutputManager outputManager)
protected

Set the OutputManager pointer.

Parameters
outputManagerpointer to an OutputManager object.
See also
OutputManager.hpp

Definition at line 57 of file FacadeSingleton.cpp.

57 {
58 this->outputManager = outputManager;
59}

References outputManager.

Referenced by startEnvironment().

◆ setUsageManager()

void FacadeSingleton::setUsageManager ( UsageManager usageManager)
protected

Set the UsageManager pointer.

Parameters
usageManagerpointer to an UsageManager object.
See also
UsageManager.hpp

Definition at line 65 of file FacadeSingleton.cpp.

65 {
66 this->usageManager = usageManager;
67}

References usageManager.

Referenced by FacadeSingleton().

◆ showSkeletons()

void FacadeSingleton::showSkeletons ( unsigned int  user_nFrame,
const float  skeletonThreshold 
)

Retrieve OpenPose's output, convert it to RealSense coordinate's space, show results and save them.

Parameters
user_nFrameframe's number to capture according to user choice.
skeletonThresholdThe magnitude or intensity that must be exceeded for a specific reaction, phenomenon, result, or condition to occur or be manifested. In this case, if the skeleton's confidence mean value is greater than "skeletonThreshold", then the skeleton will be considered a meaningful skeleton.
See also
showSkeletonsCV(unsigned int user_nFrame)

Definition at line 145 of file FacadeSingleton.cpp.

145 {
146 getOpenCV_Manager()->showSkeletonsCV(user_nFrame, skeletonThreshold);
147}
void showSkeletonsCV(unsigned int user_nFrame, const float skeletonThreshold)
Retrieve OpenPose's output, convert it to RealSense coordinate's space, show results and save them.

References getOpenCV_Manager(), and OpenCV_Manager::showSkeletonsCV().

Referenced by main().

◆ startEnvironment()

void FacadeSingleton::startEnvironment ( rs2::pipeline &  pipelineStream,
struct rs2_intrinsics &  color_intrin,
float *  scale,
unsigned short int  resX,
unsigned short int  resY,
const char *  destinationKafkaTopic,
Room  room 
)

This method is useful to invoke at the boot of the program where we want to initialize the different mangers, start the camera and set up the related environment.

Parameters
pipelineStreamThe pipeline simplifies the user interaction with the device and computer vision processing modules. The class abstracts the camera configuration and streaming, and the vision modules triggering and threading. It lets the application focus on the computer vision output of the modules, or the device output data. The pipeline can manage computer vision modules, which are implemented as a processing block. The pipeline is the consumer of the processing block interface, while the application consumes the computer vision interface.
color_intrinReference to color video stream intrinsics.
scalePointer to scaling factor.
resXx resoultion <->.
resYy resolution.
destinationKafkaTopicthe destination's kafka topic's name.
roomSpecific room within which the coordinate mapping will be done.
See also
https://dev.intelrealsense.com/docs/docs-get-started
startEnvironment(rs2::pipeline & pipelineStream, struct rs2_intrinsics & color_intrin, float * scale, unsigned short int resX, unsigned short int resY, bool firstBoot)

Definition at line 123 of file FacadeSingleton.cpp.

123 {
128
130 FacadeSingleton::setKafkaManager(new KafkaManager(destinationKafkaTopic));
131 FacadeSingleton::getCameraManager()->startEnvironment(pipelineStream, color_intrin, scale, resX, resY, FIRST_BOOT);
133}
void setOutputManager(OutputManager *outputManager)
Set the OutputManager pointer.
void setImageManager(ImageManager *imageManager)
Set the ImageManager pointer.
void setCoordinateMappingManager(CoordinateMappingManager *coordinateMappingManager)
Set the CoordinateMappingManager pointer.
void setOpenCV_Manager(OpenCV_Manager *openCV_Manager)
Set the OpenCV_Manager pointer.
void setKafkaManager(KafkaManager *kafkaManager)
Set the KafkaManager pointer.
void setCameraManager(RealSenseManager *cameraManager)
Set the RealSenseManager pointer.
void cleanBuildFolder(void)
This method cleans the build folder, in order to prepare the environment for the next loop iteration....
ImageManager class is a general-purpose class useful for operations on images such as loading,...
Kafka class is a class that is responsible to send all generated output data, via Apache Kafka techno...
OpenCV_Manager class is used for general-purpose tasks on the captured frames.
RealSenseD435Manager class is a class that abstracts the behavior of an Intel RealSense D435 Camera,...
virtual void startEnvironment(rs2::pipeline &pipelineStream, struct rs2_intrinsics &color_intrin, float *scale, unsigned short int resX, unsigned short int resY, bool firstBoot)=0
This method is useful to invoke at the boot of the program where we want to initialize the different ...
The UnityCoordinateMappingManager class is a class that is responsible for converting coordinates val...
static const bool FIRST_BOOT
Definition: constants.hpp:71

References cleanBuildFolder(), FIRST_BOOT, getCameraManager(), setCameraManager(), setCoordinateMappingManager(), setImageManager(), setKafkaManager(), setOpenCV_Manager(), setOutputManager(), and RealSenseManager::startEnvironment().

Referenced by main().

Member Data Documentation

◆ cameraManager

RealSenseManager* FacadeSingleton::cameraManager
private

A pointer to RealSenseManager object. A RealSenseManager object is responsible for handling the camera setup, frames acquisition and frames post-processing.

See also
RealSenseManager.hpp

Definition at line 62 of file FacadeSingleton.hpp.

Referenced by getCameraManager(), and setCameraManager().

◆ coordinateMappingManager

CoordinateMappingManager* FacadeSingleton::coordinateMappingManager
private

A pointer to CoordinateMappingManager object. A CoordinateMappingManager object is responsible for transforming one coordinate range values' space into another one. For instance, it can transform a RealSense coordinates space to meters or to Unity coordinates. In both cases, there are several parameters to set up regarding the scene and the room where the camera is installed.

See also
constants.hpp
CoordinateMappingManager.hpp

Definition at line 90 of file FacadeSingleton.hpp.

Referenced by getCoordinateMappingManager(), and setCoordinateMappingManager().

◆ imageManager

ImageManager* FacadeSingleton::imageManager
private

A pointer to CoordinateMappingManager object. A CoordinateMappingManager object is responsible for broad tasks such as loading, saving, and showing images, as well as releasing the memory allocated for those images.

See also
ImageManager.hpp

Definition at line 97 of file FacadeSingleton.hpp.

Referenced by getImageManager(), and setImageManager().

◆ kafkaManager

KafkaManager* FacadeSingleton::kafkaManager
private

A pointer to KafkaManager object. A KafkaManager object is responsible for sending previously produced JSON output via Kafka.

See also
KafkaManager.hpp

Definition at line 103 of file FacadeSingleton.hpp.

Referenced by getKafkaManager(), and setKafkaManager().

◆ openCV_Manager

OpenCV_Manager* FacadeSingleton::openCV_Manager
private

A pointer to OpenCV_Manager object. An OpenCV_Manager object is responsible for converting camera frame to an OpenCV matrix and booting building skeletons into the image.

See also
OpenCV_Manager.hpp

Definition at line 74 of file FacadeSingleton.hpp.

Referenced by getOpenCV_Manager(), and setOpenCV_Manager().

◆ outputManager

OutputManager* FacadeSingleton::outputManager
private

A pointer to OutputManager object. An OutputManager object is responsible for handling the final output generation to send via Kafka later on.

See also
OutputManager.hpp

Definition at line 68 of file FacadeSingleton.hpp.

Referenced by getOutputManager(), and setOutputManager().

◆ sharedInstance

FacadeSingleton * FacadeSingleton::sharedInstance { nullptr }
staticprivate

The field for storing the singleton instance.

Definition at line 49 of file FacadeSingleton.hpp.

Referenced by getInstance(), and ~FacadeSingleton().

◆ singletonMutex

std::mutex FacadeSingleton::singletonMutex
staticprivate

Mutex for thread-safe access.

Definition at line 53 of file FacadeSingleton.hpp.

Referenced by getInstance().

◆ usageManager

UsageManager* FacadeSingleton::usageManager
private

A pointer to UsageManager object. An UsageManager object is responsible for checking if the parameters read from configuration file are fine, correct and valid. Furthermore this class provides methods to access this parameters.

See also
UsageManager.hpp

Definition at line 81 of file FacadeSingleton.hpp.

Referenced by getUsageManager(), and setUsageManager().


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