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