tutorial-ros-grabber.cpp
Go to the documentation of this file.
1 #include <visp/vpDisplayX.h>
3 #include <visp/vpImage.h>
5 
6 int main(int argc, const char** argv)
7 {
8  try {
9  bool opt_use_camera_info = false;
10  for (int i=0; i<argc; i++) {
11  if (std::string(argv[i]) == "--use-camera-info")
12  opt_use_camera_info = true;
13  else if (std::string(argv[i]) == "--help") {
14  std::cout << "Usage: " << argv[0]
15  << " [--use-camera-info] [--help]"
16  << std::endl;
17  return 0;
18  }
19  }
20  std::cout << "Use camera info: " << ((opt_use_camera_info == true) ? "yes" : "no") << std::endl;
21 
22  //vpImage<unsigned char> I; // Create a gray level image container
23  vpImage<vpRGBa> I; // Create a color image container
25  vpROSGrabber g; // Create a grabber based on ROS
27 
29  g.setImageTopic("/camera/image_raw");
32  if (opt_use_camera_info) {
33  g.setCameraInfoTopic("/camera/camera_info");
34  g.setRectify(true);
35  }
37 
39  g.open(I);
41  std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl;
42 
43 #ifdef VISP_HAVE_X11
44  vpDisplayX d(I);
45 #else
46  std::cout << "No image viewer is available..." << std::endl;
47 #endif
48 
49  while(1) {
51  g.acquire(I);
53  vpDisplay::display(I);
54  vpDisplay::displayText(I, 20, 20, "A click to quit...", vpColor::red);
55  vpDisplay::flush(I);
56  if (vpDisplay::getClick(I, false))
57  break;
58  }
59  }
60  catch(vpException e) {
61  std::cout << "Catch an exception: " << e << std::endl;
62  }
63 }
d
Class for cameras video capture for ROS cameras.
Definition: vpROSGrabber.h:104
void setRectify(bool rectify)
void setCameraInfoTopic(std::string topic_name)
void open(int argc, char **argv)
class for Camera video capture for ROS middleware.
int main(int argc, const char **argv)
void setImageTopic(std::string topic_name)
void acquire(vpImage< unsigned char > &I)


visp_ros
Author(s): Francois Pasteau, Fabien Spindler, Gatien Gaumerais
autogenerated on Fri Jul 3 2020 03:41:43