40#include <visp3/core/vpException.h>
41#include <visp3/sensor/vpFlyCaptureGrabber.h>
43#ifdef VISP_HAVE_FLYCAPTURE
45#include <visp3/core/vpTime.h>
68 unsigned int numCameras;
69 FlyCapture2::BusManager busMgr;
70 FlyCapture2::Error error = busMgr.GetNumOfCameras(&numCameras);
71 if (error != FlyCapture2::PGRERROR_OK) {
85 FlyCapture2::CameraInfo camInfo;
86 FlyCapture2::Error error =
m_camera.GetCameraInfo(&camInfo);
87 if (error != FlyCapture2::PGRERROR_OK) {
88 error.PrintErrorTrace();
91 os <<
"Camera information: " << std::endl;
92 os <<
" Serial number : " << camInfo.serialNumber << std::endl;
93 os <<
" Camera model : " << camInfo.modelName << std::endl;
94 os <<
" Camera vendor : " << camInfo.vendorName << std::endl;
95 os <<
" Sensor : " << camInfo.sensorInfo << std::endl;
96 os <<
" Resolution : " << camInfo.sensorResolution << std::endl;
97 os <<
" Firmware version : " << camInfo.firmwareVersion << std::endl;
98 os <<
" Firmware build time: " << camInfo.firmwareBuildTime << std::endl;
216 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::FRAME_RATE);
217 return prop.absValue;
236 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHUTTER);
237 return prop.absValue;
256 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::GAIN);
257 return prop.absValue;
276 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::BRIGHTNESS);
277 return prop.absValue;
296 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHARPNESS);
316 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::AUTO_EXPOSURE);
317 return prop.absValue;
358 if (index >= num_cameras) {
360 index, num_cameras));
362 unsigned int serial_id;
363 FlyCapture2::BusManager busMgr;
364 FlyCapture2::Error error;
365 error = busMgr.GetCameraSerialNumberFromIndex(index, &serial_id);
366 if (error != FlyCapture2::PGRERROR_OK) {
367 error.PrintErrorTrace();
433 FlyCapture2::BusManager busMgr;
434 FlyCapture2::Error error;
459 FlyCapture2::PropertyInfo propInfo;
462 if (propInfo.present) {
463 FlyCapture2::Property prop;
464 prop.type = prop_type;
465 prop.onOff = on && propInfo.onOffSupported;
466 prop.autoManualMode = auto_on && propInfo.autoSupported;
467 prop.absControl = propInfo.absValSupported;
468 switch (prop_value) {
470 float value_ = std::max<float>(std::min<float>(
static_cast<float>(value),
static_cast<float>(propInfo.absMax)),
static_cast<float>(propInfo.absMin));
471 prop.absValue = value_;
475 unsigned int value_ =
476 std::max<unsigned int>(std::min<unsigned int>(
static_cast<unsigned int>(value),
static_cast<unsigned int>(propInfo.max)),
static_cast<unsigned int>(propInfo.min));
477 prop.valueA = value_;
482 FlyCapture2::Error error;
483 error =
m_camera.SetProperty(&prop);
484 if (error != FlyCapture2::PGRERROR_OK) {
485 error.PrintErrorTrace();
531 this->
setProperty(FlyCapture2::FRAME_RATE,
true,
false, frame_rate);
532 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::FRAME_RATE);
533 return prop.absValue;
577 this->
setProperty(FlyCapture2::SHUTTER,
true, auto_shutter, shutter_ms);
578 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHUTTER);
579 return prop.absValue;
625 this->
setProperty(FlyCapture2::GAIN,
true, gain_auto, gain_value);
626 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::GAIN);
627 return prop.absValue;
673 this->
setProperty(FlyCapture2::BRIGHTNESS,
true, brightness_auto, brightness_value);
674 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::BRIGHTNESS);
675 return prop.absValue;
731 this->
setProperty(FlyCapture2::AUTO_EXPOSURE, exposure_on, exposure_auto, exposure_value);
732 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::AUTO_EXPOSURE);
733 return prop.absValue;
783 this->
setProperty(FlyCapture2::SHARPNESS, sharpness_on, sharpness_auto,
static_cast<float>(sharpness_value),
VALUE_A);
784 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHARPNESS);
796 FlyCapture2::Property prop;
797 prop.type = prop_type;
798 FlyCapture2::Error error;
799 error =
m_camera.GetProperty(&prop);
800 if (error != FlyCapture2::PGRERROR_OK) {
801 error.PrintErrorTrace();
816 FlyCapture2::PropertyInfo propInfo;
817 propInfo.type = prop_type;
819 FlyCapture2::Error error;
820 error =
m_camera.GetPropertyInfo(&propInfo);
821 if (error != FlyCapture2::PGRERROR_OK) {
822 error.PrintErrorTrace();
866 FlyCapture2::Error error;
867 error =
m_camera.SetVideoModeAndFrameRate(video_mode, frame_rate);
868 if (error != FlyCapture2::PGRERROR_OK) {
869 error.PrintErrorTrace();
878 FlyCapture2::FrameRate frame_rate)
882 FlyCapture2::Error error;
883 bool supported =
false;
884 error =
m_camera.GetVideoModeAndFrameRateInfo(video_mode, frame_rate, &supported);
885 if (error != FlyCapture2::PGRERROR_OK) {
886 error.PrintErrorTrace();
900 if (size == 0 || size > max_size)
903 size = size / step * step;
904 const unsigned int offset = (max_size - size) / 2;
906 return std::make_pair(size, offset);
945 unsigned int w,
unsigned int h)
949 FlyCapture2::Format7Info fmt7_info;
951 FlyCapture2::Error error;
953 fmt7_info.mode = format7_mode;
954 error =
m_camera.GetFormat7Info(&fmt7_info, &fmt7_supported);
955 if (error != FlyCapture2::PGRERROR_OK) {
956 error.PrintErrorTrace();
959 if (!fmt7_supported) {
963 FlyCapture2::Format7ImageSettings fmt7_settings;
964 fmt7_settings.mode = format7_mode;
965 fmt7_settings.pixelFormat = pixel_format;
967 std::pair<unsigned int, unsigned int> roi_w = this->
centerRoi(w, fmt7_info.maxWidth, fmt7_info.imageHStepSize);
968 std::pair<unsigned int, unsigned int> roi_h = this->
centerRoi(h, fmt7_info.maxHeight, fmt7_info.imageVStepSize);
969 fmt7_settings.width = roi_w.first;
970 fmt7_settings.offsetX = roi_w.second;
971 fmt7_settings.height = roi_h.first;
972 fmt7_settings.offsetY = roi_h.second;
975 FlyCapture2::Format7PacketInfo fmt7_packet_info;
977 error =
m_camera.ValidateFormat7Settings(&fmt7_settings, &valid, &fmt7_packet_info);
978 if (error != FlyCapture2::PGRERROR_OK) {
979 error.PrintErrorTrace();
985 error =
m_camera.SetFormat7Configuration(&fmt7_settings, fmt7_packet_info.recommendedBytesPerPacket);
986 if (error != FlyCapture2::PGRERROR_OK) {
987 error.PrintErrorTrace();
999 FlyCapture2::Format7Info fmt7_info;
1000 bool supported =
false;
1001 FlyCapture2::Error error;
1003 fmt7_info.mode = format7_mode;
1004 error =
m_camera.GetFormat7Info(&fmt7_info, &supported);
1005 if (error != FlyCapture2::PGRERROR_OK) {
1006 error.PrintErrorTrace();
1023 FlyCapture2::Error error;
1025 if (error != FlyCapture2::PGRERROR_OK) {
1026 error.PrintErrorTrace();
1047 FlyCapture2::Error error;
1049 if (error != FlyCapture2::PGRERROR_OK) {
1050 error.PrintErrorTrace();
1069 FlyCapture2::Error error;
1075 FlyCapture2::BusManager busMgr;
1078 if (error != FlyCapture2::PGRERROR_OK) {
1079 error.PrintErrorTrace();
1084 if (error != FlyCapture2::PGRERROR_OK) {
1085 error.PrintErrorTrace();
1105 FlyCapture2::Error error;
1107 if (error != FlyCapture2::PGRERROR_OK) {
1108 error.PrintErrorTrace();
1146 FlyCapture2::TimeStamp timestamp;
1161 FlyCapture2::Error error;
1164 if (error != FlyCapture2::PGRERROR_OK) {
1165 error.PrintErrorTrace();
1178 FlyCapture2::Image convertedImage(
height,
width,
sizeof(
unsigned char) *
width, I.bitmap,
1179 sizeof(
unsigned char) * I.getSize(), FlyCapture2::PIXEL_FORMAT_MONO8);
1182 error =
m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_MONO8, &convertedImage);
1183 if (error != FlyCapture2::PGRERROR_OK) {
1184 error.PrintErrorTrace();
1197 FlyCapture2::TimeStamp timestamp;
1212 FlyCapture2::Error error;
1215 if (error != FlyCapture2::PGRERROR_OK) {
1216 error.PrintErrorTrace();
1222 FlyCapture2::Image convertedImage;
1225 error =
m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGBU, &convertedImage);
1226 if (error != FlyCapture2::PGRERROR_OK) {
1227 error.PrintErrorTrace();
1231 height = convertedImage.GetRows();
1232 width = convertedImage.GetCols();
1235 unsigned char *data = convertedImage.GetData();
1236 unsigned int stride = convertedImage.GetStride();
1237 unsigned int Bps = convertedImage.GetBitsPerPixel() / 8;
1241 for (
unsigned int i = 0; i <
height; ++i) {
1242 for (
unsigned int j = 0; j <
width; ++j) {
1243 unsigned char *pp = data + i * stride + j * Bps;
1298 const unsigned int powerReg = 0x400;
1299 unsigned int powerRegVal = 0;
1301 FlyCapture2::Error error;
1302 error =
m_camera.ReadRegister(powerReg, &powerRegVal);
1303 if (error != FlyCapture2::PGRERROR_OK) {
1307 return ((powerRegVal & 0x00008000) != 0);
1319 const unsigned int powerReg = 0x610;
1320 unsigned int powerRegVal = 0;
1322 FlyCapture2::Error error;
1323 error =
m_camera.ReadRegister(powerReg, &powerRegVal);
1324 if (error != FlyCapture2::PGRERROR_OK) {
1328 return ((powerRegVal & (0x1 << 31)) != 0);
1372 const unsigned int powerReg = 0x610;
1373 unsigned int powerRegVal = 0;
1375 powerRegVal = (on ==
true) ? 0x80000000 : 0x0;
1377 FlyCapture2::Error error;
1378 error =
m_camera.WriteRegister(powerReg, powerRegVal);
1379 if (error != FlyCapture2::PGRERROR_OK) {
1380 error.PrintErrorTrace();
1384 unsigned int millisecondsToSleep = 100;
1385 unsigned int regVal = 0;
1386 unsigned int retries = 10;
1391 error =
m_camera.ReadRegister(powerReg, ®Val);
1392 if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1396 else if (error != FlyCapture2::PGRERROR_OK) {
1397 error.PrintErrorTrace();
1402 }
while ((regVal & powerRegVal) == 0 && retries > 0);
1405 if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1406 error.PrintErrorTrace();
1465void dummy_vpFlyCaptureGrabber() { }
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
unsigned int getSharpness()
FlyCapture2::Camera * getCameraHandler()
static unsigned int getNumCameras()
FlyCapture2::Image m_rawImage
Image buffer.
float setGain(bool gain_auto, float gain_value=0)
std::pair< unsigned int, unsigned int > centerRoi(unsigned int size, unsigned int max_size, unsigned int step)
float setShutter(bool auto_shutter, float shutter_ms=10)
void setCameraPower(bool on)
float setExposure(bool exposure_on, bool exposure_auto, float exposure_value=0)
void setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value, PropertyValue prop_value=ABS_VALUE)
bool m_capture
true is capture started
vpFlyCaptureGrabber & operator>>(vpImage< unsigned char > &I)
void setCameraSerial(unsigned int serial)
void setCameraIndex(unsigned int index)
float setFrameRate(float frame_rate)
bool isCameraPowerAvailable()
FlyCapture2::Camera m_camera
Pointer to each camera.
unsigned int m_index
Active camera index.
FlyCapture2::PropertyInfo getPropertyInfo(FlyCapture2::PropertyType prop_type)
static unsigned int getCameraSerial(unsigned int index)
void setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format, unsigned int width, unsigned int height)
unsigned int m_numCameras
Number of connected cameras.
unsigned int setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value=0)
void acquire(vpImage< unsigned char > &I)
FlyCapture2::Property getProperty(FlyCapture2::PropertyType prop_type)
bool isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
std::ostream & getCameraInfo(std::ostream &os)
bool isFormat7Supported(FlyCapture2::Mode format7_mode)
@ VALUE_A
Consider FlyCapture2::Property::valueA.
@ ABS_VALUE
Consider FlyCapture2::Property::absValue.
virtual ~vpFlyCaptureGrabber()
void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
bool m_connected
true if camera connected
FlyCapture2::PGRGuid m_guid
Active camera guid.
float setBrightness(bool brightness_auto, float brightness_value=0)
unsigned int height
Number of rows in the image.
bool init
Set to true if the frame grabber has been initialized.
unsigned int width
Number of columns in the image.
Definition of the vpImage class member functions.
VISP_EXPORT int wait(double t0, double t)