Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
vpFlyCaptureGrabber.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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 
155 class VISP_EXPORT vpFlyCaptureGrabber : public vpFrameGrabber
156 {
157 public:
159  virtual ~vpFlyCaptureGrabber();
160 
162  void acquire(vpImage<unsigned char> &I, FlyCapture2::TimeStamp &timestamp);
163  void acquire(vpImage<vpRGBa> &I);
164  void acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp &timestamp);
165 
166  void close();
167  void connect();
168  void disconnect();
169 
170  float getBrightness();
171  std::ostream &getCameraInfo(std::ostream &os); // Cannot be const since
172  // FlyCapture2::Camera::GetCameraInfo()
173  // isn't
174  FlyCapture2::Camera *getCameraHandler();
176  unsigned int getCameraIndex() const { return m_index; };
177  bool getCameraPower();
178  static unsigned int getCameraSerial(unsigned int index);
179  float getExposure();
180  float getFrameRate();
181  float getGain();
182  static unsigned int getNumCameras();
183  unsigned int getSharpness();
184  float getShutter();
185 
186  bool isCameraPowerAvailable();
188  bool isConnected() const { return m_connected; }
190  bool isCaptureStarted() const { return m_capture; }
191  bool isFormat7Supported(FlyCapture2::Mode format7_mode);
192  bool isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate);
193  void open(vpImage<unsigned char> &I);
194  void open(vpImage<vpRGBa> &I);
195 
197  vpFlyCaptureGrabber &operator>>(vpImage<vpRGBa> &I);
198 
199  float setBrightness(bool brightness_auto, float brightness_value = 0);
200  void setCameraIndex(unsigned int index);
201  void setCameraPower(bool on);
202  void setCameraSerial(unsigned int serial);
203  float setExposure(bool exposure_on, bool exposure_auto, float exposure_value = 0);
204  float setGain(bool gain_auto, float gain_value = 0);
205  void setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format, unsigned int width,
206  unsigned int height);
207  float setFrameRate(float frame_rate);
208  unsigned int setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value = 0);
209  float setShutter(bool auto_shutter, float shutter_ms = 10);
210  void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate);
211 
212  void startCapture();
213  void stopCapture();
214 
215 protected:
216  typedef enum {
219  } PropertyValue;
220  std::pair<unsigned int, unsigned int> centerRoi(unsigned int size, unsigned int max_size, unsigned int step);
221  FlyCapture2::Property getProperty(FlyCapture2::PropertyType prop_type);
222  FlyCapture2::PropertyInfo getPropertyInfo(FlyCapture2::PropertyType prop_type);
223  void open();
224  void setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value,
225  PropertyValue prop_value = ABS_VALUE);
226 
227 protected:
228  FlyCapture2::Camera m_camera;
229  FlyCapture2::PGRGuid m_guid;
230  unsigned int m_index;
231  unsigned int m_numCameras;
232  FlyCapture2::Image m_rawImage;
233  bool m_connected;
234  bool m_capture;
235 };
236 
237 #endif
238 #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