Visual Servoing Platform  version 3.6.1 under development (2024-11-21)
vpFlyCaptureGrabber.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 https://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 *****************************************************************************/
35 
42 #ifndef _vpFlyCaptureGrabber_h_
43 #define _vpFlyCaptureGrabber_h_
44 
45 #include <ostream>
46 #include <visp3/core/vpConfig.h>
47 #include <visp3/core/vpFrameGrabber.h>
48 
49 #ifdef VISP_HAVE_FLYCAPTURE
50 
51 #include <FlyCapture2.h>
52 
53 BEGIN_VISP_NAMESPACE
54 
163 class VISP_EXPORT vpFlyCaptureGrabber : public vpFrameGrabber
164 {
165 public:
167  virtual ~vpFlyCaptureGrabber();
168 
170  void acquire(vpImage<unsigned char> &I, FlyCapture2::TimeStamp &timestamp);
171  void acquire(vpImage<vpRGBa> &I);
172  void acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp &timestamp);
173 
174  void close();
175  void connect();
176  void disconnect();
177 
178  float getBrightness();
179  std::ostream &getCameraInfo(std::ostream &os); // Cannot be const since
180  // FlyCapture2::Camera::GetCameraInfo()
181  // isn't
182  FlyCapture2::Camera *getCameraHandler();
184  unsigned int getCameraIndex() const { return m_index; };
185  bool getCameraPower();
186  static unsigned int getCameraSerial(unsigned int index);
187  float getExposure();
188  float getFrameRate();
189  float getGain();
190  static unsigned int getNumCameras();
191  unsigned int getSharpness();
192  float getShutter();
193 
194  bool isCameraPowerAvailable();
196  bool isConnected() const { return m_connected; }
198  bool isCaptureStarted() const { return m_capture; }
199  bool isFormat7Supported(FlyCapture2::Mode format7_mode);
200  bool isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate);
201  void open(vpImage<unsigned char> &I);
202  void open(vpImage<vpRGBa> &I);
203 
205  vpFlyCaptureGrabber &operator>>(vpImage<vpRGBa> &I);
206 
207  float setBrightness(bool brightness_auto, float brightness_value = 0);
208  void setCameraIndex(unsigned int index);
209  void setCameraPower(bool on);
210  void setCameraSerial(unsigned int serial);
211  float setExposure(bool exposure_on, bool exposure_auto, float exposure_value = 0);
212  float setGain(bool gain_auto, float gain_value = 0);
213  void setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format, unsigned int width,
214  unsigned int height);
215  float setFrameRate(float frame_rate);
216  unsigned int setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value = 0);
217  float setShutter(bool auto_shutter, float shutter_ms = 10);
218  void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate);
219 
220  void startCapture();
221  void stopCapture();
222 
223 protected:
224  typedef enum
225  {
228  } PropertyValue;
229  std::pair<unsigned int, unsigned int> centerRoi(unsigned int size, unsigned int max_size, unsigned int step);
230  FlyCapture2::Property getProperty(FlyCapture2::PropertyType prop_type);
231  FlyCapture2::PropertyInfo getPropertyInfo(FlyCapture2::PropertyType prop_type);
232  void open();
233  void setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value,
234  PropertyValue prop_value = ABS_VALUE);
235 
236 protected:
237  FlyCapture2::Camera m_camera;
238  FlyCapture2::PGRGuid m_guid;
239  unsigned int m_index;
240  unsigned int m_numCameras;
241  FlyCapture2::Image m_rawImage;
242  bool m_connected;
243  bool m_capture;
244 };
245 END_VISP_NAMESPACE
246 #endif
247 #endif
FlyCapture2::Image m_rawImage
Image buffer.
bool m_capture
true is capture started
bool isCaptureStarted() const
Return true if the camera capture is started.
FlyCapture2::Camera m_camera
Pointer to each camera.
unsigned int m_index
Active camera index.
unsigned int m_numCameras
Number of connected cameras.
@ VALUE_A
Consider FlyCapture2::Property::valueA.
@ ABS_VALUE
Consider FlyCapture2::Property::absValue.
bool m_connected
true if camera connected
FlyCapture2::PGRGuid m_guid
Active camera guid.
unsigned int getCameraIndex() const
bool isConnected() const
Return true if the camera is connected.
Base class for all video devices. It is designed to provide a front end to video sources.
virtual void open(vpImage< unsigned char > &I)=0
virtual void acquire(vpImage< unsigned char > &I)=0
virtual void close()=0