45 #include <visp3/core/vpException.h> 46 #include <visp3/sensor/vpFlyCaptureGrabber.h> 48 #ifdef VISP_HAVE_FLYCAPTURE 50 #include <visp3/core/vpTime.h> 57 : m_camera(), m_guid(), m_index(0), m_numCameras(0), m_rawImage(), m_connected(false), m_capture(false)
71 unsigned int numCameras;
72 FlyCapture2::BusManager busMgr;
73 FlyCapture2::Error error = busMgr.GetNumOfCameras(&numCameras);
74 if (error != FlyCapture2::PGRERROR_OK) {
88 FlyCapture2::CameraInfo camInfo;
89 FlyCapture2::Error error =
m_camera.GetCameraInfo(&camInfo);
90 if (error != FlyCapture2::PGRERROR_OK) {
91 error.PrintErrorTrace();
94 os <<
"Camera information: " << std::endl;
95 os <<
" Serial number : " << camInfo.serialNumber << std::endl;
96 os <<
" Camera model : " << camInfo.modelName << std::endl;
97 os <<
" Camera vendor : " << camInfo.vendorName << std::endl;
98 os <<
" Sensor : " << camInfo.sensorInfo << std::endl;
99 os <<
" Resolution : " << camInfo.sensorResolution << std::endl;
100 os <<
" Firmware version : " << camInfo.firmwareVersion << std::endl;
101 os <<
" Firmware build time: " << camInfo.firmwareBuildTime << std::endl;
211 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::FRAME_RATE);
212 return prop.absValue;
231 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHUTTER);
232 return prop.absValue;
251 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::GAIN);
252 return prop.absValue;
271 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::BRIGHTNESS);
272 return prop.absValue;
291 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHARPNESS);
311 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::AUTO_EXPOSURE);
312 return prop.absValue;
349 if (index >= num_cameras) {
351 index, num_cameras));
353 unsigned int serial_id;
354 FlyCapture2::BusManager busMgr;
355 FlyCapture2::Error error;
356 error = busMgr.GetCameraSerialNumberFromIndex(index, &serial_id);
357 if (error != FlyCapture2::PGRERROR_OK) {
358 error.PrintErrorTrace();
420 FlyCapture2::BusManager busMgr;
421 FlyCapture2::Error error;
446 FlyCapture2::PropertyInfo propInfo;
449 if (propInfo.present) {
450 FlyCapture2::Property prop;
451 prop.type = prop_type;
452 prop.onOff = on && propInfo.onOffSupported;
453 prop.autoManualMode = auto_on && propInfo.autoSupported;
454 prop.absControl = propInfo.absValSupported;
455 switch (prop_value) {
457 float value_ = (std::max)((std::min)((float)value, (
float)propInfo.absMax), (
float)propInfo.absMin);
458 prop.absValue = value_;
462 unsigned int value_ =
463 (std::max)((std::min)((
unsigned int)value, (
unsigned int)propInfo.max), (
unsigned int)propInfo.min);
464 prop.valueA = value_;
469 FlyCapture2::Error error;
470 error =
m_camera.SetProperty(&prop);
471 if (error != FlyCapture2::PGRERROR_OK) {
472 error.PrintErrorTrace();
514 this->
setProperty(FlyCapture2::FRAME_RATE,
true,
false, frame_rate);
515 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::FRAME_RATE);
516 return prop.absValue;
557 this->
setProperty(FlyCapture2::SHUTTER,
true, auto_shutter, shutter_ms);
558 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHUTTER);
559 return prop.absValue;
601 this->
setProperty(FlyCapture2::GAIN,
true, gain_auto, gain_value);
602 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::GAIN);
603 return prop.absValue;
645 this->
setProperty(FlyCapture2::BRIGHTNESS,
true, brightness_auto, brightness_value);
646 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::BRIGHTNESS);
647 return prop.absValue;
698 this->
setProperty(FlyCapture2::AUTO_EXPOSURE, exposure_on, exposure_auto, exposure_value);
699 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::AUTO_EXPOSURE);
700 return prop.absValue;
745 this->
setProperty(FlyCapture2::SHARPNESS, sharpness_on, sharpness_auto, (
float)sharpness_value,
VALUE_A);
746 FlyCapture2::Property prop = this->
getProperty(FlyCapture2::SHARPNESS);
758 FlyCapture2::Property prop;
759 prop.type = prop_type;
760 FlyCapture2::Error error;
761 error =
m_camera.GetProperty(&prop);
762 if (error != FlyCapture2::PGRERROR_OK) {
763 error.PrintErrorTrace();
778 FlyCapture2::PropertyInfo propInfo;
779 propInfo.type = prop_type;
781 FlyCapture2::Error error;
782 error =
m_camera.GetPropertyInfo(&propInfo);
783 if (error != FlyCapture2::PGRERROR_OK) {
784 error.PrintErrorTrace();
824 FlyCapture2::Error error;
825 error =
m_camera.SetVideoModeAndFrameRate(video_mode, frame_rate);
826 if (error != FlyCapture2::PGRERROR_OK) {
827 error.PrintErrorTrace();
836 FlyCapture2::FrameRate frame_rate)
840 FlyCapture2::Error error;
841 bool supported =
false;
842 error =
m_camera.GetVideoModeAndFrameRateInfo(video_mode, frame_rate, &supported);
843 if (error != FlyCapture2::PGRERROR_OK) {
844 error.PrintErrorTrace();
858 if (size == 0 || size > max_size)
861 size = size / step * step;
862 const unsigned int offset = (max_size - size) / 2;
864 return std::make_pair(size, offset);
905 FlyCapture2::Format7Info fmt7_info;
907 FlyCapture2::Error error;
909 fmt7_info.mode = format7_mode;
910 error =
m_camera.GetFormat7Info(&fmt7_info, &fmt7_supported);
911 if (error != FlyCapture2::PGRERROR_OK) {
912 error.PrintErrorTrace();
915 if (!fmt7_supported) {
919 FlyCapture2::Format7ImageSettings fmt7_settings;
920 fmt7_settings.mode = format7_mode;
921 fmt7_settings.pixelFormat = pixel_format;
923 std::pair<unsigned int, unsigned int> roi_w = this->
centerRoi(width, fmt7_info.maxWidth, fmt7_info.imageHStepSize);
924 std::pair<unsigned int, unsigned int> roi_h = this->
centerRoi(height, fmt7_info.maxHeight, fmt7_info.imageVStepSize);
925 fmt7_settings.width = roi_w.first;
926 fmt7_settings.offsetX = roi_w.second;
927 fmt7_settings.height = roi_h.first;
928 fmt7_settings.offsetY = roi_h.second;
931 FlyCapture2::Format7PacketInfo fmt7_packet_info;
933 error =
m_camera.ValidateFormat7Settings(&fmt7_settings, &valid, &fmt7_packet_info);
934 if (error != FlyCapture2::PGRERROR_OK) {
935 error.PrintErrorTrace();
941 error =
m_camera.SetFormat7Configuration(&fmt7_settings, fmt7_packet_info.recommendedBytesPerPacket);
942 if (error != FlyCapture2::PGRERROR_OK) {
943 error.PrintErrorTrace();
955 FlyCapture2::Format7Info fmt7_info;
956 bool supported =
false;
957 FlyCapture2::Error error;
959 fmt7_info.mode = format7_mode;
960 error =
m_camera.GetFormat7Info(&fmt7_info, &supported);
961 if (error != FlyCapture2::PGRERROR_OK) {
962 error.PrintErrorTrace();
979 FlyCapture2::Error error;
981 if (error != FlyCapture2::PGRERROR_OK) {
982 error.PrintErrorTrace();
1003 FlyCapture2::Error error;
1005 if (error != FlyCapture2::PGRERROR_OK) {
1006 error.PrintErrorTrace();
1025 FlyCapture2::Error error;
1031 FlyCapture2::BusManager busMgr;
1034 if (error != FlyCapture2::PGRERROR_OK) {
1035 error.PrintErrorTrace();
1040 if (error != FlyCapture2::PGRERROR_OK) {
1041 error.PrintErrorTrace();
1061 FlyCapture2::Error error;
1063 if (error != FlyCapture2::PGRERROR_OK) {
1064 error.PrintErrorTrace();
1102 FlyCapture2::TimeStamp timestamp;
1117 FlyCapture2::Error error;
1120 if (error != FlyCapture2::PGRERROR_OK) {
1121 error.PrintErrorTrace();
1136 sizeof(
unsigned char) * I.
getSize(), FlyCapture2::PIXEL_FORMAT_MONO8);
1139 error =
m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_MONO8, &convertedImage);
1140 if (error != FlyCapture2::PGRERROR_OK) {
1141 error.PrintErrorTrace();
1154 FlyCapture2::TimeStamp timestamp;
1169 FlyCapture2::Error error;
1172 if (error != FlyCapture2::PGRERROR_OK) {
1173 error.PrintErrorTrace();
1180 FlyCapture2::Image convertedImage;
1183 error =
m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGBU, &convertedImage);
1184 if (error != FlyCapture2::PGRERROR_OK) {
1185 error.PrintErrorTrace();
1189 height = convertedImage.GetRows();
1190 width = convertedImage.GetCols();
1193 unsigned char *data = convertedImage.GetData();
1194 unsigned int stride = convertedImage.GetStride();
1195 unsigned int Bps = convertedImage.GetBitsPerPixel() / 8;
1199 for (
unsigned int i = 0; i <
height; ++i) {
1200 for (
unsigned int j = 0; j <
width; ++j) {
1201 unsigned char *pp = data + i * stride + j * Bps;
1256 const unsigned int powerReg = 0x400;
1257 unsigned int powerRegVal = 0;
1259 FlyCapture2::Error error;
1260 error =
m_camera.ReadRegister(powerReg, &powerRegVal);
1261 if (error != FlyCapture2::PGRERROR_OK) {
1265 return ((powerRegVal & 0x00008000) != 0);
1277 const unsigned int powerReg = 0x610;
1278 unsigned int powerRegVal = 0;
1280 FlyCapture2::Error error;
1281 error =
m_camera.ReadRegister(powerReg, &powerRegVal);
1282 if (error != FlyCapture2::PGRERROR_OK) {
1286 return ((powerRegVal & (0x1 << 31)) != 0);
1326 const unsigned int powerReg = 0x610;
1327 unsigned int powerRegVal = 0;
1329 powerRegVal = (on ==
true) ? 0x80000000 : 0x0;
1331 FlyCapture2::Error error;
1332 error =
m_camera.WriteRegister(powerReg, powerRegVal);
1333 if (error != FlyCapture2::PGRERROR_OK) {
1334 error.PrintErrorTrace();
1338 const unsigned int millisecondsToSleep = 100;
1339 unsigned int regVal = 0;
1340 unsigned int retries = 10;
1345 error =
m_camera.ReadRegister(powerReg, ®Val);
1346 if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1349 }
else if (error != FlyCapture2::PGRERROR_OK) {
1350 error.PrintErrorTrace();
1355 }
while ((regVal & powerRegVal) == 0 && retries > 0);
1358 if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1359 error.PrintErrorTrace();
1411 void dummy_vpFlyCaptureGrabber(){};
Used to indicate that a value is not in the allowed range.
void setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format, unsigned int width, unsigned int height)
FlyCapture2::Image m_rawImage
Image buffer.
VISP_EXPORT int wait(double t0, double t)
FlyCapture2::Camera m_camera
Pointer to each camera.
Type * bitmap
points toward the bitmap
unsigned int getSharpness()
void setCameraSerial(unsigned int serial)
float setShutter(bool auto_shutter, float shutter_ms=10)
void acquire(vpImage< unsigned char > &I)
error that can be emited by ViSP classes.
bool isCameraPowerAvailable()
float setBrightness(bool brightness_auto, float brightness_value=0)
Consider FlyCapture2::Property::valueA.
FlyCapture2::Camera * getCameraHandler()
void setCameraIndex(unsigned int index)
std::pair< unsigned int, unsigned int > centerRoi(unsigned int size, unsigned int max_size, unsigned int step)
float setExposure(bool exposure_on, bool exposure_auto, float exposure_value=0)
float setGain(bool gain_auto, float gain_value=0)
unsigned int getSize() const
FlyCapture2::PGRGuid m_guid
Active camera guid.
unsigned int height
Number of rows in the image.
void setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value, PropertyValue prop_value=ABS_VALUE)
FlyCapture2::PropertyInfo getPropertyInfo(FlyCapture2::PropertyType prop_type)
bool isFormat7Supported(FlyCapture2::Mode format7_mode)
bool m_connected
true if camera connected
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
Consider FlyCapture2::Property::absValue.
unsigned int setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value=0)
bool m_capture
true is capture started
vpFlyCaptureGrabber & operator>>(vpImage< unsigned char > &I)
FlyCapture2::Property getProperty(FlyCapture2::PropertyType prop_type)
bool init
Set to true if the frame grabber has been initialized.
static unsigned int getNumCameras()
virtual ~vpFlyCaptureGrabber()
unsigned int m_index
Active camera index.
static unsigned int getCameraSerial(unsigned int index)
float setFrameRate(float frame_rate)
unsigned int m_numCameras
Number of connected cameras.
std::ostream & getCameraInfo(std::ostream &os)
void setCameraPower(bool on)
bool isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
unsigned int width
Number of columns in the image.
void setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)