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


visp_ros
Author(s): Francois Pasteau, Fabien Spindler, Gatien Gaumerais, Alexander Oliva
autogenerated on Wed Mar 2 2022 01:13:33