Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tutorial-grabber-flycapture.cpp
1 #include <visp3/sensor/vpFlyCaptureGrabber.h>
3 #include <visp3/gui/vpDisplayX.h>
4 #include <visp3/gui/vpDisplayGDI.h>
5 #include <visp3/core/vpImage.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  }
22  catch(...) { // If settings are not available just catch execption to 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  }
54  catch(vpException &e) {
55  std::cout << "Catch an exception: " << e.getStringMessage() << std::endl;
56  }
57 #endif
58 }
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
unsigned int getWidth() const
Definition: vpImage.h:226
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:128
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:153
void acquire(vpImage< unsigned char > &I)
error that can be emited by ViSP classes.
Definition: vpException.h:73
static void flush(const vpImage< unsigned char > &I)
void open(vpImage< unsigned char > &I)
static const vpColor red
Definition: vpColor.h:163
float setGain(bool gain_auto, float gain_value=0)
static void display(const vpImage< unsigned char > &I)
unsigned int getHeight() const
Definition: vpImage.h:175
const std::string & getStringMessage(void) const
Send a reference (constant) related the error message (can be empty).
void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)