Visual Servoing Platform  version 3.6.1 under development (2024-02-13)
vpFlyCaptureGrabber.cpp
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 #include <visp3/core/vpException.h>
43 #include <visp3/sensor/vpFlyCaptureGrabber.h>
44 
45 #ifdef VISP_HAVE_FLYCAPTURE
46 
47 #include <visp3/core/vpTime.h>
48 
54  : m_camera(), m_guid(), m_index(0), m_numCameras(0), m_rawImage(), m_connected(false), m_capture(false)
55 {
56  m_numCameras = this->getNumCameras();
57 }
58 
67 {
68  unsigned int numCameras;
69  FlyCapture2::BusManager busMgr;
70  FlyCapture2::Error error = busMgr.GetNumOfCameras(&numCameras);
71  if (error != FlyCapture2::PGRERROR_OK) {
72  numCameras = 0;
73  }
74  return numCameras;
75 }
76 
81 std::ostream &vpFlyCaptureGrabber::getCameraInfo(std::ostream &os)
82 {
83  this->connect();
84 
85  FlyCapture2::CameraInfo camInfo;
86  FlyCapture2::Error error = m_camera.GetCameraInfo(&camInfo);
87  if (error != FlyCapture2::PGRERROR_OK) {
88  error.PrintErrorTrace();
89  }
90 
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;
99  return os;
100 }
101 
182 {
183  this->connect();
184 
185  if (m_connected == true) {
186  return &m_camera;
187  }
188  else {
189  return nullptr;
190  }
191 }
192 
206 {
207  this->connect();
208 
209  FlyCapture2::Property prop = this->getProperty(FlyCapture2::FRAME_RATE);
210  return prop.absValue;
211 }
212 
226 {
227  this->connect();
228 
229  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHUTTER);
230  return prop.absValue;
231 }
232 
246 {
247  this->connect();
248 
249  FlyCapture2::Property prop = this->getProperty(FlyCapture2::GAIN);
250  return prop.absValue;
251 }
252 
266 {
267  this->connect();
268 
269  FlyCapture2::Property prop = this->getProperty(FlyCapture2::BRIGHTNESS);
270  return prop.absValue;
271 }
272 
286 {
287  this->connect();
288 
289  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHARPNESS);
290  return prop.valueA;
291 }
292 
306 {
307  this->connect();
308 
309  FlyCapture2::Property prop = this->getProperty(FlyCapture2::AUTO_EXPOSURE);
310  return prop.absValue;
311 }
312 
344 unsigned int vpFlyCaptureGrabber::getCameraSerial(unsigned int index)
345 {
346  unsigned int num_cameras = vpFlyCaptureGrabber::getNumCameras();
347  if (index >= num_cameras) {
348  throw(vpException(vpException::badValue, "The camera with index %u is not present. Only %d cameras connected.",
349  index, num_cameras));
350  }
351  unsigned int serial_id;
352  FlyCapture2::BusManager busMgr;
353  FlyCapture2::Error error;
354  error = busMgr.GetCameraSerialNumberFromIndex(index, &serial_id);
355  if (error != FlyCapture2::PGRERROR_OK) {
356  error.PrintErrorTrace();
357  throw(vpException(vpException::fatalError, "Cannot get camera with index %d serial id.", index));
358  }
359  return serial_id;
360 }
361 
377 void vpFlyCaptureGrabber::setCameraIndex(unsigned int index)
378 {
379  if (index >= m_numCameras) {
380  throw(vpException(vpException::badValue, "The camera with index %u is not present. Only %d cameras connected.",
381  index, m_numCameras));
382  }
383 
384  m_index = index;
385 }
386 
416 void vpFlyCaptureGrabber::setCameraSerial(unsigned int serial_id)
417 {
418  FlyCapture2::BusManager busMgr;
419  FlyCapture2::Error error;
420  m_numCameras = this->getNumCameras();
421  for (unsigned int i = 0; i < m_numCameras; i++) {
422  if (vpFlyCaptureGrabber::getCameraSerial(i) == serial_id) {
423  m_index = i;
424  return;
425  }
426  }
427  throw(vpException(vpException::badValue, "The camera with serial id %u is not present.", serial_id));
428 }
429 
439 void vpFlyCaptureGrabber::setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value,
440  PropertyValue prop_value)
441 {
442  this->connect();
443 
444  FlyCapture2::PropertyInfo propInfo;
445  propInfo = this->getPropertyInfo(prop_type);
446 
447  if (propInfo.present) {
448  FlyCapture2::Property prop;
449  prop.type = prop_type;
450  prop.onOff = on && propInfo.onOffSupported;
451  prop.autoManualMode = auto_on && propInfo.autoSupported;
452  prop.absControl = propInfo.absValSupported;
453  switch (prop_value) {
454  case ABS_VALUE: {
455  float value_ = std::max<float>(std::min<float>((float)value, (float)propInfo.absMax), (float)propInfo.absMin);
456  prop.absValue = value_;
457  break;
458  }
459  case VALUE_A: {
460  unsigned int value_ =
461  std::max<unsigned int>(std::min<unsigned int>((unsigned int)value, (unsigned int)propInfo.max), (unsigned int)propInfo.min);
462  prop.valueA = value_;
463  break;
464  }
465  }
466 
467  FlyCapture2::Error error;
468  error = m_camera.SetProperty(&prop);
469  if (error != FlyCapture2::PGRERROR_OK) {
470  error.PrintErrorTrace();
471  throw(vpException(vpException::fatalError, "Cannot set property %d.", (int)prop_type));
472  }
473  }
474 }
475 
508 float vpFlyCaptureGrabber::setFrameRate(float frame_rate)
509 {
510  this->connect();
511 
512  this->setProperty(FlyCapture2::FRAME_RATE, true, false, frame_rate);
513  FlyCapture2::Property prop = this->getProperty(FlyCapture2::FRAME_RATE);
514  return prop.absValue;
515 }
516 
551 float vpFlyCaptureGrabber::setShutter(bool auto_shutter, float shutter_ms)
552 {
553  this->connect();
554 
555  this->setProperty(FlyCapture2::SHUTTER, true, auto_shutter, shutter_ms);
556  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHUTTER);
557  return prop.absValue;
558 }
559 
595 float vpFlyCaptureGrabber::setGain(bool gain_auto, float gain_value)
596 {
597  this->connect();
598 
599  this->setProperty(FlyCapture2::GAIN, true, gain_auto, gain_value);
600  FlyCapture2::Property prop = this->getProperty(FlyCapture2::GAIN);
601  return prop.absValue;
602 }
603 
639 float vpFlyCaptureGrabber::setBrightness(bool brightness_auto, float brightness_value)
640 {
641  this->connect();
642 
643  this->setProperty(FlyCapture2::BRIGHTNESS, true, brightness_auto, brightness_value);
644  FlyCapture2::Property prop = this->getProperty(FlyCapture2::BRIGHTNESS);
645  return prop.absValue;
646 }
647 
692 float vpFlyCaptureGrabber::setExposure(bool exposure_on, bool exposure_auto, float exposure_value)
693 {
694  this->connect();
695 
696  this->setProperty(FlyCapture2::AUTO_EXPOSURE, exposure_on, exposure_auto, exposure_value);
697  FlyCapture2::Property prop = this->getProperty(FlyCapture2::AUTO_EXPOSURE);
698  return prop.absValue;
699 }
700 
739 unsigned int vpFlyCaptureGrabber::setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value)
740 {
741  this->connect();
742 
743  this->setProperty(FlyCapture2::SHARPNESS, sharpness_on, sharpness_auto, (float)sharpness_value, VALUE_A);
744  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHARPNESS);
745  return prop.valueA;
746 }
747 
752 FlyCapture2::Property vpFlyCaptureGrabber::getProperty(FlyCapture2::PropertyType prop_type)
753 {
754  this->connect();
755 
756  FlyCapture2::Property prop;
757  prop.type = prop_type;
758  FlyCapture2::Error error;
759  error = m_camera.GetProperty(&prop);
760  if (error != FlyCapture2::PGRERROR_OK) {
761  error.PrintErrorTrace();
762  throw(vpException(vpException::fatalError, "Cannot get property %d value.", (int)prop_type));
763  }
764  return prop;
765 }
766 
772 FlyCapture2::PropertyInfo vpFlyCaptureGrabber::getPropertyInfo(FlyCapture2::PropertyType prop_type)
773 {
774  this->connect();
775 
776  FlyCapture2::PropertyInfo propInfo;
777  propInfo.type = prop_type;
778 
779  FlyCapture2::Error error;
780  error = m_camera.GetPropertyInfo(&propInfo);
781  if (error != FlyCapture2::PGRERROR_OK) {
782  error.PrintErrorTrace();
783  throw(vpException(vpException::fatalError, "Cannot get property %d info.", (int)prop_type));
784  }
785  return propInfo;
786 }
787 
818 void vpFlyCaptureGrabber::setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
819 {
820  this->connect();
821 
822  FlyCapture2::Error error;
823  error = m_camera.SetVideoModeAndFrameRate(video_mode, frame_rate);
824  if (error != FlyCapture2::PGRERROR_OK) {
825  error.PrintErrorTrace();
826  throw(vpException(vpException::fatalError, "Cannot set video mode and framerate."));
827  }
828 }
829 
833 bool vpFlyCaptureGrabber::isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode,
834  FlyCapture2::FrameRate frame_rate)
835 {
836  this->connect();
837 
838  FlyCapture2::Error error;
839  bool supported = false;
840  error = m_camera.GetVideoModeAndFrameRateInfo(video_mode, frame_rate, &supported);
841  if (error != FlyCapture2::PGRERROR_OK) {
842  error.PrintErrorTrace();
843  throw(vpException(vpException::fatalError, "Cannot get video mode and framerate."));
844  }
845  return supported;
846 }
847 
853 std::pair<unsigned int, unsigned int> vpFlyCaptureGrabber::centerRoi(unsigned int size, unsigned int max_size,
854  unsigned int step)
855 {
856  if (size == 0 || size > max_size)
857  size = max_size;
858  // size should be a multiple of step
859  size = size / step * step;
860  const unsigned int offset = (max_size - size) / 2;
861  // Return offset for centering roi
862  return std::make_pair(size, offset);
863 }
864 
898 void vpFlyCaptureGrabber::setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format,
899  unsigned int w, unsigned int h)
900 {
901  this->connect();
902 
903  FlyCapture2::Format7Info fmt7_info;
904  bool fmt7_supported;
905  FlyCapture2::Error error;
906 
907  fmt7_info.mode = format7_mode;
908  error = m_camera.GetFormat7Info(&fmt7_info, &fmt7_supported);
909  if (error != FlyCapture2::PGRERROR_OK) {
910  error.PrintErrorTrace();
911  throw(vpException(vpException::fatalError, "Cannot get format7 info."));
912  }
913  if (!fmt7_supported) {
914  throw(vpException(vpException::fatalError, "Format7 mode %d not supported.", (int)format7_mode));
915  }
916 
917  FlyCapture2::Format7ImageSettings fmt7_settings;
918  fmt7_settings.mode = format7_mode;
919  fmt7_settings.pixelFormat = pixel_format;
920  // Set centered roi
921  std::pair<unsigned int, unsigned int> roi_w = this->centerRoi(w, fmt7_info.maxWidth, fmt7_info.imageHStepSize);
922  std::pair<unsigned int, unsigned int> roi_h = this->centerRoi(h, fmt7_info.maxHeight, fmt7_info.imageVStepSize);
923  fmt7_settings.width = roi_w.first;
924  fmt7_settings.offsetX = roi_w.second;
925  fmt7_settings.height = roi_h.first;
926  fmt7_settings.offsetY = roi_h.second;
927 
928  // Validate the settings
929  FlyCapture2::Format7PacketInfo fmt7_packet_info;
930  bool valid = false;
931  error = m_camera.ValidateFormat7Settings(&fmt7_settings, &valid, &fmt7_packet_info);
932  if (error != FlyCapture2::PGRERROR_OK) {
933  error.PrintErrorTrace();
934  throw(vpException(vpException::fatalError, "Cannot validate format7 settings."));
935  }
936  if (!valid) {
937  throw(vpException(vpException::fatalError, "Format7 settings are not valid."));
938  }
939  error = m_camera.SetFormat7Configuration(&fmt7_settings, fmt7_packet_info.recommendedBytesPerPacket);
940  if (error != FlyCapture2::PGRERROR_OK) {
941  error.PrintErrorTrace();
942  throw(vpException(vpException::fatalError, "Cannot set format7 settings."));
943  }
944 }
945 
949 bool vpFlyCaptureGrabber::isFormat7Supported(FlyCapture2::Mode format7_mode)
950 {
951  this->connect();
952 
953  FlyCapture2::Format7Info fmt7_info;
954  bool supported = false;
955  FlyCapture2::Error error;
956 
957  fmt7_info.mode = format7_mode;
958  error = m_camera.GetFormat7Info(&fmt7_info, &supported);
959  if (error != FlyCapture2::PGRERROR_OK) {
960  error.PrintErrorTrace();
961  throw(vpException(vpException::fatalError, "Cannot get format7 info."));
962  }
963 
964  return supported;
965 }
972 {
973  this->connect();
974 
975  if (m_capture == false) {
976 
977  FlyCapture2::Error error;
978  error = m_camera.StartCapture();
979  if (error != FlyCapture2::PGRERROR_OK) {
980  error.PrintErrorTrace();
981  throw(vpException(vpException::fatalError, "Cannot start capture for camera with serial %u",
983  }
984  m_capture = true;
985  }
986  if (m_connected && m_capture)
987  init = true;
988  else
989  init = false;
990 }
991 
998 {
999  if (m_capture == true) {
1000 
1001  FlyCapture2::Error error;
1002  error = m_camera.StopCapture();
1003  if (error != FlyCapture2::PGRERROR_OK) {
1004  error.PrintErrorTrace();
1005  throw(vpException(vpException::fatalError, "Cannot stop capture."));
1006  }
1007  m_capture = false;
1008  }
1009  if (m_connected && m_capture)
1010  init = true;
1011  else
1012  init = false;
1013 }
1014 
1021 {
1022  if (m_connected == false) {
1023  FlyCapture2::Error error;
1024  m_numCameras = this->getNumCameras();
1025  if (m_numCameras == 0) {
1026  throw(vpException(vpException::fatalError, "No camera found on the bus"));
1027  }
1028 
1029  FlyCapture2::BusManager busMgr;
1030 
1031  error = busMgr.GetCameraFromIndex(m_index, &m_guid);
1032  if (error != FlyCapture2::PGRERROR_OK) {
1033  error.PrintErrorTrace();
1034  throw(vpException(vpException::fatalError, "Cannot retrieve guid of camera with index %u.", m_index));
1035  }
1036  // Connect to a camera
1037  error = m_camera.Connect(&m_guid);
1038  if (error != FlyCapture2::PGRERROR_OK) {
1039  error.PrintErrorTrace();
1040  throw(vpException(vpException::fatalError, "Cannot connect to camera with serial %u", getCameraSerial(m_index)));
1041  }
1042  m_connected = true;
1043  }
1044  if (m_connected && m_capture)
1045  init = true;
1046  else
1047  init = false;
1048 }
1049 
1056 {
1057  if (m_connected == true) {
1058 
1059  FlyCapture2::Error error;
1060  error = m_camera.Disconnect();
1061  if (error != FlyCapture2::PGRERROR_OK) {
1062  error.PrintErrorTrace();
1063  throw(vpException(vpException::fatalError, "Cannot stop capture."));
1064  }
1065  m_connected = false;
1066  }
1067  if (m_connected && m_capture)
1068  init = true;
1069  else
1070  init = false;
1071 }
1072 
1088 {
1089  this->stopCapture();
1090  this->disconnect();
1091 }
1092 
1099 {
1100  FlyCapture2::TimeStamp timestamp;
1101  this->acquire(I, timestamp);
1102 }
1103 
1111 void vpFlyCaptureGrabber::acquire(vpImage<unsigned char> &I, FlyCapture2::TimeStamp &timestamp)
1112 {
1113  this->open();
1114 
1115  FlyCapture2::Error error;
1116  // Retrieve an image
1117  error = m_camera.RetrieveBuffer(&m_rawImage);
1118  if (error != FlyCapture2::PGRERROR_OK) {
1119  error.PrintErrorTrace();
1120  std::cerr << "Cannot retrieve image from camera with serial " << getCameraSerial(m_index) << std::endl;
1121  }
1122  timestamp = m_rawImage.GetTimeStamp();
1123 
1124  height = m_rawImage.GetRows();
1125  width = m_rawImage.GetCols();
1126  I.resize(height, width);
1127 
1128  // Create a converted image using a stride equals to `sizeof(unsigned
1129  // char) * width`, which makes sure there is no paddings or holes
1130  // between pixel data. And the convertedImage object is sharing the
1131  // same data buffer with vpImage object `I`.
1132  FlyCapture2::Image convertedImage(height, width, sizeof(unsigned char) * width, I.bitmap,
1133  sizeof(unsigned char) * I.getSize(), FlyCapture2::PIXEL_FORMAT_MONO8);
1134 
1135  // Convert the raw image
1136  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_MONO8, &convertedImage);
1137  if (error != FlyCapture2::PGRERROR_OK) {
1138  error.PrintErrorTrace();
1139  throw(vpException(vpException::fatalError, "Cannot convert image from camera with serial %u",
1141  }
1142 }
1143 
1150 {
1151  FlyCapture2::TimeStamp timestamp;
1152  this->acquire(I, timestamp);
1153 }
1154 
1162 void vpFlyCaptureGrabber::acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp &timestamp)
1163 {
1164  this->open();
1165 
1166  FlyCapture2::Error error;
1167  // Retrieve an image
1168  error = m_camera.RetrieveBuffer(&m_rawImage);
1169  if (error != FlyCapture2::PGRERROR_OK) {
1170  error.PrintErrorTrace();
1171  std::cerr << "Cannot retrieve image from camera with serial " << getCameraSerial(m_index) << std::endl;
1172  }
1173  timestamp = m_rawImage.GetTimeStamp();
1174 
1175  // Create a converted image
1176  FlyCapture2::Image convertedImage;
1177 
1178  // Convert the raw image
1179  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGBU, &convertedImage);
1180  if (error != FlyCapture2::PGRERROR_OK) {
1181  error.PrintErrorTrace();
1182  throw(vpException(vpException::fatalError, "Cannot convert image from camera with serial %u",
1184  }
1185  height = convertedImage.GetRows();
1186  width = convertedImage.GetCols();
1187  I.resize(height, width);
1188 
1189  unsigned char *data = convertedImage.GetData();
1190  unsigned int stride = convertedImage.GetStride();
1191  unsigned int Bps = convertedImage.GetBitsPerPixel() / 8; // Bytes per pixel
1192  // `I.bitmap` and `I[i]` are pointers to `vpRGBa` objects. While
1193  // `data` is a pointer to an array of 32-bit RGBU values with each
1194  // value a byte in the order of R, G, B and U and goes on.
1195  for (unsigned int i = 0; i < height; ++i) {
1196  for (unsigned int j = 0; j < width; ++j) {
1197  unsigned char *pp = data + i * stride + j * Bps;
1198  I[i][j].R = pp[0];
1199  I[i][j].G = pp[1];
1200  I[i][j].B = pp[2];
1201  I[i][j].A = pp[3];
1202  }
1203  }
1204 }
1205 
1211 {
1212  this->open();
1213  this->acquire(I);
1214 }
1215 
1221 {
1222  this->open();
1223  this->acquire(I);
1224 }
1225 
1238 {
1239  this->connect();
1240  this->startCapture();
1241 }
1242 
1249 {
1250  this->connect();
1251 
1252  const unsigned int powerReg = 0x400;
1253  unsigned int powerRegVal = 0;
1254 
1255  FlyCapture2::Error error;
1256  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1257  if (error != FlyCapture2::PGRERROR_OK) {
1258  return false;
1259  }
1260 
1261  return ((powerRegVal & 0x00008000) != 0);
1262 }
1263 
1270 {
1271  if (!isCameraPowerAvailable())
1272  return false;
1273  const unsigned int powerReg = 0x610;
1274  unsigned int powerRegVal = 0;
1275 
1276  FlyCapture2::Error error;
1277  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1278  if (error != FlyCapture2::PGRERROR_OK) {
1279  return false;
1280  }
1281 
1282  return ((powerRegVal & (0x1 << 31)) != 0);
1283 }
1284 
1314 {
1315  this->connect();
1316 
1317  if (!isCameraPowerAvailable()) {
1318  throw(vpException(vpException::badValue, "Cannot power on camera. Feature not available"));
1319  }
1320 
1321  // Power on the camera
1322  const unsigned int powerReg = 0x610;
1323  unsigned int powerRegVal = 0;
1324 
1325  powerRegVal = (on == true) ? 0x80000000 : 0x0;
1326 
1327  FlyCapture2::Error error;
1328  error = m_camera.WriteRegister(powerReg, powerRegVal);
1329  if (error != FlyCapture2::PGRERROR_OK) {
1330  error.PrintErrorTrace();
1331  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1332  }
1333 
1334  unsigned int millisecondsToSleep = 100;
1335  unsigned int regVal = 0;
1336  unsigned int retries = 10;
1337 
1338  // Wait for camera to complete power-up
1339  do {
1340  vpTime::wait(millisecondsToSleep);
1341  error = m_camera.ReadRegister(powerReg, &regVal);
1342  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1343  // ignore timeout errors, camera may not be responding to
1344  // register reads during power-up
1345  }
1346  else if (error != FlyCapture2::PGRERROR_OK) {
1347  error.PrintErrorTrace();
1348  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1349  }
1350 
1351  retries--;
1352  } while ((regVal & powerRegVal) == 0 && retries > 0);
1353 
1354  // Check for timeout errors after retrying
1355  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1356  error.PrintErrorTrace();
1357  throw(vpException(vpException::fatalError, "Cannot power on the camera. Timeout occur"));
1358  }
1359 }
1360 
1378 {
1379  this->acquire(I);
1380  return *this;
1381 }
1382 
1400 {
1401  this->acquire(I);
1402  return *this;
1403 }
1404 
1405 #else
1406 // Work around to avoid warning:
1407 // libvisp_flycapture.a(vpFlyCaptureGrabber.cpp.o) has no symbols
1408 void dummy_vpFlyCaptureGrabber() { };
1409 #endif
error that can be emitted by ViSP classes.
Definition: vpException.h:59
@ badValue
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:85
@ fatalError
Fatal error.
Definition: vpException.h:84
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)
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)
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.
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.
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:780
unsigned int getSize() const
Definition: vpImage.h:223
Type * bitmap
points toward the bitmap
Definition: vpImage.h:139
VISP_EXPORT int wait(double t0, double t)