AI Watch A1
Multi-person 3D skeleton detection using Intel RealSense and OpenPose with Kafka support.
main.cpp
Go to the documentation of this file.
1//
2// main.cpp
3// AI Watch A1
4//
5// Created by Denny Caruso on 06/07/22.
6//
7
8// License: Apache 2.0. See LICENSE file in root directory.
9// Copyright(c) 2022. All Rights Reserved.
10
209#include "FacadeSingleton.hpp"
210
211
212
213const int expected_argc = 5;
214const char * expectedUsageMessage = "Usage: sudo ./AI_Watch_A1.bin <path/openpose folder/> <./path/openpose.bin> "
215 "<path/images folder/> <path/JSON output folder/>";
216
217
218
229int main (int argc, char ** argv) {
230 rs2::pipeline pipelineStream;
231 // Scaling factor for distance frame and topic name for kafka connection.
232 float scale;
233 const char * destinationKafkaTopic = "topic1";
234 // Optimal resolution for D435: 848x480.
235 unsigned int user_nFrame = 50, resX = 848, resY = 480;
236 const unsigned short int framesToSkip = 5;
237 const float skeletonThreshold = 0.05;
238 struct rs2_intrinsics color_intrin;
239 Room room = CVPR_Lab();
240
241 // Declaring a pointer to a FacadeSingleton object (it will be helpful to easily interact with all submodules) and starting D435 camera.
243 myUtility->startEnvironment(pipelineStream, color_intrin, & scale, resX, resY, destinationKafkaTopic, room);
244
245 /*
246 An infinite loop that captures the frames seen from the camera, gives them to OpenPose, gets the output, and builds skeletons.
247 After that, we create a properly formatted output JSON file and send it via Kafka for further elaboration.
248 */
249 while (true) {
250 myUtility->getVideoFrames(user_nFrame, pipelineStream, scale, framesToSkip);
251 myUtility->getVideoBodyKeyPoints(& argc, & argv);
252 myUtility->showSkeletons(user_nFrame, skeletonThreshold);
253 myUtility->sendData(user_nFrame);
254 myUtility->cleanBuildFolder();
255 }
256 return EXIT_SUCCESS;
257}
CVPR Lab class represents the CVPR Lab abstraction. The CVPR Lab is a Room with default values....
Definition: CVPR_Lab.hpp:23
FacadeSingleton class is used as a single access point to a simplified interface.
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.
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 ...
void getVideoBodyKeyPoints(int *argc, char ***argv)
Start and execute OpenPose submodule.
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.
void cleanBuildFolder(void)
This method cleans the build folder, in order to prepare the environment for the next loop iteration....
void sendData(unsigned int user_nFrame)
Send saved results by getVideoBodyKeyPoints(...) via Kafka using the KafkaManager.
static FacadeSingleton * getInstance(void)
Get the unique class instance. This methods should be called in the following scenario: when we just ...
Room class represents the Room abstraction. A Room object has different specifications,...
Definition: Room.hpp:64
int main(int argc, char **argv)
Main.
Definition: main.cpp:229
const char * expectedUsageMessage
Definition: main.cpp:214
const int expected_argc
Definition: main.cpp:213