Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpFlyCaptureGrabber Class Reference

#include <vpFlyCaptureGrabber.h>

Inheritance diagram for vpFlyCaptureGrabber:

Public Member Functions

 vpFlyCaptureGrabber ()
virtual ~vpFlyCaptureGrabber ()
void acquire (vpImage< unsigned char > &I)
void acquire (vpImage< unsigned char > &I, FlyCapture2::TimeStamp &timestamp)
void acquire (vpImage< vpRGBa > &I)
void acquire (vpImage< vpRGBa > &I, FlyCapture2::TimeStamp &timestamp)
void close ()
void connect ()
void disconnect ()
float getBrightness ()
std::ostream & getCameraInfo (std::ostream &os)
FlyCapture2::Camera * getCameraHandler ()
unsigned int getCameraIndex () const
bool getCameraPower ()
float getExposure ()
float getFrameRate ()
float getGain ()
unsigned int getSharpness ()
float getShutter ()
bool isCameraPowerAvailable ()
bool isConnected () const
bool isCaptureStarted () const
bool isFormat7Supported (FlyCapture2::Mode format7_mode)
bool isVideoModeAndFrameRateSupported (FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
void open (vpImage< unsigned char > &I)
void open (vpImage< vpRGBa > &I)
vpFlyCaptureGrabberoperator>> (vpImage< unsigned char > &I)
vpFlyCaptureGrabberoperator>> (vpImage< vpRGBa > &I)
float setBrightness (bool brightness_auto, float brightness_value=0)
void setCameraIndex (unsigned int index)
void setCameraPower (bool on)
void setCameraSerial (unsigned int serial)
float setExposure (bool exposure_on, bool exposure_auto, float exposure_value=0)
float setGain (bool gain_auto, float gain_value=0)
void setFormat7VideoMode (FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format, unsigned int width, unsigned int height)
float setFrameRate (float frame_rate)
unsigned int setSharpness (bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value=0)
float setShutter (bool auto_shutter, float shutter_ms=10)
void setVideoModeAndFrameRate (FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
void startCapture ()
void stopCapture ()

Static Public Member Functions

static unsigned int getCameraSerial (unsigned int index)
static unsigned int getNumCameras ()

Public Attributes

bool init

Protected Types

enum  PropertyValue { ABS_VALUE , VALUE_A }

Protected Member Functions

std::pair< unsigned int, unsigned int > centerRoi (unsigned int size, unsigned int max_size, unsigned int step)
FlyCapture2::Property getProperty (FlyCapture2::PropertyType prop_type)
FlyCapture2::PropertyInfo getPropertyInfo (FlyCapture2::PropertyType prop_type)
void open ()
void setProperty (const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value, PropertyValue prop_value=ABS_VALUE)

Protected Attributes

FlyCapture2::Camera m_camera
FlyCapture2::PGRGuid m_guid
unsigned int m_index
unsigned int m_numCameras
FlyCapture2::Image m_rawImage
bool m_connected
bool m_capture

Inherited functionalities from vpFramegrabber

unsigned int height
unsigned int width
unsigned int getHeight () const
unsigned int getWidth () const

Detailed Description

Allows to grab images from a PointGrey camera using FlyCapture SDK.

To use this class install first FlyCapture SDK https://www.ptgrey.com/flycapture-sdk. Installation instructions are provide here https://visp.inria.fr/3rd_flycapture.

Note
To install FlyCapture SDK on linux follow https://www.ptgrey.com/tan/10548.
For specific details about using FlyCapture and Linux with a USB 3.0 camera, see http://www.ptgrey.com/KB/10685.
Warning
With Ubuntu 16.04 or more recent versions, if you get issues during grabbing like:
Grab loop had an error: There is an image consistency issue with this image.
follow instruction provide here to increase receive buffer size.

Once installed configure ViSP using cmake to detect FlyCapture SDK and build ViSP to include FlyCapture SDK support.

This class was tested under Ubuntu and Windows with the following cameras:

  • Flea3 USB 3.0 cameras (FL3-U3-32S2M-CS, FL3-U3-13E4C-C)
  • Flea2 firewire camera (FL2-03S2C)
  • Dragonfly2 firewire camera (DR2-COL)

The following example shows how to use this class to capture images from the first camera that is found.

#include <visp3/core/vpImage.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
try {
int nframes = 100;
char filename[FILENAME_MAX];
std::cout << "Number of cameras detected: " << g.getNumCameras() << std::endl;
g.setCameraIndex(0); // Default camera is the first on the bus
g.getCameraInfo(std::cout);
g.open(I);
for(int i=0; i< nframes; ++i) {
g.acquire(I);
std::string filename = vpIoTools::formatString("image%04d.png", i);
vpImageIo::write(I, filename);
}
#endif
}
static unsigned int getNumCameras()
void setCameraIndex(unsigned int index)
void open(vpImage< unsigned char > &I)
void acquire(vpImage< unsigned char > &I)
std::ostream & getCameraInfo(std::ostream &os)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition of the vpImage class member functions.
Definition vpImage.h:131
static std::string formatString(const std::string &name, unsigned int val)

If more than one camera is detected, you can use setCamera(const unsigned int &) to select the camera of interest.

It is also possible to capture images from multiple cameras. The following example shows how to capture simultaneously images from multiple cameras.

#include <visp3/core/vpImage.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
int nframes = 100;
char filename[FILENAME_MAX];
unsigned int numCameras = vpFlyCaptureGrabber::getNumCameras();
std::cout << "Number of cameras detected: " << numCameras << std::endl;
std::vector< vpImage<unsigned char> > I(numCameras);
for(unsigned int cam=0; cam < numCameras; cam++) {
g[cam].setCameraIndex(cam); // Default camera is the first on the bus
g[cam].getCameraInfo(std::cout);
g[cam].open(I[cam]);
}
for(int i=0; i< nframes; i++) {
for(unsigned int cam=0; cam < numCameras; cam++) {
g[cam].acquire(I[cam]);
snprintf(filename, FILENAME_MAX, "image-camera%d-%04d.pgm", cam, i);
vpImageIo::write(I[cam], filename);
}
}
delete [] g;
#endif
}
Examples
grabFlyCapture.cpp, servoFlirPtuIBVS.cpp, tutorial-apriltag-detector-live.cpp, tutorial-blob-tracker-live.cpp, tutorial-flir-ptu-ibvs.cpp, tutorial-grabber-flycapture.cpp, tutorial-mb-generic-tracker-live.cpp, tutorial-me-ellipse-tracker.cpp, tutorial-me-line-tracker.cpp, and tutorial-pose-from-points-live.cpp.

Definition at line 162 of file vpFlyCaptureGrabber.h.

Member Enumeration Documentation

◆ PropertyValue

Enumerator
ABS_VALUE 

Consider FlyCapture2::Property::absValue.

VALUE_A 

Consider FlyCapture2::Property::valueA.

Definition at line 223 of file vpFlyCaptureGrabber.h.

Constructor & Destructor Documentation

◆ vpFlyCaptureGrabber()

BEGIN_VISP_NAMESPACE vpFlyCaptureGrabber::vpFlyCaptureGrabber ( )

Default constructor that consider the first camera found on the bus as active.

Definition at line 53 of file vpFlyCaptureGrabber.cpp.

References getNumCameras(), m_camera, m_capture, m_connected, m_guid, m_index, m_numCameras, and m_rawImage.

Referenced by operator>>(), and operator>>().

◆ ~vpFlyCaptureGrabber()

vpFlyCaptureGrabber::~vpFlyCaptureGrabber ( )
virtual

Default destructor that closes the connection with the camera.

Definition at line 62 of file vpFlyCaptureGrabber.cpp.

References close().

Member Function Documentation

◆ acquire() [1/4]

void vpFlyCaptureGrabber::acquire ( vpImage< unsigned char > & I)
virtual

Acquire a gray level image from the active camera.

Parameters
I: Image data structure (8 bits image).

Implements vpFrameGrabber.

Examples
grabFlyCapture.cpp, servoFlirPtuIBVS.cpp, and tutorial-flir-ptu-ibvs.cpp.

Definition at line 1144 of file vpFlyCaptureGrabber.cpp.

References acquire().

Referenced by acquire(), acquire(), open(), open(), operator>>(), and operator>>().

◆ acquire() [2/4]

void vpFlyCaptureGrabber::acquire ( vpImage< unsigned char > & I,
FlyCapture2::TimeStamp & timestamp )

Acquire a gray level image from the active camera.

Parameters
I: Image data structure (8 bits image).
timestamp: The acquisition timestamp.

Definition at line 1157 of file vpFlyCaptureGrabber.cpp.

References vpException::fatalError, getCameraSerial(), vpFrameGrabber::height, m_camera, m_index, m_rawImage, open(), and vpFrameGrabber::width.

◆ acquire() [3/4]

void vpFlyCaptureGrabber::acquire ( vpImage< vpRGBa > & I)
virtual

Acquire a color image from the active camera.

Parameters
I: Image data structure (RGBa image).

Implements vpFrameGrabber.

Definition at line 1195 of file vpFlyCaptureGrabber.cpp.

References acquire().

◆ acquire() [4/4]

void vpFlyCaptureGrabber::acquire ( vpImage< vpRGBa > & I,
FlyCapture2::TimeStamp & timestamp )

Acquire a color image from the active camera.

Parameters
I: Image data structure (RGBa image).
timestamp: The acquisition timestamp.

Definition at line 1208 of file vpFlyCaptureGrabber.cpp.

References vpException::fatalError, getCameraSerial(), vpFrameGrabber::height, m_camera, m_index, m_rawImage, open(), and vpFrameGrabber::width.

◆ centerRoi()

std::pair< unsigned int, unsigned int > vpFlyCaptureGrabber::centerRoi ( unsigned int size,
unsigned int max_size,
unsigned int step )
protected

Return size and offset corresponding to a centered roi.

Parameters
size: Horizontal or vertical roi size. If set to 0, use the max allowed size.
max_size: Allowed max size.
step: Step.

Definition at line 897 of file vpFlyCaptureGrabber.cpp.

Referenced by setFormat7VideoMode().

◆ close()

void vpFlyCaptureGrabber::close ( )
virtual

Stop active camera capturing images and disconnect the active camera. If you want to use again this camera, you may call setCamera(const unsigned int &) and open(vpImage<unsigned char> &) or open(vpImage<vpRGBa> &) to connect again the camera.

Similar then calling stopCapture() and disconnect():

...
g.stopCapture();

Implements vpFrameGrabber.

Definition at line 1133 of file vpFlyCaptureGrabber.cpp.

References disconnect(), and stopCapture().

Referenced by ~vpFlyCaptureGrabber().

◆ connect()

◆ disconnect()

void vpFlyCaptureGrabber::disconnect ( )

Disconnect the active camera.

See also
connect()

Definition at line 1101 of file vpFlyCaptureGrabber.cpp.

References vpException::fatalError, vpFrameGrabber::init, m_camera, m_capture, and m_connected.

Referenced by close().

◆ getBrightness()

float vpFlyCaptureGrabber::getBrightness ( )

Return brightness value in %. If the camera doesn't support brightness property, return an exception.

std::cout << "Brightness value: " << g.getBrightness() << " %" << std::endl;
See also
setBrightness()

Definition at line 272 of file vpFlyCaptureGrabber.cpp.

References connect(), and getProperty().

◆ getCameraHandler()

FlyCapture2::Camera * vpFlyCaptureGrabber::getCameraHandler ( )

Return the handler to the active camera or nullptr if the camera is not connected. This function was designed to provide a direct access to the FlyCapture SDK to get access to advanced functionalities that are not implemented in this class.

We provide here after and example that shows how to use this function to access to the camera and check if a given video mode and framerate are supported by the camera.

#include <visp3/core/vpImage.h>
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
int nframes = 100;
g.connect();
FlyCapture2::Camera *handler = g.getCameraHandler();
bool supported = false;
handler->GetVideoModeAndFrameRateInfo(FlyCapture2::VIDEOMODE_1280x960Y8, FlyCapture2::FRAMERATE_60, &supported);
if (supported)
g.setVideoModeAndFrameRate(FlyCapture2::VIDEOMODE_1280x960Y8, FlyCapture2::FRAMERATE_60); g.startCapture();
for(int i=0; i< nframes; i++) {
g.acquire(I);
}
#endif
}
FlyCapture2::Camera * getCameraHandler()
void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)

The following code shows how to use this function to check if a given format7 (here MODE_0, PIXEL_FORMAT_MONO8) is supported by the camera:

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
g.connect();
FlyCapture2::Camera *handler = g.getCameraHandler();
// Query for available Format 7 modes
const FlyCapture2::Mode k_fmt7Mode = FlyCapture2::MODE_0;
const FlyCapture2::PixelFormat k_fmt7PixFmt = FlyCapture2::PIXEL_FORMAT_MONO8;
FlyCapture2::Format7Info fmt7Info;
bool supported;
fmt7Info.mode = k_fmt7Mode;
FlyCapture2::Error error = handler->GetFormat7Info( &fmt7Info, &supported );
if (error != FlyCapture2::PGRERROR_OK) {
error.PrintErrorTrace();
return -1;
}
if (supported) {
std::cout << "Max image pixels: (" << fmt7Info.maxWidth << ", " << fmt7Info.maxHeight << ")" << std::endl;
std::cout << "Image Unit size: (" << fmt7Info.imageHStepSize << ", " << fmt7Info.imageVStepSize << ")"
<< std::endl;
std::cout << "Offset Unit size: (" << fmt7Info.offsetHStepSize << ", " << fmt7Info.offsetVStepSize << ")"
<< std::endl;
std::cout << "Pixel format bitfield: 0x" << fmt7Info.pixelFormatBitField << std::endl;
if ( (k_fmt7PixFmt & fmt7Info.pixelFormatBitField) == 0 ) {
// Pixel format not supported!
std::cout << "Pixel format is not supported" << std::endl;
return -1;
}
}
#endif
}

Definition at line 188 of file vpFlyCaptureGrabber.cpp.

References connect(), m_camera, and m_connected.

◆ getCameraIndex()

unsigned int vpFlyCaptureGrabber::getCameraIndex ( ) const
inline

Return the index of the active camera.

Examples
grabFlyCapture.cpp.

Definition at line 183 of file vpFlyCaptureGrabber.h.

References m_index.

◆ getCameraInfo()

std::ostream & vpFlyCaptureGrabber::getCameraInfo ( std::ostream & os)

Print to the output stream active camera information (serial number, camera model, camera vendor, sensor, resolution, firmaware version, ...).

Definition at line 81 of file vpFlyCaptureGrabber.cpp.

References connect(), and m_camera.

◆ getCameraPower()

bool vpFlyCaptureGrabber::getCameraPower ( )

Return true if the camera is powered on, false otherwise

See also
setCameraPower()

Definition at line 1315 of file vpFlyCaptureGrabber.cpp.

References isCameraPowerAvailable(), and m_camera.

◆ getCameraSerial()

unsigned int vpFlyCaptureGrabber::getCameraSerial ( unsigned int index)
static

Return the serial id of a camera with index.

Parameters
index: Camera index.

The following code shows how to retrieve the serial id of all the cameras that are connected on the bus.

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
unsigned int num_cameras = vpFlyCaptureGrabber::getNumCameras();
for (unsigned int i=0; i<num_cameras; i++) {
unsigned int serial_id = vpFlyCaptureGrabber::getCameraSerial(i);
std::cout << "Camera with index " << i << " has serial id: " << serial_id << std::endl;
}
#endif
}
static unsigned int getCameraSerial(unsigned int index)

When two cameras are connected (PGR Flea3 in our case), we get the following:

Camera with index 0 has serial id: 15372913
Camera with index 1 has serial id: 15290004
See also
setCameraSerial()
Examples
grabFlyCapture.cpp.

Definition at line 355 of file vpFlyCaptureGrabber.cpp.

References vpException::badValue, vpException::fatalError, and getNumCameras().

Referenced by acquire(), acquire(), connect(), setCameraSerial(), and startCapture().

◆ getExposure()

float vpFlyCaptureGrabber::getExposure ( )

Return exposure value. If the camera doesn't support exposure property, return an exception.

std::cout << "Exposure value: " << g.getExposure() << std::endl;
See also
setExposure()

Definition at line 312 of file vpFlyCaptureGrabber.cpp.

References connect(), and getProperty().

◆ getFrameRate()

float vpFlyCaptureGrabber::getFrameRate ( )

Return camera capture framerate. If the camera doesn't support framerate property, return an exception.

std::cout << "Frame rate: " << g.getFrameRate() << " fps" << std::endl;
See also
setFrameRate()

Definition at line 212 of file vpFlyCaptureGrabber.cpp.

References connect(), and getProperty().

◆ getGain()

float vpFlyCaptureGrabber::getGain ( )

Return camera gain value in db. If the camera doesn't support gain property, return an exception.

std::cout << "Gain value: " << g.getGain() << " ms" << std::endl;
See also
setGain()

Definition at line 252 of file vpFlyCaptureGrabber.cpp.

References connect(), and getProperty().

◆ getHeight()

BEGIN_VISP_NAMESPACE unsigned int vpFrameGrabber::getHeight ( ) const
inherited

Return the number of rows in the image.

Examples
AROgre.cpp, AROgreBasic.cpp, testPylonGrabber.cpp, and tutorial-rbt-sequence.cpp.

Definition at line 38 of file vpFrameGrabber.cpp.

References height.

◆ getNumCameras()

unsigned int vpFlyCaptureGrabber::getNumCameras ( )
static
Returns
Return the number of cameras connected on the bus.

Definition at line 66 of file vpFlyCaptureGrabber.cpp.

Referenced by connect(), getCameraSerial(), setCameraSerial(), and vpFlyCaptureGrabber().

◆ getProperty()

FlyCapture2::Property vpFlyCaptureGrabber::getProperty ( FlyCapture2::PropertyType prop_type)
protected

Return property values.

Parameters
prop_type: Property type.

Definition at line 792 of file vpFlyCaptureGrabber.cpp.

References connect(), vpException::fatalError, and m_camera.

Referenced by getBrightness(), getExposure(), getFrameRate(), getGain(), getSharpness(), getShutter(), setBrightness(), setExposure(), setFrameRate(), setGain(), setSharpness(), and setShutter().

◆ getPropertyInfo()

FlyCapture2::PropertyInfo vpFlyCaptureGrabber::getPropertyInfo ( FlyCapture2::PropertyType prop_type)
protected

Return information concerning a given property type.

Parameters
prop_type: Property type.
Exceptions
vpException::fatalError: If property type doesn't exist.

Definition at line 812 of file vpFlyCaptureGrabber.cpp.

References connect(), vpException::fatalError, and m_camera.

Referenced by setProperty().

◆ getSharpness()

unsigned int vpFlyCaptureGrabber::getSharpness ( )

Return sharpness value. If the camera doesn't support sharpness property, return an exception.

std::cout << "Sharpness value: " << g.getSharpness() << std::endl;
See also
setSharpness()

Definition at line 292 of file vpFlyCaptureGrabber.cpp.

References connect(), and getProperty().

◆ getShutter()

float vpFlyCaptureGrabber::getShutter ( )

Return camera shutter value in ms. If the camera doesn't support shutter property, return an exception.

std::cout << "Shutter value: " << g.getShutter() << " ms" << std::endl;
See also
setShutter()

Definition at line 232 of file vpFlyCaptureGrabber.cpp.

References connect(), and getProperty().

◆ getWidth()

unsigned int vpFrameGrabber::getWidth ( ) const
inherited

Return the number of columns in the image.

Examples
AROgre.cpp, AROgreBasic.cpp, testPylonGrabber.cpp, and tutorial-rbt-sequence.cpp.

Definition at line 43 of file vpFrameGrabber.cpp.

References width.

◆ isCameraPowerAvailable()

bool vpFlyCaptureGrabber::isCameraPowerAvailable ( )

Return true if camera power is available, false otherwise.

See also
getCameraPower(), setCameraPowerOn(), setCameraPowerOff()

Definition at line 1294 of file vpFlyCaptureGrabber.cpp.

References connect(), and m_camera.

Referenced by getCameraPower(), and setCameraPower().

◆ isCaptureStarted()

bool vpFlyCaptureGrabber::isCaptureStarted ( ) const
inline

Return true if the camera capture is started.

Definition at line 197 of file vpFlyCaptureGrabber.h.

References m_capture.

◆ isConnected()

bool vpFlyCaptureGrabber::isConnected ( ) const
inline

Return true if the camera is connected.

Definition at line 195 of file vpFlyCaptureGrabber.h.

References m_connected.

◆ isFormat7Supported()

bool vpFlyCaptureGrabber::isFormat7Supported ( FlyCapture2::Mode format7_mode)

Return true if format7 mode is supported.

Definition at line 995 of file vpFlyCaptureGrabber.cpp.

References connect(), vpException::fatalError, and m_camera.

◆ isVideoModeAndFrameRateSupported()

bool vpFlyCaptureGrabber::isVideoModeAndFrameRateSupported ( FlyCapture2::VideoMode video_mode,
FlyCapture2::FrameRate frame_rate )

Return true if video mode and framerate is supported.

Definition at line 877 of file vpFlyCaptureGrabber.cpp.

References connect(), vpException::fatalError, and m_camera.

◆ open() [1/3]

void vpFlyCaptureGrabber::open ( )
protected

Connect to the active camera and start capture.

Similar then calling:

...
g.connect();

Definition at line 1283 of file vpFlyCaptureGrabber.cpp.

References connect(), and startCapture().

Referenced by acquire(), acquire(), open(), and open().

◆ open() [2/3]

void vpFlyCaptureGrabber::open ( vpImage< unsigned char > & I)
virtual

Connect to the active camera, start capture and retrieve an image.

Parameters
I: Captured image.

Implements vpFrameGrabber.

Examples
grabFlyCapture.cpp, servoFlirPtuIBVS.cpp, tutorial-apriltag-detector-live.cpp, tutorial-flir-ptu-ibvs.cpp, tutorial-grabber-flycapture.cpp, and tutorial-pose-from-points-live.cpp.

Definition at line 1256 of file vpFlyCaptureGrabber.cpp.

References acquire(), and open().

◆ open() [3/3]

void vpFlyCaptureGrabber::open ( vpImage< vpRGBa > & I)
virtual

Connect to the active camera, start capture and retrieve an image.

Parameters
I: Captured image.

Implements vpFrameGrabber.

Definition at line 1266 of file vpFlyCaptureGrabber.cpp.

References acquire(), and open().

◆ operator>>() [1/2]

vpFlyCaptureGrabber & vpFlyCaptureGrabber::operator>> ( vpImage< unsigned char > & I)

Operator that allows to capture a grey level image.

Parameters
I: The captured image.
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
g >> I;
}

Definition at line 1430 of file vpFlyCaptureGrabber.cpp.

References acquire(), and vpFlyCaptureGrabber().

◆ operator>>() [2/2]

vpFlyCaptureGrabber & vpFlyCaptureGrabber::operator>> ( vpImage< vpRGBa > & I)

Operator that allows to capture a grey level image.

Parameters
I: The captured image.
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
g >> I;
}

Definition at line 1456 of file vpFlyCaptureGrabber.cpp.

References acquire(), and vpFlyCaptureGrabber().

◆ setBrightness()

float vpFlyCaptureGrabber::setBrightness ( bool brightness_auto,
float brightness_value = 0 )

Set camera brightness mode and parameter.

Parameters
brightness_auto: If true set auto brightness, if false set manual brightness applying brightness_value parameter.
brightness_value: This is the level of black in an image. A high brightness will result in a low amount of black in the image.
Returns
The measured brightness after applying the new setting.

The following example shows how to use this function:

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
float brightness = g.getBrightness();
std::cout << "Brightness : " << brightness << " %" << std::endl;
brightness = g.setBrightness(false, 2); // Turn manual brightness on to 2%
std::cout << "Brightness manual: " << brightness << " %" << std::endl;
brightness = g.setBrightness(true); // Turn auto brightness on
std::cout << "Brightness auto : " << brightness << " %" << std::endl;
g.open(I);
...
#endif
}
float setBrightness(bool brightness_auto, float brightness_value=0)
See also
getBrightness()

Definition at line 669 of file vpFlyCaptureGrabber.cpp.

References connect(), getProperty(), and setProperty().

◆ setCameraIndex()

void vpFlyCaptureGrabber::setCameraIndex ( unsigned int index)

If multiples cameras are connected on the bus, select the camero to dial with.

Parameters
index: Current camera index, a value comprised between 0 (the first camera found on the bus) and the number of cameras found on the bus and returned by getNumCameras() minus 1. If two cameras are connected on the bus, setting index to one allows to communicate with the second one. This identifier is not unique. That is why, it is also possible to select a camera by its serial number, which is unique using setCameraSerial().
Exceptions
vpException::badValue: If the index is greater or equal to the number of cameras connected to the bus.
Examples
grabFlyCapture.cpp.

Definition at line 388 of file vpFlyCaptureGrabber.cpp.

References vpException::badValue, m_index, and m_numCameras.

◆ setCameraPower()

void vpFlyCaptureGrabber::setCameraPower ( bool on)

Power on/off the camera.

Parameters
on: true to power on the camera, false to power off the camera.

The following example shows how to turn off a camera.

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
g.connect();
bool power = g.getCameraPower();
std::cout << "Camera is powered: " << ((power == true) ? "on" : "off") << std::endl;
if (power)
g.setCameraPower(false); // Power off the camera
#endif
}
See also
getCameraPower()

Definition at line 1363 of file vpFlyCaptureGrabber.cpp.

References vpException::badValue, connect(), vpException::fatalError, isCameraPowerAvailable(), m_camera, and vpTime::wait().

◆ setCameraSerial()

void vpFlyCaptureGrabber::setCameraSerial ( unsigned int serial_id)

Set the current camera from its unique serial identifier.

Parameters
serial_id: Camera serial id.

The following example shows how to capture images from a camera that has serial id 15290004.

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
int nframes = 100;
g.setCameraSerial(15290004); // Set camera with serial id
g.open(I);
g.getCameraInfo(std::cout);
for(int i=0; i< nframes; i++) {
g.acquire(I);
}
#endif
}
void setCameraSerial(unsigned int serial)
See also
getCameraSerial()

Definition at line 431 of file vpFlyCaptureGrabber.cpp.

References vpException::badValue, getCameraSerial(), getNumCameras(), m_index, and m_numCameras.

◆ setExposure()

float vpFlyCaptureGrabber::setExposure ( bool exposure_on,
bool exposure_auto,
float exposure_value = 0 )

Set camera exposure mode and parameter.

Parameters
exposure_on: If true turn exposure on, otherwise turn off.
exposure_auto: If true set auto exposure, if false set manual exposure applying exposure_value parameter.
exposure_value: This is the average intensity of the image. It will use other available (non-manually adjustable) controls to adjust the image. Specifically, when shutter and gain are both in auto mode, manually adjusting the exposure is actually adjusting the auto-exposure, which tries to make the average intensity of the image 1/4 of the auto-exposure value e.g. exposure is 400, the camera will try to adjust shutter and gain so that the average image intensity is 100. When the auto-exposure mode is enabled for exposure, the camera tries to manipulate shutter and gain such that 5% of the image is saturated (pixel value of 255).
Returns
The measured brightness after applying the new setting.

The following example shows how to use this function:

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
float exposure = g.getExposure();
std::cout << "Exposure : " << exposure << std::endl;
exposure = g.setExposure(true, false, 1); // Turn manual exposure on to 1
std::cout << "Exposure manual: " << exposure << std::endl;
exposure = g.setExposure(true, true); // Turn auto exposure on
std::cout << "Exposure auto : " << exposure << std::endl;
g.open(I);
...
#endif
}
float setExposure(bool exposure_on, bool exposure_auto, float exposure_value=0)
See also
getExposure()

Definition at line 727 of file vpFlyCaptureGrabber.cpp.

References connect(), getProperty(), and setProperty().

◆ setFormat7VideoMode()

void vpFlyCaptureGrabber::setFormat7VideoMode ( FlyCapture2::Mode format7_mode,
FlyCapture2::PixelFormat pixel_format,
unsigned int w,
unsigned int h )

Set format7 video mode.

Parameters
format7_mode: Format 7 mode.
pixel_format: Pixel format.
w: Width of the centered roi. If set to 0, use the max allowed size.
h: Height of the centered roi. If set to 0, use the max allowed size.

If the format7 video mode and pixel format are not supported, return an exception.

The following example shows how to use this function to capture a 640x480 roi:

#include <iomanip>
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
g.setFormat7VideoMode(FlyCapture2::MODE_0, FlyCapture2::PIXEL_FORMAT_MONO8, 640, 480);
g.open(I);
...
#endif
}
void setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format, unsigned int width, unsigned int height)

Definition at line 944 of file vpFlyCaptureGrabber.cpp.

References centerRoi(), connect(), vpException::fatalError, and m_camera.

◆ setFrameRate()

float vpFlyCaptureGrabber::setFrameRate ( float frame_rate)

Set camera frame rate.

Parameters
frame_rate: Camera frame rate (fps) to set.
Returns
The camera current framerate.

The following example shows how to use this function.

#include <iomanip>
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
float framerate = g.getFrameRate();
std::cout << "Cur frame rate: " << std::fixed << std::setprecision(3) << framerate << " fps" << std::endl;
framerate = g.setFrameRate(30); // Set framerate to 30 fps
std::cout << "New frame rate: " << std::fixed << std::setprecision(3) << framerate << " fps" << std::endl;
g.open(I);
while (1)
g.acquire(I);
#endif
}
float setFrameRate(float frame_rate)
See also
getFramerate()

Definition at line 527 of file vpFlyCaptureGrabber.cpp.

References connect(), getProperty(), and setProperty().

◆ setGain()

float vpFlyCaptureGrabber::setGain ( bool gain_auto,
float gain_value = 0 )

Set camera gain mode and value.

Parameters
gain_auto: If true set auto gain, if false set manual gain applying gain_value parameter.
gain_value: The amount of amplification that is applied to a pixel in manual mode. An increase in gain can result in an increase in noise.
Returns
The measured gain after applying the new setting.

The following example shows how to use this function:

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
float gain_db = g.getGain();
std::cout << "Gain: " << gain_db << " db" << std::endl;
gain_db = g.setGain(false, 5); // Turn manual gain on to 5db
std::cout << "Gain manual: " << gain_db << " db" << std::endl;
gain_db = g.setGain(true); // Turn auto shutter on
std::cout << "Gain auto : " << gain_db << " db" << std::endl;
g.open(I);
...
#endif
}
float setGain(bool gain_auto, float gain_value=0)
See also
getGain()

Definition at line 621 of file vpFlyCaptureGrabber.cpp.

References connect(), getProperty(), and setProperty().

◆ setProperty()

void vpFlyCaptureGrabber::setProperty ( const FlyCapture2::PropertyType & prop_type,
bool on,
bool auto_on,
float value,
PropertyValue prop_value = ABS_VALUE )
protected

Set camera property.

Parameters
prop_type: Property type.
on: true to turn property on.
auto_on: true to turn auto mode on, false to turn manual mode.
value: value to set.
prop_value: Switch to affect value to the corresponding variable.

Definition at line 454 of file vpFlyCaptureGrabber.cpp.

References ABS_VALUE, connect(), vpException::fatalError, getPropertyInfo(), m_camera, and VALUE_A.

Referenced by setBrightness(), setExposure(), setFrameRate(), setGain(), setSharpness(), and setShutter().

◆ setSharpness()

unsigned int vpFlyCaptureGrabber::setSharpness ( bool sharpness_on,
bool sharpness_auto,
unsigned int sharpness_value = 0 )

Set camera sharpness mode and parameter.

Parameters
sharpness_on: If true turn sharpness on, otherwise turn off.
sharpness_auto: If true set auto sharpness, if false set manual sharpness applying sharpness_value parameter.
sharpness_value: Parameter used to tune the filter applied on the image to reduce blurred edges in an image.
Returns
The measured sharpness after applying the new setting.

The following example shows how to use this function:

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
float sharpness = g.getSharpness();
std::cout << "Sharpness : " << sharpness << std::endl;
sharpness = g.setSharpness(true, false, 1000); // Turn manual sharpness on to 1000
std::cout << "Sharpness manual: " << sharpness << std::endl;
sharpness = g.setSharpness(true, true); // Turn auto sharpness on
std::cout << "Sharpness auto : " << sharpness << std::endl;
g.open(I);
...
#endif
}
unsigned int setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value=0)
See also
getSharpness()

Definition at line 779 of file vpFlyCaptureGrabber.cpp.

References connect(), getProperty(), setProperty(), and VALUE_A.

◆ setShutter()

float vpFlyCaptureGrabber::setShutter ( bool auto_shutter,
float shutter_ms = 10 )

Set camera shutter mode and parameter.

Parameters
auto_shutter: If true set auto shutter, if false set manual shutter applying shutter_ms parameter.
shutter_ms: This is the speed at which the camera shutter opens and closes in manual mode.
Returns
The measured shutter after applying the new setting.

The following example shows how to use this function:

#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
float shutter_ms = g.getShutter();
std::cout << "Shutter : " << shutter_ms << " ms" << std::endl;
shutter_ms = g.setShutter(false, 10); // Turn manual shutter on to 10ms
std::cout << "Shutter manual: " << shutter_ms << " ms" << std::endl;
shutter_ms = g.setShutter(true); // Turn auto shutter on
std::cout << "Shutter auto : " << shutter_ms << " ms" << std::endl;
g.open(I);
...
#endif
}
float setShutter(bool auto_shutter, float shutter_ms=10)
See also
getShutter()

Definition at line 573 of file vpFlyCaptureGrabber.cpp.

References connect(), getProperty(), and setProperty().

◆ setVideoModeAndFrameRate()

void vpFlyCaptureGrabber::setVideoModeAndFrameRate ( FlyCapture2::VideoMode video_mode,
FlyCapture2::FrameRate frame_rate )

Set video mode and framerate of the active camera.

Parameters
video_mode: Camera video mode.
frame_rate: Camera frame rate.

The following example shows how to use this function to set the camera image resolution to 1280 x 960, pixel format to Y8 and capture framerate to 60 fps.

#include <visp3/core/vpImage.h>
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
#if defined(VISP_HAVE_FLYCAPTURE)
int nframes = 100;
g.setCameraIndex(0); // Default camera is the first on the bus
g.setVideoModeAndFrameRate(FlyCapture2::VIDEOMODE_1280x960Y8, FlyCapture2::FRAMERATE_60);
g.open(I);
g.getCameraInfo(std::cout);
for(int i=0; i< nframes; i++) {
g.acquire(I);
}
#endif
}

Definition at line 862 of file vpFlyCaptureGrabber.cpp.

References connect(), vpException::fatalError, and m_camera.

◆ startCapture()

void vpFlyCaptureGrabber::startCapture ( )

Start active camera capturing images.

See also
stopCapture()

Definition at line 1017 of file vpFlyCaptureGrabber.cpp.

References connect(), vpException::fatalError, getCameraSerial(), vpFrameGrabber::init, m_camera, m_capture, m_connected, and m_index.

Referenced by open().

◆ stopCapture()

void vpFlyCaptureGrabber::stopCapture ( )

Stop active camera capturing images.

See also
startCapture()

Definition at line 1043 of file vpFlyCaptureGrabber.cpp.

References vpException::fatalError, vpFrameGrabber::init, m_camera, m_capture, and m_connected.

Referenced by close().

Member Data Documentation

◆ height

◆ init

◆ m_camera

◆ m_capture

bool vpFlyCaptureGrabber::m_capture
protected

true is capture started

Definition at line 242 of file vpFlyCaptureGrabber.h.

Referenced by connect(), disconnect(), isCaptureStarted(), startCapture(), stopCapture(), and vpFlyCaptureGrabber().

◆ m_connected

bool vpFlyCaptureGrabber::m_connected
protected

true if camera connected

Definition at line 241 of file vpFlyCaptureGrabber.h.

Referenced by connect(), disconnect(), getCameraHandler(), isConnected(), startCapture(), stopCapture(), and vpFlyCaptureGrabber().

◆ m_guid

FlyCapture2::PGRGuid vpFlyCaptureGrabber::m_guid
protected

Active camera guid.

Definition at line 237 of file vpFlyCaptureGrabber.h.

Referenced by connect(), and vpFlyCaptureGrabber().

◆ m_index

unsigned int vpFlyCaptureGrabber::m_index
protected

◆ m_numCameras

unsigned int vpFlyCaptureGrabber::m_numCameras
protected

Number of connected cameras.

Definition at line 239 of file vpFlyCaptureGrabber.h.

Referenced by connect(), setCameraIndex(), setCameraSerial(), and vpFlyCaptureGrabber().

◆ m_rawImage

FlyCapture2::Image vpFlyCaptureGrabber::m_rawImage
protected

Image buffer.

Definition at line 240 of file vpFlyCaptureGrabber.h.

Referenced by acquire(), acquire(), and vpFlyCaptureGrabber().

◆ width