Visual Servoing Platform  version 3.6.1 under development (2024-07-27)
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 
50 
56  : m_camera(), m_guid(), m_index(0), m_numCameras(0), m_rawImage(), m_connected(false), m_capture(false)
57 {
58  m_numCameras = this->getNumCameras();
59 }
60 
69 {
70  unsigned int numCameras;
71  FlyCapture2::BusManager busMgr;
72  FlyCapture2::Error error = busMgr.GetNumOfCameras(&numCameras);
73  if (error != FlyCapture2::PGRERROR_OK) {
74  numCameras = 0;
75  }
76  return numCameras;
77 }
78 
83 std::ostream &vpFlyCaptureGrabber::getCameraInfo(std::ostream &os)
84 {
85  this->connect();
86 
87  FlyCapture2::CameraInfo camInfo;
88  FlyCapture2::Error error = m_camera.GetCameraInfo(&camInfo);
89  if (error != FlyCapture2::PGRERROR_OK) {
90  error.PrintErrorTrace();
91  }
92 
93  os << "Camera information: " << std::endl;
94  os << " Serial number : " << camInfo.serialNumber << std::endl;
95  os << " Camera model : " << camInfo.modelName << std::endl;
96  os << " Camera vendor : " << camInfo.vendorName << std::endl;
97  os << " Sensor : " << camInfo.sensorInfo << std::endl;
98  os << " Resolution : " << camInfo.sensorResolution << std::endl;
99  os << " Firmware version : " << camInfo.firmwareVersion << std::endl;
100  os << " Firmware build time: " << camInfo.firmwareBuildTime << std::endl;
101  return os;
102 }
103 
191 {
192  this->connect();
193 
194  if (m_connected == true) {
195  return &m_camera;
196  }
197  else {
198  return nullptr;
199  }
200 }
201 
215 {
216  this->connect();
217 
218  FlyCapture2::Property prop = this->getProperty(FlyCapture2::FRAME_RATE);
219  return prop.absValue;
220 }
221 
235 {
236  this->connect();
237 
238  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHUTTER);
239  return prop.absValue;
240 }
241 
255 {
256  this->connect();
257 
258  FlyCapture2::Property prop = this->getProperty(FlyCapture2::GAIN);
259  return prop.absValue;
260 }
261 
275 {
276  this->connect();
277 
278  FlyCapture2::Property prop = this->getProperty(FlyCapture2::BRIGHTNESS);
279  return prop.absValue;
280 }
281 
295 {
296  this->connect();
297 
298  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHARPNESS);
299  return prop.valueA;
300 }
301 
315 {
316  this->connect();
317 
318  FlyCapture2::Property prop = this->getProperty(FlyCapture2::AUTO_EXPOSURE);
319  return prop.absValue;
320 }
321 
357 unsigned int vpFlyCaptureGrabber::getCameraSerial(unsigned int index)
358 {
359  unsigned int num_cameras = vpFlyCaptureGrabber::getNumCameras();
360  if (index >= num_cameras) {
361  throw(vpException(vpException::badValue, "The camera with index %u is not present. Only %d cameras connected.",
362  index, num_cameras));
363  }
364  unsigned int serial_id;
365  FlyCapture2::BusManager busMgr;
366  FlyCapture2::Error error;
367  error = busMgr.GetCameraSerialNumberFromIndex(index, &serial_id);
368  if (error != FlyCapture2::PGRERROR_OK) {
369  error.PrintErrorTrace();
370  throw(vpException(vpException::fatalError, "Cannot get camera with index %d serial id.", index));
371  }
372  return serial_id;
373 }
374 
390 void vpFlyCaptureGrabber::setCameraIndex(unsigned int index)
391 {
392  if (index >= m_numCameras) {
393  throw(vpException(vpException::badValue, "The camera with index %u is not present. Only %d cameras connected.",
394  index, m_numCameras));
395  }
396 
397  m_index = index;
398 }
399 
433 void vpFlyCaptureGrabber::setCameraSerial(unsigned int serial_id)
434 {
435  FlyCapture2::BusManager busMgr;
436  FlyCapture2::Error error;
437  m_numCameras = this->getNumCameras();
438  for (unsigned int i = 0; i < m_numCameras; i++) {
439  if (vpFlyCaptureGrabber::getCameraSerial(i) == serial_id) {
440  m_index = i;
441  return;
442  }
443  }
444  throw(vpException(vpException::badValue, "The camera with serial id %u is not present.", serial_id));
445 }
446 
456 void vpFlyCaptureGrabber::setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value,
457  PropertyValue prop_value)
458 {
459  this->connect();
460 
461  FlyCapture2::PropertyInfo propInfo;
462  propInfo = this->getPropertyInfo(prop_type);
463 
464  if (propInfo.present) {
465  FlyCapture2::Property prop;
466  prop.type = prop_type;
467  prop.onOff = on && propInfo.onOffSupported;
468  prop.autoManualMode = auto_on && propInfo.autoSupported;
469  prop.absControl = propInfo.absValSupported;
470  switch (prop_value) {
471  case ABS_VALUE: {
472  float value_ = std::max<float>(std::min<float>((float)value, (float)propInfo.absMax), (float)propInfo.absMin);
473  prop.absValue = value_;
474  break;
475  }
476  case VALUE_A: {
477  unsigned int value_ =
478  std::max<unsigned int>(std::min<unsigned int>((unsigned int)value, (unsigned int)propInfo.max), (unsigned int)propInfo.min);
479  prop.valueA = value_;
480  break;
481  }
482  }
483 
484  FlyCapture2::Error error;
485  error = m_camera.SetProperty(&prop);
486  if (error != FlyCapture2::PGRERROR_OK) {
487  error.PrintErrorTrace();
488  throw(vpException(vpException::fatalError, "Cannot set property %d.", (int)prop_type));
489  }
490  }
491 }
492 
529 float vpFlyCaptureGrabber::setFrameRate(float frame_rate)
530 {
531  this->connect();
532 
533  this->setProperty(FlyCapture2::FRAME_RATE, true, false, frame_rate);
534  FlyCapture2::Property prop = this->getProperty(FlyCapture2::FRAME_RATE);
535  return prop.absValue;
536 }
537 
575 float vpFlyCaptureGrabber::setShutter(bool auto_shutter, float shutter_ms)
576 {
577  this->connect();
578 
579  this->setProperty(FlyCapture2::SHUTTER, true, auto_shutter, shutter_ms);
580  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHUTTER);
581  return prop.absValue;
582 }
583 
623 float vpFlyCaptureGrabber::setGain(bool gain_auto, float gain_value)
624 {
625  this->connect();
626 
627  this->setProperty(FlyCapture2::GAIN, true, gain_auto, gain_value);
628  FlyCapture2::Property prop = this->getProperty(FlyCapture2::GAIN);
629  return prop.absValue;
630 }
631 
671 float vpFlyCaptureGrabber::setBrightness(bool brightness_auto, float brightness_value)
672 {
673  this->connect();
674 
675  this->setProperty(FlyCapture2::BRIGHTNESS, true, brightness_auto, brightness_value);
676  FlyCapture2::Property prop = this->getProperty(FlyCapture2::BRIGHTNESS);
677  return prop.absValue;
678 }
679 
729 float vpFlyCaptureGrabber::setExposure(bool exposure_on, bool exposure_auto, float exposure_value)
730 {
731  this->connect();
732 
733  this->setProperty(FlyCapture2::AUTO_EXPOSURE, exposure_on, exposure_auto, exposure_value);
734  FlyCapture2::Property prop = this->getProperty(FlyCapture2::AUTO_EXPOSURE);
735  return prop.absValue;
736 }
737 
781 unsigned int vpFlyCaptureGrabber::setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value)
782 {
783  this->connect();
784 
785  this->setProperty(FlyCapture2::SHARPNESS, sharpness_on, sharpness_auto, (float)sharpness_value, VALUE_A);
786  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHARPNESS);
787  return prop.valueA;
788 }
789 
794 FlyCapture2::Property vpFlyCaptureGrabber::getProperty(FlyCapture2::PropertyType prop_type)
795 {
796  this->connect();
797 
798  FlyCapture2::Property prop;
799  prop.type = prop_type;
800  FlyCapture2::Error error;
801  error = m_camera.GetProperty(&prop);
802  if (error != FlyCapture2::PGRERROR_OK) {
803  error.PrintErrorTrace();
804  throw(vpException(vpException::fatalError, "Cannot get property %d value.", (int)prop_type));
805  }
806  return prop;
807 }
808 
814 FlyCapture2::PropertyInfo vpFlyCaptureGrabber::getPropertyInfo(FlyCapture2::PropertyType prop_type)
815 {
816  this->connect();
817 
818  FlyCapture2::PropertyInfo propInfo;
819  propInfo.type = prop_type;
820 
821  FlyCapture2::Error error;
822  error = m_camera.GetPropertyInfo(&propInfo);
823  if (error != FlyCapture2::PGRERROR_OK) {
824  error.PrintErrorTrace();
825  throw(vpException(vpException::fatalError, "Cannot get property %d info.", (int)prop_type));
826  }
827  return propInfo;
828 }
829 
864 void vpFlyCaptureGrabber::setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
865 {
866  this->connect();
867 
868  FlyCapture2::Error error;
869  error = m_camera.SetVideoModeAndFrameRate(video_mode, frame_rate);
870  if (error != FlyCapture2::PGRERROR_OK) {
871  error.PrintErrorTrace();
872  throw(vpException(vpException::fatalError, "Cannot set video mode and framerate."));
873  }
874 }
875 
879 bool vpFlyCaptureGrabber::isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode,
880  FlyCapture2::FrameRate frame_rate)
881 {
882  this->connect();
883 
884  FlyCapture2::Error error;
885  bool supported = false;
886  error = m_camera.GetVideoModeAndFrameRateInfo(video_mode, frame_rate, &supported);
887  if (error != FlyCapture2::PGRERROR_OK) {
888  error.PrintErrorTrace();
889  throw(vpException(vpException::fatalError, "Cannot get video mode and framerate."));
890  }
891  return supported;
892 }
893 
899 std::pair<unsigned int, unsigned int> vpFlyCaptureGrabber::centerRoi(unsigned int size, unsigned int max_size,
900  unsigned int step)
901 {
902  if (size == 0 || size > max_size)
903  size = max_size;
904  // size should be a multiple of step
905  size = size / step * step;
906  const unsigned int offset = (max_size - size) / 2;
907  // Return offset for centering roi
908  return std::make_pair(size, offset);
909 }
910 
945 void vpFlyCaptureGrabber::setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format,
946  unsigned int w, unsigned int h)
947 {
948  this->connect();
949 
950  FlyCapture2::Format7Info fmt7_info;
951  bool fmt7_supported;
952  FlyCapture2::Error error;
953 
954  fmt7_info.mode = format7_mode;
955  error = m_camera.GetFormat7Info(&fmt7_info, &fmt7_supported);
956  if (error != FlyCapture2::PGRERROR_OK) {
957  error.PrintErrorTrace();
958  throw(vpException(vpException::fatalError, "Cannot get format7 info."));
959  }
960  if (!fmt7_supported) {
961  throw(vpException(vpException::fatalError, "Format7 mode %d not supported.", (int)format7_mode));
962  }
963 
964  FlyCapture2::Format7ImageSettings fmt7_settings;
965  fmt7_settings.mode = format7_mode;
966  fmt7_settings.pixelFormat = pixel_format;
967  // Set centered roi
968  std::pair<unsigned int, unsigned int> roi_w = this->centerRoi(w, fmt7_info.maxWidth, fmt7_info.imageHStepSize);
969  std::pair<unsigned int, unsigned int> roi_h = this->centerRoi(h, fmt7_info.maxHeight, fmt7_info.imageVStepSize);
970  fmt7_settings.width = roi_w.first;
971  fmt7_settings.offsetX = roi_w.second;
972  fmt7_settings.height = roi_h.first;
973  fmt7_settings.offsetY = roi_h.second;
974 
975  // Validate the settings
976  FlyCapture2::Format7PacketInfo fmt7_packet_info;
977  bool valid = false;
978  error = m_camera.ValidateFormat7Settings(&fmt7_settings, &valid, &fmt7_packet_info);
979  if (error != FlyCapture2::PGRERROR_OK) {
980  error.PrintErrorTrace();
981  throw(vpException(vpException::fatalError, "Cannot validate format7 settings."));
982  }
983  if (!valid) {
984  throw(vpException(vpException::fatalError, "Format7 settings are not valid."));
985  }
986  error = m_camera.SetFormat7Configuration(&fmt7_settings, fmt7_packet_info.recommendedBytesPerPacket);
987  if (error != FlyCapture2::PGRERROR_OK) {
988  error.PrintErrorTrace();
989  throw(vpException(vpException::fatalError, "Cannot set format7 settings."));
990  }
991 }
992 
996 bool vpFlyCaptureGrabber::isFormat7Supported(FlyCapture2::Mode format7_mode)
997 {
998  this->connect();
999 
1000  FlyCapture2::Format7Info fmt7_info;
1001  bool supported = false;
1002  FlyCapture2::Error error;
1003 
1004  fmt7_info.mode = format7_mode;
1005  error = m_camera.GetFormat7Info(&fmt7_info, &supported);
1006  if (error != FlyCapture2::PGRERROR_OK) {
1007  error.PrintErrorTrace();
1008  throw(vpException(vpException::fatalError, "Cannot get format7 info."));
1009  }
1010 
1011  return supported;
1012 }
1019 {
1020  this->connect();
1021 
1022  if (m_capture == false) {
1023 
1024  FlyCapture2::Error error;
1025  error = m_camera.StartCapture();
1026  if (error != FlyCapture2::PGRERROR_OK) {
1027  error.PrintErrorTrace();
1028  throw(vpException(vpException::fatalError, "Cannot start capture for camera with serial %u",
1030  }
1031  m_capture = true;
1032  }
1033  if (m_connected && m_capture)
1034  init = true;
1035  else
1036  init = false;
1037 }
1038 
1045 {
1046  if (m_capture == true) {
1047 
1048  FlyCapture2::Error error;
1049  error = m_camera.StopCapture();
1050  if (error != FlyCapture2::PGRERROR_OK) {
1051  error.PrintErrorTrace();
1052  throw(vpException(vpException::fatalError, "Cannot stop capture."));
1053  }
1054  m_capture = false;
1055  }
1056  if (m_connected && m_capture)
1057  init = true;
1058  else
1059  init = false;
1060 }
1061 
1068 {
1069  if (m_connected == false) {
1070  FlyCapture2::Error error;
1071  m_numCameras = this->getNumCameras();
1072  if (m_numCameras == 0) {
1073  throw(vpException(vpException::fatalError, "No camera found on the bus"));
1074  }
1075 
1076  FlyCapture2::BusManager busMgr;
1077 
1078  error = busMgr.GetCameraFromIndex(m_index, &m_guid);
1079  if (error != FlyCapture2::PGRERROR_OK) {
1080  error.PrintErrorTrace();
1081  throw(vpException(vpException::fatalError, "Cannot retrieve guid of camera with index %u.", m_index));
1082  }
1083  // Connect to a camera
1084  error = m_camera.Connect(&m_guid);
1085  if (error != FlyCapture2::PGRERROR_OK) {
1086  error.PrintErrorTrace();
1087  throw(vpException(vpException::fatalError, "Cannot connect to camera with serial %u", getCameraSerial(m_index)));
1088  }
1089  m_connected = true;
1090  }
1091  if (m_connected && m_capture)
1092  init = true;
1093  else
1094  init = false;
1095 }
1096 
1103 {
1104  if (m_connected == true) {
1105 
1106  FlyCapture2::Error error;
1107  error = m_camera.Disconnect();
1108  if (error != FlyCapture2::PGRERROR_OK) {
1109  error.PrintErrorTrace();
1110  throw(vpException(vpException::fatalError, "Cannot stop capture."));
1111  }
1112  m_connected = false;
1113  }
1114  if (m_connected && m_capture)
1115  init = true;
1116  else
1117  init = false;
1118 }
1119 
1135 {
1136  this->stopCapture();
1137  this->disconnect();
1138 }
1139 
1146 {
1147  FlyCapture2::TimeStamp timestamp;
1148  this->acquire(I, timestamp);
1149 }
1150 
1158 void vpFlyCaptureGrabber::acquire(vpImage<unsigned char> &I, FlyCapture2::TimeStamp &timestamp)
1159 {
1160  this->open();
1161 
1162  FlyCapture2::Error error;
1163  // Retrieve an image
1164  error = m_camera.RetrieveBuffer(&m_rawImage);
1165  if (error != FlyCapture2::PGRERROR_OK) {
1166  error.PrintErrorTrace();
1167  std::cerr << "Cannot retrieve image from camera with serial " << getCameraSerial(m_index) << std::endl;
1168  }
1169  timestamp = m_rawImage.GetTimeStamp();
1170 
1171  height = m_rawImage.GetRows();
1172  width = m_rawImage.GetCols();
1173  I.resize(height, width);
1174 
1175  // Create a converted image using a stride equals to `sizeof(unsigned
1176  // char) * width`, which makes sure there is no paddings or holes
1177  // between pixel data. And the convertedImage object is sharing the
1178  // same data buffer with vpImage object `I`.
1179  FlyCapture2::Image convertedImage(height, width, sizeof(unsigned char) * width, I.bitmap,
1180  sizeof(unsigned char) * I.getSize(), FlyCapture2::PIXEL_FORMAT_MONO8);
1181 
1182  // Convert the raw image
1183  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_MONO8, &convertedImage);
1184  if (error != FlyCapture2::PGRERROR_OK) {
1185  error.PrintErrorTrace();
1186  throw(vpException(vpException::fatalError, "Cannot convert image from camera with serial %u",
1188  }
1189 }
1190 
1197 {
1198  FlyCapture2::TimeStamp timestamp;
1199  this->acquire(I, timestamp);
1200 }
1201 
1209 void vpFlyCaptureGrabber::acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp &timestamp)
1210 {
1211  this->open();
1212 
1213  FlyCapture2::Error error;
1214  // Retrieve an image
1215  error = m_camera.RetrieveBuffer(&m_rawImage);
1216  if (error != FlyCapture2::PGRERROR_OK) {
1217  error.PrintErrorTrace();
1218  std::cerr << "Cannot retrieve image from camera with serial " << getCameraSerial(m_index) << std::endl;
1219  }
1220  timestamp = m_rawImage.GetTimeStamp();
1221 
1222  // Create a converted image
1223  FlyCapture2::Image convertedImage;
1224 
1225  // Convert the raw image
1226  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGBU, &convertedImage);
1227  if (error != FlyCapture2::PGRERROR_OK) {
1228  error.PrintErrorTrace();
1229  throw(vpException(vpException::fatalError, "Cannot convert image from camera with serial %u",
1231  }
1232  height = convertedImage.GetRows();
1233  width = convertedImage.GetCols();
1234  I.resize(height, width);
1235 
1236  unsigned char *data = convertedImage.GetData();
1237  unsigned int stride = convertedImage.GetStride();
1238  unsigned int Bps = convertedImage.GetBitsPerPixel() / 8; // Bytes per pixel
1239  // `I.bitmap` and `I[i]` are pointers to `vpRGBa` objects. While
1240  // `data` is a pointer to an array of 32-bit RGBU values with each
1241  // value a byte in the order of R, G, B and U and goes on.
1242  for (unsigned int i = 0; i < height; ++i) {
1243  for (unsigned int j = 0; j < width; ++j) {
1244  unsigned char *pp = data + i * stride + j * Bps;
1245  I[i][j].R = pp[0];
1246  I[i][j].G = pp[1];
1247  I[i][j].B = pp[2];
1248  I[i][j].A = pp[3];
1249  }
1250  }
1251 }
1252 
1258 {
1259  this->open();
1260  this->acquire(I);
1261 }
1262 
1268 {
1269  this->open();
1270  this->acquire(I);
1271 }
1272 
1285 {
1286  this->connect();
1287  this->startCapture();
1288 }
1289 
1296 {
1297  this->connect();
1298 
1299  const unsigned int powerReg = 0x400;
1300  unsigned int powerRegVal = 0;
1301 
1302  FlyCapture2::Error error;
1303  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1304  if (error != FlyCapture2::PGRERROR_OK) {
1305  return false;
1306  }
1307 
1308  return ((powerRegVal & 0x00008000) != 0);
1309 }
1310 
1317 {
1318  if (!isCameraPowerAvailable())
1319  return false;
1320  const unsigned int powerReg = 0x610;
1321  unsigned int powerRegVal = 0;
1322 
1323  FlyCapture2::Error error;
1324  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1325  if (error != FlyCapture2::PGRERROR_OK) {
1326  return false;
1327  }
1328 
1329  return ((powerRegVal & (0x1 << 31)) != 0);
1330 }
1331 
1365 {
1366  this->connect();
1367 
1368  if (!isCameraPowerAvailable()) {
1369  throw(vpException(vpException::badValue, "Cannot power on camera. Feature not available"));
1370  }
1371 
1372  // Power on the camera
1373  const unsigned int powerReg = 0x610;
1374  unsigned int powerRegVal = 0;
1375 
1376  powerRegVal = (on == true) ? 0x80000000 : 0x0;
1377 
1378  FlyCapture2::Error error;
1379  error = m_camera.WriteRegister(powerReg, powerRegVal);
1380  if (error != FlyCapture2::PGRERROR_OK) {
1381  error.PrintErrorTrace();
1382  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1383  }
1384 
1385  unsigned int millisecondsToSleep = 100;
1386  unsigned int regVal = 0;
1387  unsigned int retries = 10;
1388 
1389  // Wait for camera to complete power-up
1390  do {
1391  vpTime::wait(millisecondsToSleep);
1392  error = m_camera.ReadRegister(powerReg, &regVal);
1393  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1394  // ignore timeout errors, camera may not be responding to
1395  // register reads during power-up
1396  }
1397  else if (error != FlyCapture2::PGRERROR_OK) {
1398  error.PrintErrorTrace();
1399  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1400  }
1401 
1402  retries--;
1403  } while ((regVal & powerRegVal) == 0 && retries > 0);
1404 
1405  // Check for timeout errors after retrying
1406  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1407  error.PrintErrorTrace();
1408  throw(vpException(vpException::fatalError, "Cannot power on the camera. Timeout occur"));
1409  }
1410 }
1411 
1432 {
1433  this->acquire(I);
1434  return *this;
1435 }
1436 
1458 {
1459  this->acquire(I);
1460  return *this;
1461 }
1462 END_VISP_NAMESPACE
1463 #else
1464 // Work around to avoid warning:
1465 // libvisp_flycapture.a(vpFlyCaptureGrabber.cpp.o) has no symbols
1466 void dummy_vpFlyCaptureGrabber() { };
1467 #endif
error that can be emitted by ViSP classes.
Definition: vpException.h:60
@ badValue
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:73
@ fatalError
Fatal error.
Definition: vpException.h:72
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:538
unsigned int getSize() const
Definition: vpImage.h:221
Type * bitmap
points toward the bitmap
Definition: vpImage.h:135
VISP_EXPORT int wait(double t0, double t)