Visual Servoing Platform  version 3.1.0
vpFlyCaptureGrabber.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description: Class which enables to project an image in the 3D space
32  * and get the view of a virtual camera.
33  *
34  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
39 #ifndef __vpFlyCaptureGrabber_h_
40 #define __vpFlyCaptureGrabber_h_
41 
42 #include <ostream>
43 #include <visp3/core/vpConfig.h>
44 #include <visp3/core/vpFrameGrabber.h>
45 
46 #ifdef VISP_HAVE_FLYCAPTURE
47 
48 #include <FlyCapture2.h>
49 
147 class VISP_EXPORT vpFlyCaptureGrabber : public vpFrameGrabber
148 {
149 public:
151  virtual ~vpFlyCaptureGrabber();
152 
154  void acquire(vpImage<unsigned char> &I, FlyCapture2::TimeStamp &timestamp);
155  void acquire(vpImage<vpRGBa> &I);
156  void acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp &timestamp);
157 
158  void close();
159  void connect();
160  void disconnect();
161 
162  float getBrightness();
163  std::ostream &getCameraInfo(std::ostream &os); // Cannot be const since
164  // FlyCapture2::Camera::GetCameraInfo()
165  // isn't
166  FlyCapture2::Camera *getCameraHandler();
168  unsigned int getCameraIndex() const { return m_index; };
169  bool getCameraPower();
170  static unsigned int getCameraSerial(unsigned int index);
171  float getExposure();
172  float getFrameRate();
173  float getGain();
174  static unsigned int getNumCameras();
175  unsigned int getSharpness();
176  float getShutter();
177 
178  bool isCameraPowerAvailable();
180  bool isConnected() const { return m_connected; }
182  bool isCaptureStarted() const { return m_capture; }
183  bool isFormat7Supported(FlyCapture2::Mode format7_mode);
184  bool isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate);
185  void open(vpImage<unsigned char> &I);
186  void open(vpImage<vpRGBa> &I);
187 
189  vpFlyCaptureGrabber &operator>>(vpImage<vpRGBa> &I);
190 
191  float setBrightness(bool brightness_auto, float brightness_value = 0);
192  void setCameraIndex(unsigned int index);
193  void setCameraPower(bool on);
194  void setCameraSerial(unsigned int serial);
195  float setExposure(bool exposure_on, bool exposure_auto, float exposure_value = 0);
196  float setGain(bool gain_auto, float gain_value = 0);
197  void setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format, unsigned int width,
198  unsigned int height);
199  float setFrameRate(float frame_rate);
200  unsigned int setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value = 0);
201  float setShutter(bool auto_shutter, float shutter_ms = 10);
202  void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate);
203 
204  void startCapture();
205  void stopCapture();
206 
207 protected:
208  typedef enum {
211  } PropertyValue;
212  std::pair<unsigned int, unsigned int> centerRoi(unsigned int size, unsigned int max_size, unsigned int step);
213  FlyCapture2::Property getProperty(FlyCapture2::PropertyType prop_type);
214  FlyCapture2::PropertyInfo getPropertyInfo(FlyCapture2::PropertyType prop_type);
215  void open();
216  void setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value,
217  PropertyValue prop_value = ABS_VALUE);
218 
219 protected:
220  FlyCapture2::Camera m_camera;
221  FlyCapture2::PGRGuid m_guid;
222  unsigned int m_index;
223  unsigned int m_numCameras;
224  FlyCapture2::Image m_rawImage;
225  bool m_connected;
226  bool m_capture;
227 };
228 
229 #endif
230 #endif
FlyCapture2::Image m_rawImage
Image buffer.
FlyCapture2::Camera m_camera
Pointer to each camera.
Consider FlyCapture2::Property::valueA.
virtual void open(vpImage< unsigned char > &I)=0
bool isConnected() const
Return true if the camera is connected.
unsigned int getCameraIndex() const
FlyCapture2::PGRGuid m_guid
Active camera guid.
bool m_connected
true if camera connected
Consider FlyCapture2::Property::absValue.
bool m_capture
true is capture started
Base class for all video devices. It is designed to provide a front end to video sources.
virtual void close()=0
unsigned int m_index
Active camera index.
bool isCaptureStarted() const
Return true if the camera capture is started.
unsigned int m_numCameras
Number of connected cameras.
virtual void acquire(vpImage< unsigned char > &I)=0