class BodyTracking {
public:
//Constructor
BodyTracking();
//Destructor
~BodyTracking();
private:
#include "body_tracking.h"
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
cv::CascadeClassifier face_cascade;
typedef message_filters::sync_policies::
ApproximateTime<sensor_msgs::PointCloud2, sensor_msgs::PointCloud2>
MySync2Policy;
typedef message_filters::sync_policies::
ApproximateTime<sensor_msgs::PointCloud2, sensor_msgs::PointCloud2,
sensor_msgs::PointCloud2> MySync3Policy;
ros::Subscriber single_cam;
boost::shared_ptr<message_filters::Synchronizer<MySync2Policy> > sync2;
boost::shared_ptr<message_filters::Synchronizer<MySync3Policy> > sync3;
typedef pcl::PointXYZRGB PointT;
typedef pcl::PointCloud<PointT> PointCloudT;
typedef body_tracking::BodyTrackingConfig Config;
typedef dynamic_reconfigure::Server<Config> ReconfigureServer;
typedef boost::shared_ptr<PointCloudT> PointCloudPtr;
typedef boost::shared_ptr<const PointCloudT> PointCloudConstPtr;
// listener for coordinate system transforms
boost::shared_ptr<tf::TransformListener> tflistener_ptr;
// skeltrack objects start
SkeltrackSkeleton *skeltrack_skeleton_rawptr;
SkeltrackJointList skeltrack_joint_list; // this is a SkeltrackJoint**
// skeltrack objects end
// body model objects start
//boost::shared_ptr<BodyModel> body_model_ptr(new BodyModel());
boost::shared_ptr<BodyModel> body_model_ptr();
// body model objects end
bool intrinsics_already_set = false;
Eigen::Matrix3f intrinsics_matrix;
bool update_background = false;
// Min confidence for people detection:
double min_confidence_;
// People detection object
open_ptrack::detection::GroundBasedPeopleDetectionApp<PointT> people_detector;
// Flag stating if classifiers based on RGB image should be used or not
bool use_rgb;
// Threshold on image luminance. If luminance is over this threshold,
// classifiers on RGB image are also used
int minimum_luminance;
// If true, sensor tilt angle wrt ground plane is compensated to improve people
// detection
bool sensor_tilt_compensation;
// Voxel size for downsampling the cloud
double voxel_size;
// If true, do not update the ground plane at every frame
bool lock_ground;
// Frames to use for updating the background
int max_background_frames;
// Main loop rate:
double rate_value;
// Voxel resolution of the octree used to represent the background
double background_octree_resolution;
// Background cloud
PointCloudT::Ptr background_cloud;
// If true, background subtraction is performed
bool background_subtraction;
// Threshold on the ratio of valid points needed for ground estimation
double valid_points_threshold;
// Create classifier for people detection:
open_ptrack::detection::PersonClassifier<pcl::RGB> person_classifier;
// ground estimator
boost::shared_ptr<open_ptrack::detection::GroundplaneEstimation<PointT> >
ground_estimator;
// algo variables
bool ground_from_extrinsic_calibration;
bool read_ground_from_file; // Flag stating if the ground should be read from
// file, if present
int sampling_factor;
std::string pointcloud_topic;
bool first_valid_frame = false;
// algo variables end
// my variables
bool ground_found_ = false;
bool ground_based_found_last_frame_ = false;
Eigen::VectorXf ground_coeffs;
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
boost::shared_ptr<pcl::visualization::RangeImageVisualizer>
range_image_widget_ptr_;
// For visualizing things in rviz
// rviz_visual_tools::RvizVisualToolsPtr visual_tools_ptr;
ros::Publisher debug_cloud_;
ros::Publisher debug_markers_;
ros::Publisher debug_depth_image_;
ros::Publisher debug_rgb_image_;
float bboxxstretch_, bboxystretch_, bboxzstretch_;
bool rviz_debug_output_;
bool pcl_debug_output_ = true;
// my variables end
visualization_msgs::Marker
create_marker(Eigen::Vector3f position, Eigen::Vector4f orientation,
Eigen::Vector3f scale, std::string frame_id, std::string ns,
int id, Eigen::Vector4f color, std::string text, uint32_t shape,
std::vector<geometry_msgs::Point> point_vector,
std::vector<std_msgs::ColorRGBA> colors);
visualization_msgs::Marker
create_marker_minmax(Eigen::Vector3f centroid, Eigen::Vector4f min,
Eigen::Vector4f max, std::string frame_id, std::string ns,
int id, Eigen::Vector4f color, uint32_t shape);
std::vector<visualization_msgs::Marker>
create_body_markers(Eigen::MatrixXf features, Eigen::MatrixXi adjacency_matrix,
std::string frame_id);
pcl::PointXYZ my_skeltrack_joint_to_point(SkeltrackJoint joint);
void deleteAllMarkersFromFrame(std::string frame_id);
void deleteAllJointMarkers(std::string frame_id);
void publishMarkerForSkeltrackJoint(SkeltrackJoint *joint, std::string name,
Eigen::Vector4f color, float radius,
std::string frame_id);
void addJointAsSphereVis(SkeltrackJoint *joint, float radius,
Eigen::Vector4f color, std::string name);
void updatePeopleVis(
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer,
pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud,
std::vector<pcl::people::PersonCluster<PointT> > clusters,
boost::shared_ptr<pcl::people::PersonCluster<PointT> > max_conf_cluster);
void updateVis(boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer,
pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud);
/** create PCL viewer window */
boost::shared_ptr<pcl::visualization::PCLVisualizer> createVis();
/** input: list of ROS Clouds. Output: List of PCL clouds transformed to Frame
* of first Camera */
void
ROSCloud_TF_PCLCloud(const std::vector<sensor_msgs::PointCloud2ConstPtr> in,
std::vector<PointCloudPtr> &out);
/** returns true if valid ground plane found*/
bool estimateGround(PointCloudPtr cloud);
void findPersonClusters(PointCloudPtr cloud,std::vector<pcl::people::PersonCluster<PointT> >
&clusters);
/** returns true if cluster found with confidence > minconfidence. index is returned in maxConfIndex. if function returns false maxConfIndex is INVALID. */
bool getBestPersonCLuster(std::vector<pcl::people::PersonCluster<PointT> > clusters,const int min_confidence, int &maxConfIndex);
void createDepthAndRGB2DFromOrganizedCloud(const PointCloudPtr incloud_ptr,cv::Mat &out_cloud_2d ,cv::Mat &out_cloud_2d_rgb );
/** returns: cropped cloud and 2d cv:Mat depth_image and 2d cv:Mat cropped color image */
void cropCloudToPerson(const PointCloudPtr incloud_ptr,PointCloudPtr &outcloud_ptr,const boost::shared_ptr<pcl::people::PersonCluster<PointT> > person1ptr,cv::Mat &out_cloud_2d ,cv::Mat &out_cloud_2d_rgb);
// callback methd fo N cameras (all logic code goes here)
void cloudNCallback(const std::vector<sensor_msgs::PointCloud2ConstPtr> cloud_msg_list);
void cloud1Callback(const sensor_msgs::PointCloud2ConstPtr &camera1);
// callback method for 2 cameras (synced)
void cloud2Callback(const sensor_msgs::PointCloud2ConstPtr &camera1,
const sensor_msgs::PointCloud2ConstPtr &camera2);
// callback method for 3 cameras (synced)
void cloud3Callback(const sensor_msgs::PointCloud2ConstPtr &camera1,
const sensor_msgs::PointCloud2ConstPtr &camera2,
const sensor_msgs::PointCloud2ConstPtr &camera3);
void cameraInfoCallback(const sensor_msgs::CameraInfo::ConstPtr &msg);
bool fileExists(const char *fileName);
};