Visual Servoing Platform  version 3.5.1 under development (2022-12-02)
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 w, unsigned int h)
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(w, fmt7_info.maxWidth, fmt7_info.imageHStepSize);
924  std::pair<unsigned int, unsigned int> roi_h = this->centerRoi(h, 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  std::cerr << "Cannot retrieve image from camera with serial " << getCameraSerial(m_index) << std::endl;
1123  }
1124  timestamp = m_rawImage.GetTimeStamp();
1125 
1126  height = m_rawImage.GetRows();
1127  width = m_rawImage.GetCols();
1128  I.resize(height, width);
1129 
1130  // Create a converted image using a stride equals to `sizeof(unsigned
1131  // char) * width`, which makes sure there is no paddings or holes
1132  // between pixel data. And the convertedImage object is sharing the
1133  // same data buffer with vpImage object `I`.
1134  FlyCapture2::Image convertedImage(height, width, sizeof(unsigned char) * width, I.bitmap,
1135  sizeof(unsigned char) * I.getSize(), FlyCapture2::PIXEL_FORMAT_MONO8);
1136 
1137  // Convert the raw image
1138  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_MONO8, &convertedImage);
1139  if (error != FlyCapture2::PGRERROR_OK) {
1140  error.PrintErrorTrace();
1141  throw(vpException(vpException::fatalError, "Cannot convert image from camera with serial %u",
1143  }
1144 }
1145 
1152 {
1153  FlyCapture2::TimeStamp timestamp;
1154  this->acquire(I, timestamp);
1155 }
1156 
1164 void vpFlyCaptureGrabber::acquire(vpImage<vpRGBa> &I, FlyCapture2::TimeStamp &timestamp)
1165 {
1166  this->open();
1167 
1168  FlyCapture2::Error error;
1169  // Retrieve an image
1170  error = m_camera.RetrieveBuffer(&m_rawImage);
1171  if (error != FlyCapture2::PGRERROR_OK) {
1172  error.PrintErrorTrace();
1173  std::cerr << "Cannot retrieve image from camera with serial " << getCameraSerial(m_index) << std::endl;
1174  }
1175  timestamp = m_rawImage.GetTimeStamp();
1176 
1177  // Create a converted image
1178  FlyCapture2::Image convertedImage;
1179 
1180  // Convert the raw image
1181  error = m_rawImage.Convert(FlyCapture2::PIXEL_FORMAT_RGBU, &convertedImage);
1182  if (error != FlyCapture2::PGRERROR_OK) {
1183  error.PrintErrorTrace();
1184  throw(vpException(vpException::fatalError, "Cannot convert image from camera with serial %u",
1186  }
1187  height = convertedImage.GetRows();
1188  width = convertedImage.GetCols();
1189  I.resize(height, width);
1190 
1191  unsigned char *data = convertedImage.GetData();
1192  unsigned int stride = convertedImage.GetStride();
1193  unsigned int Bps = convertedImage.GetBitsPerPixel() / 8; // Bytes per pixel
1194  // `I.bitmap` and `I[i]` are pointers to `vpRGBa` objects. While
1195  // `data` is a pointer to an array of 32-bit RGBU values with each
1196  // value a byte in the order of R, G, B and U and goes on.
1197  for (unsigned int i = 0; i < height; ++i) {
1198  for (unsigned int j = 0; j < width; ++j) {
1199  unsigned char *pp = data + i * stride + j * Bps;
1200  I[i][j].R = pp[0];
1201  I[i][j].G = pp[1];
1202  I[i][j].B = pp[2];
1203  I[i][j].A = pp[3];
1204  }
1205  }
1206 }
1207 
1213 {
1214  this->open();
1215  this->acquire(I);
1216 }
1217 
1223 {
1224  this->open();
1225  this->acquire(I);
1226 }
1227 
1240 {
1241  this->connect();
1242  this->startCapture();
1243 }
1244 
1251 {
1252  this->connect();
1253 
1254  const unsigned int powerReg = 0x400;
1255  unsigned int powerRegVal = 0;
1256 
1257  FlyCapture2::Error error;
1258  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1259  if (error != FlyCapture2::PGRERROR_OK) {
1260  return false;
1261  }
1262 
1263  return ((powerRegVal & 0x00008000) != 0);
1264 }
1265 
1272 {
1273  if (!isCameraPowerAvailable())
1274  return false;
1275  const unsigned int powerReg = 0x610;
1276  unsigned int powerRegVal = 0;
1277 
1278  FlyCapture2::Error error;
1279  error = m_camera.ReadRegister(powerReg, &powerRegVal);
1280  if (error != FlyCapture2::PGRERROR_OK) {
1281  return false;
1282  }
1283 
1284  return ((powerRegVal & (0x1 << 31)) != 0);
1285 }
1286 
1316 {
1317  this->connect();
1318 
1319  if (!isCameraPowerAvailable()) {
1320  throw(vpException(vpException::badValue, "Cannot power on camera. Feature not available"));
1321  }
1322 
1323  // Power on the camera
1324  const unsigned int powerReg = 0x610;
1325  unsigned int powerRegVal = 0;
1326 
1327  powerRegVal = (on == true) ? 0x80000000 : 0x0;
1328 
1329  FlyCapture2::Error error;
1330  error = m_camera.WriteRegister(powerReg, powerRegVal);
1331  if (error != FlyCapture2::PGRERROR_OK) {
1332  error.PrintErrorTrace();
1333  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1334  }
1335 
1336  unsigned int millisecondsToSleep = 100;
1337  unsigned int regVal = 0;
1338  unsigned int retries = 10;
1339 
1340  // Wait for camera to complete power-up
1341  do {
1342  vpTime::wait(millisecondsToSleep);
1343  error = m_camera.ReadRegister(powerReg, &regVal);
1344  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1345  // ignore timeout errors, camera may not be responding to
1346  // register reads during power-up
1347  } else if (error != FlyCapture2::PGRERROR_OK) {
1348  error.PrintErrorTrace();
1349  throw(vpException(vpException::fatalError, "Cannot power on the camera."));
1350  }
1351 
1352  retries--;
1353  } while ((regVal & powerRegVal) == 0 && retries > 0);
1354 
1355  // Check for timeout errors after retrying
1356  if (error == FlyCapture2::PGRERROR_TIMEOUT) {
1357  error.PrintErrorTrace();
1358  throw(vpException(vpException::fatalError, "Cannot power on the camera. Timeout occur"));
1359  }
1360 }
1361 
1379 {
1380  this->acquire(I);
1381  return *this;
1382 }
1383 
1401 {
1402  this->acquire(I);
1403  return *this;
1404 }
1405 
1406 #else
1407 // Work around to avoid warning:
1408 // libvisp_flycapture.a(vpFlyCaptureGrabber.cpp.o) has no symbols
1409 void dummy_vpFlyCaptureGrabber(){};
1410 #endif
error that can be emited by ViSP classes.
Definition: vpException.h:72
@ badValue
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:97
@ fatalError
Fatal error.
Definition: vpException.h:96
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:799
unsigned int getSize() const
Definition: vpImage.h:227
Type * bitmap
points toward the bitmap
Definition: vpImage.h:143
VISP_EXPORT int wait(double t0, double t)