/** @brief Main function
 * @return Exit status */
int
main (void)
{
  viewer_ptr.reset (new pcl::visualization::CloudViewer ("3D Viewer"));
  ensenso_ptr.reset (new pcl::EnsensoGrabber);
  ensenso_ptr->openDevice (0);
  ensenso_ptr->openTcpPort ();
  //ensenso_ptr->initExtrinsicCalibration (5); // Disable projector if you want good looking images.
  // You won't be able to detect a calibration pattern with the projector enabled!

  boost::function<void
  (const boost::shared_ptr<PointCloudT>&,
   const boost::shared_ptr<PairOfImages>&)> f = boost::bind (&grabberCallback, _1, _2);
  ensenso_ptr->registerCallback (f);

  cv::namedWindow ("Ensenso images", cv::WINDOW_AUTOSIZE);
  ensenso_ptr->start ();

  while (!viewer_ptr->wasStopped ())
  {
    PCL_INFO("FPS: %f\n", ensenso_ptr->getFramesPerSecond ());
    boost::this_thread::sleep (boost::posix_time::milliseconds (500));
  }

  ensenso_ptr->stop ();
  //cv::destroyAllWindows (); // Doesn't work

  ensenso_ptr->closeDevice ();
  ensenso_ptr->closeTcpPort ();
  return 0;
}