Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.81 KB | None | 0 0
  1. #include <pcl/console/parse.h>
  2. #include <pcl/point_types.h>
  3. #include <pcl/common/time.h>
  4. #include <pcl/visualization/pcl_visualizer.h>
  5. #include <pcl/io/openni_grabber.h>
  6. #include <pcl/sample_consensus/sac_model_plane.h>
  7. #include <pcl/people/ground_based_people_detection_app.h>
  8.  
  9. typedef pcl::PointXYZRGBA PointT;
  10. typedef pcl::PointCloud<PointT> PointCloudT;
  11.  
  12.  
  13. class Algorithm
  14. {
  15.     pcl::visualization::PCLVisualizer *viewer;
  16.     boost::mutex cloud_mutex;
  17.     enum { COLS = 640, ROWS = 480 };
  18.  
  19.     void cloud_cb_(const PointCloudT::ConstPtr &callback_cloud, PointCloudT::Ptr& cloud,
  20.         bool* new_cloud_available_flag)
  21.     {
  22.         cloud_mutex.lock();    // for not overwriting the point cloud from another thread
  23.         *cloud = *callback_cloud;
  24.         *new_cloud_available_flag = true;
  25.         cloud_mutex.unlock();
  26.     }
  27.  
  28.     struct callback_args{
  29.         // structure used to pass arguments to the callback function
  30.         PointCloudT::Ptr clicked_points_3d;
  31.         pcl::visualization::PCLVisualizer::Ptr viewerPtr;
  32.     };
  33.  
  34.     void
  35.         pp_callback(const pcl::visualization::PointPickingEvent& event, void* args)
  36.     {
  37.             struct callback_args* data = (struct callback_args *)args;
  38.             if (event.getPointIndex() == -1)
  39.                 return;
  40.             PointT current_point;
  41.             event.getPoint(current_point.x, current_point.y, current_point.z);
  42.             data->clicked_points_3d->points.push_back(current_point);
  43.             // Draw clicked points in red:
  44.             pcl::visualization::PointCloudColorHandlerCustom<PointT> red(data->clicked_points_3d, 255, 0, 0);
  45.             data->viewerPtr->removePointCloud("clicked_points");
  46.             data->viewerPtr->addPointCloud(data->clicked_points_3d, red, "clicked_points");
  47.             data->viewerPtr->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 10, "clicked_points");
  48.             std::cout << current_point.x << " " << current_point.y << " " << current_point.z << std::endl;
  49.     }
  50.  
  51.     public:
  52.     Algorithm(pcl::visualization::PCLVisualizer *viewer2){
  53.         viewer = viewer2;
  54.     };
  55.  
  56.     void play()
  57.     {
  58.         std::string svm_filename = "trainedLinearSVMForPeopleDetectionWithHOG.yaml";
  59.         float min_confidence = -1.5;
  60.         float min_height = 1.3;
  61.         float max_height = 2.3;
  62.         float voxel_size = 0.06;
  63.         Eigen::Matrix3f rgb_intrinsics_matrix;
  64.         rgb_intrinsics_matrix << 525, 0.0, 319.5, 0.0, 525, 239.5, 0.0, 0.0, 1.0; // Kinect RGB camera intrinsics
  65.  
  66.         PointCloudT::Ptr cloud(new PointCloudT);
  67.         bool new_cloud_available_flag = false;
  68.         pcl::Grabber* interface = new pcl::OpenNIGrabber("sample-pokoj.oni");
  69.         boost::function<void(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f = boost::bind(&cloud_cb_, _1, cloud, &new_cloud_available_flag);
  70.         //interface->registerCallback(f);
  71.         //interface->start();
  72.     }
  73. };
  74.  
  75. int main(int argc, char** argv)
  76. {
  77.     int a;
  78.     pcl::visualization::PCLVisualizer viewer("PCL Viewer");
  79.     Algorithm obiekt(&viewer);
  80.     obiekt.play();
  81.     cin >> a;
  82.     return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement