Visual Servoing Platform  version 3.1.0
tutorial-grabber-flycapture.cpp
1 #include <visp3/core/vpImage.h>
3 #include <visp3/gui/vpDisplayGDI.h>
4 #include <visp3/gui/vpDisplayX.h>
5 #include <visp3/sensor/vpFlyCaptureGrabber.h>
6 
7 int main()
8 {
9 #ifdef VISP_HAVE_FLYCAPTURE
10  try {
11  vpImage<unsigned char> I; // Create a gray level image container
13  vpFlyCaptureGrabber g; // Create a grabber based on FlyCapture SDK third party lib
15 
17  try {
18  g.setShutter(true); // Turn auto shutter on
19  g.setGain(true); // Turn auto gain on
20  g.setVideoModeAndFrameRate(FlyCapture2::VIDEOMODE_1280x960Y8, FlyCapture2::FRAMERATE_60);
21  } catch (...) { // If settings are not available just catch execption to
22  // continue with default settings
23  }
26  g.open(I);
28 
29  std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl;
30 
31 #if defined(VISP_HAVE_X11)
32  vpDisplayX d(I);
33 #elif defined(VISP_HAVE_GDI)
34  vpDisplayGDI d(I);
35 #else
36  std::cout << "No image viewer is available..." << std::endl;
37 #endif
38 
39  while (1) {
41  g.acquire(I);
47  vpDisplay::displayText(I, 15, 15, "Click to quit", vpColor::red);
48  if (vpDisplay::getClick(I, false))
49  break;
52  }
53  } catch (vpException &e) {
54  std::cout << "Catch an exception: " << e.getStringMessage() << std::endl;
55  }
56 #endif
57 }
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:129
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
float setShutter(bool auto_shutter, float shutter_ms=10)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:151
void acquire(vpImage< unsigned char > &I)
error that can be emited by ViSP classes.
Definition: vpException.h:71
static void flush(const vpImage< unsigned char > &I)
void open(vpImage< unsigned char > &I)
static const vpColor red
Definition: vpColor.h:180
float setGain(bool gain_auto, float gain_value=0)
static void display(const vpImage< unsigned char > &I)
unsigned int getHeight() const
Definition: vpImage.h:178
unsigned int getWidth() const
Definition: vpImage.h:229
void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
const std::string & getStringMessage(void) const
Send a reference (constant) related the error message (can be empty).
Definition: vpException.cpp:92