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