Visual Servoing Platform  version 3.2.1 under development (2019-09-22) under development (2019-09-22)
vpFlyCaptureGrabber.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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 http://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  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
45 #include <visp3/core/vpException.h>
46 #include <visp3/sensor/vpFlyCaptureGrabber.h>
47 
48 #ifdef VISP_HAVE_FLYCAPTURE
49 
50 #include <visp3/core/vpTime.h>
51 
57  : m_camera(), m_guid(), m_index(0), m_numCameras(0), m_rawImage(), m_connected(false), m_capture(false)
58 {
59  m_numCameras = this->getNumCameras();
60 }
61 
70 {
71  unsigned int numCameras;
72  FlyCapture2::BusManager busMgr;
73  FlyCapture2::Error error = busMgr.GetNumOfCameras(&numCameras);
74  if (error != FlyCapture2::PGRERROR_OK) {
75  numCameras = 0;
76  }
77  return numCameras;
78 }
79 
84 std::ostream &vpFlyCaptureGrabber::getCameraInfo(std::ostream &os)
85 {
86  this->connect();
87 
88  FlyCapture2::CameraInfo camInfo;
89  FlyCapture2::Error error = m_camera.GetCameraInfo(&camInfo);
90  if (error != FlyCapture2::PGRERROR_OK) {
91  error.PrintErrorTrace();
92  }
93 
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;
102  return os;
103 }
104 
185 {
186  this->connect();
187 
188  if (m_connected == true) {
189  return &m_camera;
190  } else {
191  return NULL;
192  }
193 }
194 
208 {
209  this->connect();
210 
211  FlyCapture2::Property prop = this->getProperty(FlyCapture2::FRAME_RATE);
212  return prop.absValue;
213 }
214 
228 {
229  this->connect();
230 
231  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHUTTER);
232  return prop.absValue;
233 }
234 
248 {
249  this->connect();
250 
251  FlyCapture2::Property prop = this->getProperty(FlyCapture2::GAIN);
252  return prop.absValue;
253 }
254 
268 {
269  this->connect();
270 
271  FlyCapture2::Property prop = this->getProperty(FlyCapture2::BRIGHTNESS);
272  return prop.absValue;
273 }
274 
288 {
289  this->connect();
290 
291  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHARPNESS);
292  return prop.valueA;
293 }
294 
308 {
309  this->connect();
310 
311  FlyCapture2::Property prop = this->getProperty(FlyCapture2::AUTO_EXPOSURE);
312  return prop.absValue;
313 }
314 
346 unsigned int vpFlyCaptureGrabber::getCameraSerial(unsigned int index)
347 {
348  unsigned int num_cameras = vpFlyCaptureGrabber::getNumCameras();
349  if (index >= num_cameras) {
350  throw(vpException(vpException::badValue, "The camera with index %u is not present. Only %d cameras connected.",
351  index, num_cameras));
352  }
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();
359  throw(vpException(vpException::fatalError, "Cannot get camera with index %d serial id.", index));
360  }
361  return serial_id;
362 }
363 
379 void vpFlyCaptureGrabber::setCameraIndex(unsigned int index)
380 {
381  if (index >= m_numCameras) {
382  throw(vpException(vpException::badValue, "The camera with index %u is not present. Only %d cameras connected.",
383  index, m_numCameras));
384  }
385 
386  m_index = index;
387 }
388 
418 void vpFlyCaptureGrabber::setCameraSerial(unsigned int serial_id)
419 {
420  FlyCapture2::BusManager busMgr;
421  FlyCapture2::Error error;
422  m_numCameras = this->getNumCameras();
423  for (unsigned int i = 0; i < m_numCameras; i++) {
424  if (vpFlyCaptureGrabber::getCameraSerial(i) == serial_id) {
425  m_index = i;
426  return;
427  }
428  }
429  throw(vpException(vpException::badValue, "The camera with serial id %u is not present.", serial_id));
430 }
431 
441 void vpFlyCaptureGrabber::setProperty(const FlyCapture2::PropertyType &prop_type, bool on, bool auto_on, float value,
442  PropertyValue prop_value)
443 {
444  this->connect();
445 
446  FlyCapture2::PropertyInfo propInfo;
447  propInfo = this->getPropertyInfo(prop_type);
448 
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) {
456  case ABS_VALUE: {
457  float value_ = (std::max)((std::min)((float)value, (float)propInfo.absMax), (float)propInfo.absMin);
458  prop.absValue = value_;
459  break;
460  }
461  case VALUE_A: {
462  unsigned int value_ =
463  (std::max)((std::min)((unsigned int)value, (unsigned int)propInfo.max), (unsigned int)propInfo.min);
464  prop.valueA = value_;
465  break;
466  }
467  }
468 
469  FlyCapture2::Error error;
470  error = m_camera.SetProperty(&prop);
471  if (error != FlyCapture2::PGRERROR_OK) {
472  error.PrintErrorTrace();
473  throw(vpException(vpException::fatalError, "Cannot set property %d.", (int)prop_type));
474  }
475  }
476 }
477 
510 float vpFlyCaptureGrabber::setFrameRate(float frame_rate)
511 {
512  this->connect();
513 
514  this->setProperty(FlyCapture2::FRAME_RATE, true, false, frame_rate);
515  FlyCapture2::Property prop = this->getProperty(FlyCapture2::FRAME_RATE);
516  return prop.absValue;
517 }
518 
553 float vpFlyCaptureGrabber::setShutter(bool auto_shutter, float shutter_ms)
554 {
555  this->connect();
556 
557  this->setProperty(FlyCapture2::SHUTTER, true, auto_shutter, shutter_ms);
558  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHUTTER);
559  return prop.absValue;
560 }
561 
597 float vpFlyCaptureGrabber::setGain(bool gain_auto, float gain_value)
598 {
599  this->connect();
600 
601  this->setProperty(FlyCapture2::GAIN, true, gain_auto, gain_value);
602  FlyCapture2::Property prop = this->getProperty(FlyCapture2::GAIN);
603  return prop.absValue;
604 }
605 
641 float vpFlyCaptureGrabber::setBrightness(bool brightness_auto, float brightness_value)
642 {
643  this->connect();
644 
645  this->setProperty(FlyCapture2::BRIGHTNESS, true, brightness_auto, brightness_value);
646  FlyCapture2::Property prop = this->getProperty(FlyCapture2::BRIGHTNESS);
647  return prop.absValue;
648 }
649 
694 float vpFlyCaptureGrabber::setExposure(bool exposure_on, bool exposure_auto, float exposure_value)
695 {
696  this->connect();
697 
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;
701 }
702 
741 unsigned int vpFlyCaptureGrabber::setSharpness(bool sharpness_on, bool sharpness_auto, unsigned int sharpness_value)
742 {
743  this->connect();
744 
745  this->setProperty(FlyCapture2::SHARPNESS, sharpness_on, sharpness_auto, (float)sharpness_value, VALUE_A);
746  FlyCapture2::Property prop = this->getProperty(FlyCapture2::SHARPNESS);
747  return prop.valueA;
748 }
749 
754 FlyCapture2::Property vpFlyCaptureGrabber::getProperty(FlyCapture2::PropertyType prop_type)
755 {
756  this->connect();
757 
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();
764  throw(vpException(vpException::fatalError, "Cannot get property %d value.", (int)prop_type));
765  }
766  return prop;
767 }
768 
774 FlyCapture2::PropertyInfo vpFlyCaptureGrabber::getPropertyInfo(FlyCapture2::PropertyType prop_type)
775 {
776  this->connect();
777 
778  FlyCapture2::PropertyInfo propInfo;
779  propInfo.type = prop_type;
780 
781  FlyCapture2::Error error;
782  error = m_camera.GetPropertyInfo(&propInfo);
783  if (error != FlyCapture2::PGRERROR_OK) {
784  error.PrintErrorTrace();
785  throw(vpException(vpException::fatalError, "Cannot get property %d info.", (int)prop_type));
786  }
787  return propInfo;
788 }
789 
820 void vpFlyCaptureGrabber::setVideoModeAndFrameRate(FlyCapture2::VideoMode video_mode, FlyCapture2::FrameRate frame_rate)
821 {
822  this->connect();
823 
824  FlyCapture2::Error error;
825  error = m_camera.SetVideoModeAndFrameRate(video_mode, frame_rate);
826  if (error != FlyCapture2::PGRERROR_OK) {
827  error.PrintErrorTrace();
828  throw(vpException(vpException::fatalError, "Cannot set video mode and framerate."));
829  }
830 }
831 
835 bool vpFlyCaptureGrabber::isVideoModeAndFrameRateSupported(FlyCapture2::VideoMode video_mode,
836  FlyCapture2::FrameRate frame_rate)
837 {
838  this->connect();
839 
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();
845  throw(vpException(vpException::fatalError, "Cannot get video mode and framerate."));
846  }
847  return supported;
848 }
849 
855 std::pair<unsigned int, unsigned int> vpFlyCaptureGrabber::centerRoi(unsigned int size, unsigned int max_size,
856  unsigned int step)
857 {
858  if (size == 0 || size > max_size)
859  size = max_size;
860  // size should be a multiple of step
861  size = size / step * step;
862  const unsigned int offset = (max_size - size) / 2;
863  // Return offset for centering roi
864  return std::make_pair(size, offset);
865 }
866 
900 void vpFlyCaptureGrabber::setFormat7VideoMode(FlyCapture2::Mode format7_mode, FlyCapture2::PixelFormat pixel_format,
901  unsigned int width, unsigned int height)
902 {
903  this->connect();
904 
905  FlyCapture2::Format7Info fmt7_info;
906  bool fmt7_supported;
907  FlyCapture2::Error error;
908 
909  fmt7_info.mode = format7_mode;
910  error = m_camera.GetFormat7Info(&fmt7_info, &fmt7_supported);
911  if (error != FlyCapture2::PGRERROR_OK) {
912  error.PrintErrorTrace();
913  throw(vpException(vpException::fatalError, "Cannot get format7 info."));
914  }
915  if (!fmt7_supported) {
916  throw(vpException(vpException::fatalError, "Format7 mode %d not supported.", (int)format7_mode));
917  }
918 
919  FlyCapture2::Format7ImageSettings fmt7_settings;
920  fmt7_settings.mode = format7_mode;
921  fmt7_settings.pixelFormat = pixel_format;
922  // Set centered roi
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;
929 
930  // Validate the settings
931  FlyCapture2::Format7PacketInfo fmt7_packet_info;
932  bool valid = false;
933  error = m_camera.ValidateFormat7Settings(&fmt7_settings, &valid, &fmt7_packet_info);
934  if (error != FlyCapture2::PGRERROR_OK) {
935  error.PrintErrorTrace();
936  throw(vpException(vpException::fatalError, "Cannot validate format7 settings."));
937  }
938  if (!valid) {
939  throw(vpException(vpException::fatalError, "Format7 settings are not valid."));
940  }
941  error = m_camera.SetFormat7Configuration(&fmt7_settings, fmt7_packet_info.recommendedBytesPerPacket);
942  if (error != FlyCapture2::PGRERROR_OK) {
943  error.PrintErrorTrace();
944  throw(vpException(vpException::fatalError, "Cannot set format7 settings."));
945  }
946 }
947 
951 bool vpFlyCaptureGrabber::isFormat7Supported(FlyCapture2::Mode format7_mode)
952 {
953  this->connect();
954 
955  FlyCapture2::Format7Info fmt7_info;
956  bool supported = false;
957  FlyCapture2::Error error;
958 
959  fmt7_info.mode = format7_mode;
960  error = m_camera.GetFormat7Info(&fmt7_info, &supported);
961  if (error != FlyCapture2::PGRERROR_OK) {
962  error.PrintErrorTrace();
963  throw(vpException(vpException::fatalError, "Cannot get format7 info."));
964  }
965 
966  return supported;
967 }
974 {
975  this->connect();
976 
977  if (m_capture == false) {
978 
979  FlyCapture2::Error error;
980  error = m_camera.StartCapture();
981  if (error != FlyCapture2::PGRERROR_OK) {
982  error.PrintErrorTrace();
983  throw(vpException(vpException::fatalError, "Cannot start capture for camera with serial %u",
985  }
986  m_capture = true;
987  }
988  if (m_connected && m_capture)
989  init = true;
990  else
991  init = false;
992 }
993 
1000 {
1001  if (m_capture == true) {
1002 
1003  FlyCapture2::Error error;
1004  error = m_camera.StopCapture();
1005  if (error != FlyCapture2::PGRERROR_OK) {
1006  error.PrintErrorTrace();
1007  throw(vpException(vpException::fatalError, "Cannot stop capture."));
1008  }
1009  m_capture = false;
1010  }
1011  if (m_connected && m_capture)
1012  init = true;
1013  else
1014  init = false;
1015 }
1016 
1023 {
1024  if (m_connected == false) {
1025  FlyCapture2::Error error;
1026  m_numCameras = this->getNumCameras();
1027  if (m_numCameras == 0) {
1028  throw(vpException(vpException::fatalError, "No camera found on the bus"));
1029  }
1030 
1031  FlyCapture2::BusManager busMgr;
1032 
1033  error = busMgr.GetCameraFromIndex(m_index, &m_guid);
1034  if (error != FlyCapture2::PGRERROR_OK) {
1035  error.PrintErrorTrace();
1036  throw(vpException(vpException::fatalError, "Cannot retrieve guid of camera with index %u.", m_index));
1037  }
1038  // Connect to a camera
1039  error = m_camera.Connect(&m_guid);
1040  if (error != FlyCapture2::PGRERROR_OK) {
1041  error.PrintErrorTrace();
1042  throw(vpException(vpException::fatalError, "Cannot connect to camera with serial %u", getCameraSerial(m_index)));
1043  }
1044  m_connected = true;
1045  }
1046  if (m_connected && m_capture)
1047  init = true;
1048  else
1049  init = false;
1050 }
1051 
1058 {
1059  if (m_connected == true) {
1060 
1061  FlyCapture2::Error error;
1062  error = m_camera.Disconnect();
1063  if (error != FlyCapture2::PGRERROR_OK) {
1064  error.PrintErrorTrace();
1065  throw(vpException(vpException::fatalError, "Cannot stop capture."));
1066  }
1067  m_connected = false;
1068  }
1069  if (m_connected && m_capture)
1070  init = true;
1071  else
1072  init = false;
1073 }
1074 
1090 {
1091  this->stopCapture();
1092  this->disconnect();
1093 }
1094 
1101 {
1102  FlyCapture2::TimeStamp timestamp;
1103  this->acquire(I, timestamp);
1104 }
1105 
1113 void vpFlyCaptureGrabber::acquire(vpImage<unsigned char> &I, FlyCapture2::TimeStamp &timestamp)
1114 {
1115  this->open();
1116 
1117  FlyCapture2::Error error;
1118  // Retrieve an image
1119  error = m_camera.RetrieveBuffer(&m_rawImage);
1120  if (error != FlyCapture2::PGRERROR_OK) {
1121  error.PrintErrorTrace();
1122  throw(vpException(vpException::fatalError, "Cannot retrieve image from camera with serial %u",
1124  }
1125  timestamp = m_rawImage.GetTimeStamp();
1126 
1127  height = m_rawImage.GetRows();
1128  width = m_rawImage.GetCols();
1129  I.resize(height, width);
1130 
1131  // Create a converted image using a stride equals to `sizeof(unsigned
1132  // char) * width`, which makes sure there is no paddings or holes
1133  // between pixel data. And the convertedImage object is sharing the
1134  // same data buffer with vpImage object `I`.
1135  FlyCapture2::Image convertedImage(height, width, sizeof(unsigned char) * width, I.bitmap,
1136  sizeof(unsigned char) * I.getSize(), FlyCapture2::PIXEL_FORMAT_MONO8);
1137 
1138  // Convert the raw image
1139  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_MONO8, &convertedImage);
1140  if (error != FlyCapture2::PGRERROR_OK) {
1141  error.PrintErrorTrace();
1142  throw(vpException(vpException::fatalError, "Cannot convert image from camera with serial %u",
1144  }
1145 }
1146 
1153 {
1154  FlyCapture2::TimeStamp timestamp;
1155  this->acquire(I, timestamp);
1156 }
1157 
1165 void vpFlyCaptureGrabber::acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp &timestamp)
1166 {
1167  this->open();
1168 
1169  FlyCapture2::Error error;
1170  // Retrieve an image
1171  error = m_camera.RetrieveBuffer(&m_rawImage);
1172  if (error != FlyCapture2::PGRERROR_OK) {
1173  error.PrintErrorTrace();
1174  throw(vpException(vpException::fatalError, "Cannot retrieve image from camera with serial %u",
1176  }
1177  timestamp = m_rawImage.GetTimeStamp();
1178 
1179  // Create a converted image
1180  FlyCapture2::Image convertedImage;
1181 
1182  // Convert the raw image
1183  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGBU, &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  height = convertedImage.GetRows();
1190  width = convertedImage.GetCols();
1191  I.resize(height, width);
1192 
1193  unsigned char *data = convertedImage.GetData();
1194  unsigned int stride = convertedImage.GetStride();
1195  unsigned int Bps = convertedImage.GetBitsPerPixel() / 8; // Bytes per pixel
1196  // `I.bitmap` and `I[i]` are pointers to `vpRGBa` objects. While
1197  // `data` is a pointer to an array of 32-bit RGBU values with each
1198  // value a byte in the order of R, G, B and U and goes on.
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;
1202  I[i][j].R = pp[0];
1203  I[i][j].G = pp[1];
1204  I[i][j].B = pp[2];
1205  I[i][j].A = pp[3];
1206  }
1207  }
1208 }
1209 
1215 {
1216  this->open();
1217  this->acquire(I);
1218 }
1219 
1225 {
1226  this->open();
1227  this->acquire(I);
1228 }
1229 
1242 {
1243  this->connect();
1244  this->startCapture();
1245 }
1246 
1253 {
1254  this->connect();
1255 
1256  const unsigned int powerReg = 0x400;
1257  unsigned int powerRegVal = 0;
1258 
1259  FlyCapture2::Error error;
1260  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1261  if (error != FlyCapture2::PGRERROR_OK) {
1262  return false;
1263  }
1264 
1265  return ((powerRegVal & 0x00008000) != 0);
1266 }
1267 
1274 {
1275  if (!isCameraPowerAvailable())
1276  return false;
1277  const unsigned int powerReg = 0x610;
1278  unsigned int powerRegVal = 0;
1279 
1280  FlyCapture2::Error error;
1281  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1282  if (error != FlyCapture2::PGRERROR_OK) {
1283  return false;
1284  }
1285 
1286  return ((powerRegVal & (0x1 << 31)) != 0);
1287 }
1288 
1318 {
1319  this->connect();
1320 
1321  if (!isCameraPowerAvailable()) {
1322  throw(vpException(vpException::badValue, "Cannot power on camera. Feature not available"));
1323  }
1324 
1325  // Power on the camera
1326  const unsigned int powerReg = 0x610;
1327  unsigned int powerRegVal = 0;
1328 
1329  powerRegVal = (on == true) ? 0x80000000 : 0x0;
1330 
1331  FlyCapture2::Error error;
1332  error = m_camera.WriteRegister(powerReg, powerRegVal);
1333  if (error != FlyCapture2::PGRERROR_OK) {
1334  error.PrintErrorTrace();
1335  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1336  }
1337 
1338  const unsigned int millisecondsToSleep = 100;
1339  unsigned int regVal = 0;
1340  unsigned int retries = 10;
1341 
1342  // Wait for camera to complete power-up
1343  do {
1344  vpTime::wait(millisecondsToSleep);
1345  error = m_camera.ReadRegister(powerReg, &regVal);
1346  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1347  // ignore timeout errors, camera may not be responding to
1348  // register reads during power-up
1349  } else if (error != FlyCapture2::PGRERROR_OK) {
1350  error.PrintErrorTrace();
1351  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1352  }
1353 
1354  retries--;
1355  } while ((regVal & powerRegVal) == 0 && retries > 0);
1356 
1357  // Check for timeout errors after retrying
1358  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1359  error.PrintErrorTrace();
1360  throw(vpException(vpException::fatalError, "Cannot power on the camera. Timeout occur"));
1361  }
1362 }
1363 
1381 {
1382  this->acquire(I);
1383  return *this;
1384 }
1385 
1403 {
1404  this->acquire(I);
1405  return *this;
1406 }
1407 
1408 #else
1409 // Work arround to avoid warning:
1410 // libvisp_flycapture.a(vpFlyCaptureGrabber.cpp.o) has no symbols
1411 void dummy_vpFlyCaptureGrabber(){};
1412 #endif
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:97
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)
Definition: vpTime.cpp:173
FlyCapture2::Camera m_camera
Pointer to each camera.
Type * bitmap
points toward the bitmap
Definition: vpImage.h:141
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.
Definition: vpException.h:71
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)
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
Definition: vpImage.h:879
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()
unsigned int getSize() const
Definition: vpImage.h:225
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)
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)