Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
vpUeyeGrabber.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:
32  * IDS uEye interface.
33  *
34 *****************************************************************************/
35 
36 #include <visp3/core/vpConfig.h>
37 
38 #if defined(VISP_HAVE_UEYE)
39 
40 #include <string.h>
41 
42 #include <visp3/core/vpImageConvert.h>
43 #include <visp3/core/vpIoTools.h>
44 #include <visp3/sensor/vpUeyeGrabber.h>
45 
46 #include <ueye.h>
47 
48 #include "vpUeyeGrabber_impl.h"
49 
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 #define IMAGE_COUNT 5
55 
56 #define CAMINFO BOARDINFO
57 #define EVENTTHREAD_WAIT_TIMEOUT 1000
58 
59 #define CAP(val, min, max) \
60  { \
61  if (val < min) { \
62  val = min; \
63  } else if (val > max) { \
64  val = max; \
65  } \
66  }
67 
68 BEGIN_VISP_NAMESPACE
70 struct sBufferProps
71 {
72  int width;
73  int height;
74  int bitspp;
75 };
76 
78 struct sCameraProps
79 {
80  bool bUsesImageFormats;
81  int nImgFmtNormal;
82  int nImgFmtDefaultNormal;
83  int nImgFmtTrigger;
84  int nImgFmtDefaultTrigger;
85 };
86 
90 typedef struct _UEYE_IMAGE
91 {
92  char *pBuf;
93  INT nImageID;
94  INT nImageSeqNum;
95  INT nBufferSize;
96 } UEYE_IMAGE, *PUEYE_IMAGE;
97 
98 class vpUeyeGrabber::vpUeyeGrabberImpl
99 {
100 public:
101  vpUeyeGrabberImpl()
102  : m_hCamera((HIDS)0), m_activeCameraSelected(-1), m_pLastBuffer(nullptr), m_cameraList(nullptr), m_bLive(true),
103  m_bLiveStarted(false), m_verbose(false), m_I_temp()
104  {
105  ZeroMemory(&m_SensorInfo, sizeof(SENSORINFO));
106  ZeroMemory(&m_CamInfo, sizeof(CAMINFO));
107  ZeroMemory(&m_CamListInfo, sizeof(UEYE_CAMERA_INFO));
108  ZeroMemory(m_Images, sizeof(m_Images));
109 
110  m_BufferProps.width = 0;
111  m_BufferProps.height = 0;
112  m_BufferProps.bitspp = 8;
113 
114  m_event = 0;
115 #ifndef __linux__
116  m_hEvent = 0;
117 #endif
118 
119  // Active camera is the first one that is found
120  m_activeCameraSelected = setActiveCamera(0);
121  }
122 
123  ~vpUeyeGrabberImpl() { close(); }
124 
125  void acquire(vpImage<unsigned char> &I, double *timestamp_camera, std::string *timestamp_system)
126  {
127  INT ret = IS_SUCCESS;
128 
129  if (!m_hCamera) {
130  open(I);
131  }
132 
133  if (m_hCamera) {
134  if (!m_bLive) {
135  ret = is_FreezeVideo(m_hCamera, IS_WAIT);
136  }
137  else {
138  if (!m_bLiveStarted) {
139  ret = is_CaptureVideo(m_hCamera, IS_DONT_WAIT);
140  m_bLiveStarted = true;
141  }
142  }
143 
144  ret = waitEvent();
145 
146  if (ret == IS_SUCCESS) {
147  INT dummy = 0;
148  char *pLast = nullptr, *pMem = nullptr;
149 
150  is_GetActSeqBuf(m_hCamera, &dummy, &pMem, &pLast);
151  m_pLastBuffer = pLast;
152 
153  if (!m_pLastBuffer || m_BufferProps.width < 1 || m_BufferProps.height < 1)
154  return;
155 
156  int nNum = getImageNum(m_pLastBuffer);
157  if (timestamp_camera != nullptr || timestamp_system != nullptr) {
158  int nImageID = getImageID(m_pLastBuffer);
159  UEYEIMAGEINFO ImageInfo;
160  if (is_GetImageInfo(m_hCamera, nImageID, &ImageInfo, sizeof(ImageInfo)) == IS_SUCCESS) {
161  if (timestamp_camera != nullptr) {
162  *timestamp_camera = static_cast<double>(ImageInfo.u64TimestampDevice) / 10000.;
163  }
164  if (timestamp_system != nullptr) {
165  std::stringstream ss;
166  ss << ImageInfo.TimestampSystem.wYear << ":" << std::setfill('0') << std::setw(2)
167  << ImageInfo.TimestampSystem.wMonth << ":" << std::setfill('0') << std::setw(2)
168  << ImageInfo.TimestampSystem.wDay << ":" << std::setfill('0') << std::setw(2)
169  << ImageInfo.TimestampSystem.wHour << ":" << std::setfill('0') << std::setw(2)
170  << ImageInfo.TimestampSystem.wMinute << ":" << std::setfill('0') << std::setw(2)
171  << ImageInfo.TimestampSystem.wSecond << ":" << std::setfill('0') << std::setw(3)
172  << ImageInfo.TimestampSystem.wMilliseconds;
173  *timestamp_system = ss.str();
174  }
175  }
176  }
177 
178  helper::LockUnlockSeqBuffer lock(m_hCamera, nNum, m_pLastBuffer);
179 
180  if (lock.OwnsLock()) {
181  // get current colormode
182  int colormode = is_SetColorMode(m_hCamera, IS_GET_COLOR_MODE);
183 
184  switch (colormode) {
185  default:
186  case IS_CM_MONO8:
187  memcpy(reinterpret_cast<unsigned char *>(I.bitmap), reinterpret_cast<unsigned char *>(m_pLastBuffer),
188  m_BufferProps.width * m_BufferProps.height * m_BufferProps.bitspp / 8);
189  break;
190  case IS_CM_SENSOR_RAW8:
191  m_I_temp.resize(m_BufferProps.height, m_BufferProps.width),
192  vpImageConvert::demosaicRGGBToRGBaBilinear(reinterpret_cast<unsigned char *>(m_pLastBuffer),
193  reinterpret_cast<unsigned char *>(m_I_temp.bitmap),
194  m_BufferProps.width, m_BufferProps.height);
195  vpImageConvert::RGBaToGrey(reinterpret_cast<unsigned char *>(m_I_temp.bitmap),
196  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
197  m_BufferProps.height);
198  break;
199  case IS_CM_BGR565_PACKED:
200  throw(vpException(vpException::fatalError, "vpUeyeGrabber doesn't support BGR565 format"));
201 
202  case IS_CM_RGB8_PACKED:
203  vpImageConvert::RGBToGrey(reinterpret_cast<unsigned char *>(m_pLastBuffer),
204  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
205  m_BufferProps.height);
206  break;
207  case IS_CM_BGR8_PACKED:
208  vpImageConvert::BGRToGrey(reinterpret_cast<unsigned char *>(m_pLastBuffer),
209  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
210  m_BufferProps.height);
211  break;
212  case IS_CM_RGBA8_PACKED:
213  vpImageConvert::RGBaToGrey(reinterpret_cast<unsigned char *>(m_pLastBuffer),
214  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
215  m_BufferProps.height);
216  break;
217  case IS_CM_BGRA8_PACKED:
218  vpImageConvert::BGRaToGrey(reinterpret_cast<unsigned char *>(m_pLastBuffer),
219  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
220  m_BufferProps.height);
221  break;
222  }
223  }
224  }
225  }
226  }
227 
228  void acquire(vpImage<vpRGBa> &I, double *timestamp_camera, std::string *timestamp_system)
229  {
230  INT ret = IS_SUCCESS;
231 
232  if (!m_hCamera) {
233  open(I);
234  }
235 
236  if (m_hCamera) {
237  if (!m_bLive) {
238  ret = is_FreezeVideo(m_hCamera, IS_WAIT);
239  }
240  else {
241  if (!m_bLiveStarted) {
242  // ret = is_CaptureVideo(m_hCamera, IS_DONT_WAIT);
243  ret = is_CaptureVideo(m_hCamera, IS_WAIT);
244  m_bLiveStarted = true;
245  }
246  }
247 
248  ret = waitEvent();
249 
250  if (ret == IS_SUCCESS) {
251  INT dummy = 0;
252  char *pLast = nullptr, *pMem = nullptr;
253 
254  is_GetActSeqBuf(m_hCamera, &dummy, &pMem, &pLast);
255  m_pLastBuffer = pLast;
256 
257  if (!m_pLastBuffer || m_BufferProps.width < 1 || m_BufferProps.height < 1)
258  return;
259 
260  int nNum = getImageNum(m_pLastBuffer);
261  if (timestamp_camera != nullptr || timestamp_system != nullptr) {
262  int nImageID = getImageID(m_pLastBuffer);
263  UEYEIMAGEINFO ImageInfo;
264  if (is_GetImageInfo(m_hCamera, nImageID, &ImageInfo, sizeof(ImageInfo)) == IS_SUCCESS) {
265  if (timestamp_camera != nullptr) {
266  *timestamp_camera = static_cast<double>(ImageInfo.u64TimestampDevice) / 10000.;
267  }
268  if (timestamp_system != nullptr) {
269  std::stringstream ss;
270  ss << ImageInfo.TimestampSystem.wYear << ":" << std::setfill('0') << std::setw(2)
271  << ImageInfo.TimestampSystem.wMonth << ":" << std::setfill('0') << std::setw(2)
272  << ImageInfo.TimestampSystem.wDay << ":" << std::setfill('0') << std::setw(2)
273  << ImageInfo.TimestampSystem.wHour << ":" << std::setfill('0') << std::setw(2)
274  << ImageInfo.TimestampSystem.wMinute << ":" << std::setfill('0') << std::setw(2)
275  << ImageInfo.TimestampSystem.wSecond << ":" << std::setfill('0') << std::setw(3)
276  << ImageInfo.TimestampSystem.wMilliseconds;
277  *timestamp_system = ss.str();
278  }
279  }
280  }
281 
282  helper::LockUnlockSeqBuffer lock(m_hCamera, nNum, m_pLastBuffer);
283 
284  if (lock.OwnsLock()) {
285  // get current colormode
286  int colormode = is_SetColorMode(m_hCamera, IS_GET_COLOR_MODE);
287 
288  switch (colormode) {
289  default:
290  case IS_CM_MONO8:
291  vpImageConvert::GreyToRGBa(reinterpret_cast<unsigned char *>(m_pLastBuffer),
292  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
293  m_BufferProps.height);
294  break;
295  case IS_CM_SENSOR_RAW8:
296  vpImageConvert::demosaicRGGBToRGBaBilinear(reinterpret_cast<unsigned char *>(m_pLastBuffer),
297  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
298  m_BufferProps.height);
299  break;
300  case IS_CM_BGR565_PACKED:
301  throw(vpException(vpException::fatalError, "vpUeyeGrabber doesn't support BGR565 format"));
302 
303  case IS_CM_RGB8_PACKED:
304  vpImageConvert::RGBToRGBa(reinterpret_cast<unsigned char *>(m_pLastBuffer),
305  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
306  m_BufferProps.height);
307  break;
308  case IS_CM_BGR8_PACKED:
309  vpImageConvert::BGRToRGBa(reinterpret_cast<unsigned char *>(m_pLastBuffer),
310  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
311  m_BufferProps.height);
312  break;
313  case IS_CM_RGBA8_PACKED:
314  memcpy(reinterpret_cast<unsigned char *>(I.bitmap), reinterpret_cast<unsigned char *>(m_pLastBuffer),
315  m_BufferProps.width * m_BufferProps.height * m_BufferProps.bitspp / 8);
316  break;
317  case IS_CM_BGRA8_PACKED:
318  vpImageConvert::BGRaToRGBa(reinterpret_cast<unsigned char *>(m_pLastBuffer),
319  reinterpret_cast<unsigned char *>(I.bitmap), m_BufferProps.width,
320  m_BufferProps.height);
321  break;
322  }
323  }
324  }
325  }
326  }
327 
328  bool allocImages()
329  {
330  m_pLastBuffer = nullptr;
331  int nWidth = 0;
332  int nHeight = 0;
333 
334  UINT nAbsPosX;
335  UINT nAbsPosY;
336 
337  is_AOI(m_hCamera, IS_AOI_IMAGE_GET_POS_X_ABS, (void *)&nAbsPosX, sizeof(nAbsPosX));
338  is_AOI(m_hCamera, IS_AOI_IMAGE_GET_POS_Y_ABS, (void *)&nAbsPosY, sizeof(nAbsPosY));
339 
340  is_ClearSequence(m_hCamera);
341  freeImages();
342 
343  for (unsigned int i = 0; i < sizeof(m_Images) / sizeof(m_Images[0]); i++) {
344  nWidth = m_BufferProps.width;
345  nHeight = m_BufferProps.height;
346 
347  if (nAbsPosX) {
348  m_BufferProps.width = nWidth = m_SensorInfo.nMaxWidth;
349  }
350  if (nAbsPosY) {
351  m_BufferProps.height = nHeight = m_SensorInfo.nMaxHeight;
352  }
353 
354  if (is_AllocImageMem(m_hCamera, nWidth, nHeight, m_BufferProps.bitspp, &m_Images[i].pBuf,
355  &m_Images[i].nImageID) != IS_SUCCESS)
356  return false;
357  if (is_AddToSequence(m_hCamera, m_Images[i].pBuf, m_Images[i].nImageID) != IS_SUCCESS)
358  return false;
359 
360  m_Images[i].nImageSeqNum = i + 1;
361  m_Images[i].nBufferSize = nWidth * nHeight * m_BufferProps.bitspp / 8;
362  }
363 
364  return true;
365  }
366 
367  int cameraInitialized()
368  {
369  int ret = 0;
370  unsigned int uInitialParameterSet = IS_CONFIG_INITIAL_PARAMETERSET_NONE;
371 
372  if ((ret = is_GetCameraInfo(m_hCamera, &m_CamInfo)) != IS_SUCCESS) {
373  throw(vpException(vpException::fatalError, "uEye error: GetCameraInfo failed"));
374  }
375  else if ((ret = is_GetSensorInfo(m_hCamera, &m_SensorInfo)) != IS_SUCCESS) {
376  throw(vpException(vpException::fatalError, "uEye error: GetSensorInfo failed"));
377  }
378  else if ((ret = is_Configuration(IS_CONFIG_INITIAL_PARAMETERSET_CMD_GET, &uInitialParameterSet,
379  sizeof(unsigned int))) != IS_SUCCESS) {
380  throw(vpException(vpException::fatalError, "uEye error: querying 'initial parameter set' failed"));
381  }
382  else {
383  // m_nWidth = m_SensorInfo.nMaxWidth;
384  // m_nHeight = m_SensorInfo.nMaxHeight;
385 
386  // restore all defaults
387  // do this only if there is no 'initial parameter set' installed.
388  // if an 'initial parameter set' is installed we must not overwrite this setup!
389  if (uInitialParameterSet == IS_CONFIG_INITIAL_PARAMETERSET_NONE) {
390  ret = is_ResetToDefault(m_hCamera);
391  }
392 
393  int colormode = 0;
394  if (m_SensorInfo.nColorMode >= IS_COLORMODE_BAYER) {
395  colormode = IS_CM_BGRA8_PACKED;
396  }
397  else {
398  colormode = IS_CM_MONO8;
399  }
400 
401  if (is_SetColorMode(m_hCamera, colormode) != IS_SUCCESS) {
402  throw(vpException(vpException::fatalError, "uEye error: SetColorMode failed"));
403  }
404 
405  /* get some special camera properties */
406  ZeroMemory(&m_CameraProps, sizeof(m_CameraProps));
407 
408  // If the camera does not support a continuous AOI -> it uses special image formats
409  m_CameraProps.bUsesImageFormats = false;
410  INT nAOISupported = 0;
411  if (is_ImageFormat(m_hCamera, IMGFRMT_CMD_GET_ARBITRARY_AOI_SUPPORTED, (void *)&nAOISupported,
412  sizeof(nAOISupported)) == IS_SUCCESS) {
413  m_CameraProps.bUsesImageFormats = (nAOISupported == 0);
414  }
415 
416  /* set the default image format, if used */
417  if (m_CameraProps.bUsesImageFormats) {
418  // search the default formats
419  m_CameraProps.nImgFmtNormal = searchDefImageFormats(CAPTMODE_FREERUN | CAPTMODE_SINGLE);
420  m_CameraProps.nImgFmtDefaultNormal = m_CameraProps.nImgFmtNormal;
421  m_CameraProps.nImgFmtTrigger = searchDefImageFormats(CAPTMODE_TRIGGER_SOFT_SINGLE);
422  m_CameraProps.nImgFmtDefaultTrigger = m_CameraProps.nImgFmtTrigger;
423  // set the default formats
424  if ((ret = is_ImageFormat(m_hCamera, IMGFRMT_CMD_SET_FORMAT, (void *)&m_CameraProps.nImgFmtNormal,
425  sizeof(m_CameraProps.nImgFmtNormal))) == IS_SUCCESS) {
426  // m_nImageFormat = nFormat;
427  // bRet = TRUE;
428  }
429  }
430 
431  /* setup the capture parameter */
432  setupCapture();
433 
434  enableEvent(IS_SET_EVENT_FRAME);
435  }
436 
437  m_pLastBuffer = nullptr;
438 
439  return ret;
440  }
441 
442  void close()
443  {
444  if (m_hCamera == IS_INVALID_HIDS)
445  return;
446 
447  if (m_hCamera) {
448  if (m_bLive && m_bLiveStarted) {
449  INT nRet = 1;
450  double t = vpTime::measureTimeSecond();
451  while (nRet != IS_SUCCESS && (vpTime::measureTimeSecond() - t) <= 2.) {
452  nRet = is_StopLiveVideo(m_hCamera, IS_WAIT);
453  }
454  m_bLiveStarted = false;
455  }
456 
457  is_ClearSequence(m_hCamera);
458  freeImages();
459 
460  if (is_ExitCamera(m_hCamera) != IS_SUCCESS) {
461  throw(vpException(vpException::fatalError, "Cannot logoff camera"));
462  }
463 
464  disableEvent();
465 
466  m_hCamera = (HIDS)0;
467  }
468  }
469 
470  void disableEvent()
471  {
472  is_DisableEvent(m_hCamera, m_event);
473 #ifndef __linux__
474  is_ExitEvent(m_hCamera, m_event);
475  CloseHandle(m_hEvent);
476 #endif
477  }
478 
479  int enableEvent(int event)
480  {
481  int ret = 0;
482  m_event = event;
483 #ifndef __linux__
484  m_hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
485  if (m_hEvent == nullptr) {
486  return -1;
487  }
488  ret = is_InitEvent(m_hCamera, m_hEvent, m_event);
489 #endif
490  ret = is_EnableEvent(m_hCamera, m_event);
491 
492  return ret;
493  }
494 
495  int waitEvent()
496  {
497 #ifdef __linux__
498  if (is_WaitEvent(m_hCamera, m_event, EVENTTHREAD_WAIT_TIMEOUT) == IS_SUCCESS) {
499 #else
500  if (WaitForSingleObject(m_hEvent, EVENTTHREAD_WAIT_TIMEOUT) == WAIT_OBJECT_0) {
501 #endif
502  return IS_SUCCESS;
503  }
504  else {
505  return IS_TIMED_OUT;
506  }
507  }
508 
509  void freeImages()
510  {
511  m_pLastBuffer = nullptr;
512  // printf ("freeing image buffers\n");
513  for (unsigned int i = 0; i < sizeof(m_Images) / sizeof(m_Images[0]); i++) {
514  if (nullptr != m_Images[i].pBuf) {
515  is_FreeImageMem(m_hCamera, m_Images[i].pBuf, m_Images[i].nImageID);
516  }
517 
518  m_Images[i].pBuf = nullptr;
519  m_Images[i].nImageID = 0;
520  m_Images[i].nImageSeqNum = 0;
521  }
522  }
523 
524  std::string getActiveCameraModel() const { return m_CamListInfo.Model; }
525 
526  std::string getActiveCameraSerialNumber() const { return m_CamListInfo.SerNo; }
527 
528  int getBitsPerPixel(int colormode)
529  {
530  switch (colormode) {
531  default:
532  case IS_CM_MONO8:
533  case IS_CM_SENSOR_RAW8:
534  return 8; // occupies 8 Bit
535  case IS_CM_MONO12:
536  case IS_CM_MONO16:
537  case IS_CM_SENSOR_RAW12:
538  case IS_CM_SENSOR_RAW16:
539  case IS_CM_BGR5_PACKED:
540  case IS_CM_BGR565_PACKED:
541  case IS_CM_UYVY_PACKED:
542  case IS_CM_CBYCRY_PACKED:
543  return 16; // occupies 16 Bit
544  case IS_CM_RGB8_PACKED:
545  case IS_CM_BGR8_PACKED:
546  return 24;
547  case IS_CM_RGBA8_PACKED:
548  case IS_CM_BGRA8_PACKED:
549  case IS_CM_RGBY8_PACKED:
550  case IS_CM_BGRY8_PACKED:
551  case IS_CM_RGB10_PACKED:
552  case IS_CM_BGR10_PACKED:
553  return 32;
554  }
555  }
556 
557  std::vector<unsigned int> getCameraIDList() const
558  {
559  CameraList camera_list;
560  return camera_list.getCameraIDList();
561  }
562 
563  std::vector<std::string> getCameraModelList() const
564  {
565  CameraList camera_list;
566  return camera_list.getCameraModelList();
567  }
568 
569  std::vector<std::string> getCameraSerialNumberList() const
570  {
571  CameraList camera_list;
572  return camera_list.getCameraSerialNumberList();
573  }
574 
575  unsigned int getFrameHeight() const
576  {
577  if (!isConnected()) {
578  throw(vpException(vpException::fatalError, "Unable to get frame height. Camera connexion is not opened"));
579  }
580  return static_cast<unsigned int>(m_BufferProps.height);
581  }
582 
583  unsigned int getFrameWidth() const
584  {
585  if (!isConnected()) {
586  throw(vpException(vpException::fatalError, "Unable to get frame width. Camera connexion is not opened"));
587  }
588  return static_cast<unsigned int>(m_BufferProps.width);
589  }
590 
591  double getFramerate() const
592  {
593  if (!m_hCamera) {
594  return 0;
595  }
596  double fps;
597 
598  // Get framerate
599  if (is_GetFramesPerSecond(m_hCamera, &fps) != IS_SUCCESS) {
600  if (m_verbose) {
601  std::cout << "Unable to get acquisition frame rate" << std::endl;
602  }
603  }
604  return fps;
605  }
606 
607  INT getImageID(char *pbuf)
608  {
609  if (!pbuf)
610  return 0;
611 
612  for (unsigned int i = 0; i < sizeof(m_Images) / sizeof(m_Images[0]); i++)
613  if (m_Images[i].pBuf == pbuf)
614  return m_Images[i].nImageID;
615 
616  return 0;
617  }
618 
619  INT getImageNum(char *pbuf)
620  {
621  if (!pbuf)
622  return 0;
623 
624  for (unsigned int i = 0; i < sizeof(m_Images) / sizeof(m_Images[0]); i++)
625  if (m_Images[i].pBuf == pbuf)
626  return m_Images[i].nImageSeqNum;
627 
628  return 0;
629  }
630 
631  bool isConnected() const { return (m_hCamera != (HIDS)0); }
632 
633  void loadParameters(const std::string &filename)
634  {
635  if (!vpIoTools::checkFilename(filename)) {
636  throw(vpException(vpException::fatalError, "Camera parameters file doesn't exist: %s", filename.c_str()));
637  }
638 
639  const std::wstring filename_(filename.begin(), filename.end());
640  int ret = is_ParameterSet(m_hCamera, IS_PARAMETERSET_CMD_LOAD_FILE, (void *)filename_.c_str(), 0);
641 
642  if (ret == IS_INVALID_CAMERA_TYPE) {
643  throw(vpException(vpException::fatalError, "The camera parameters file %s belong to a different camera",
644  filename.c_str()));
645  }
646  else if (ret == IS_INCOMPATIBLE_SETTING) {
648  "Because of incompatible settings, cannot load parameters from file %s", filename.c_str()));
649  }
650  else if (ret != IS_SUCCESS) {
651  throw(vpException(vpException::fatalError, "Cannot load parameters from file %s", filename.c_str()));
652  }
653  else {
654  std::cout << "Parameters loaded sucessfully" << std::endl;
655  }
656 
657  setupCapture();
658  }
659 
660  void open()
661  {
662  if (m_hCamera) {
663  if (is_ExitCamera(m_hCamera) != IS_SUCCESS) {
664  throw(vpException(vpException::fatalError, "Cannot logoff camera"));
665  }
666  }
667 
668  // open the selected camera
669  m_hCamera = (HIDS)(m_CamListInfo.dwDeviceID | IS_USE_DEVICE_ID); // open camera
670 
671  if (is_InitCamera(&m_hCamera, 0) != IS_SUCCESS) { // init camera - no window handle required
672  throw(vpException(vpException::fatalError, "Cannot open connexion with IDS uEye camera"));
673  }
674 
675  int ret = cameraInitialized();
676  if (ret != IS_SUCCESS) {
677  throw(vpException(vpException::fatalError, "Unable to initialize uEye camera"));
678  }
679  }
680 
681  template <class Type> void open(vpImage<Type> &I)
682  {
683  open();
684  I.resize(m_SensorInfo.nMaxHeight, m_SensorInfo.nMaxWidth);
685  }
686 
692  int searchDefImageFormats(int suppportMask)
693  {
694  int ret = IS_SUCCESS;
695  int nNumber;
696  int format = 0;
697  IMAGE_FORMAT_LIST *pFormatList;
698  IS_RECT rectAOI;
699 
700  if ((ret = is_ImageFormat(m_hCamera, IMGFRMT_CMD_GET_NUM_ENTRIES, (void *)&nNumber, sizeof(nNumber))) ==
701  IS_SUCCESS &&
702  (ret = is_AOI(m_hCamera, IS_AOI_IMAGE_GET_AOI, (void *)&rectAOI, sizeof(rectAOI))) == IS_SUCCESS) {
703  int i = 0;
704  int nSize = sizeof(IMAGE_FORMAT_LIST) + (nNumber - 1) * sizeof(IMAGE_FORMAT_LIST);
705  pFormatList = (IMAGE_FORMAT_LIST *)(new char[nSize]);
706  pFormatList->nNumListElements = nNumber;
707  pFormatList->nSizeOfListEntry = sizeof(IMAGE_FORMAT_INFO);
708 
709  if ((ret = is_ImageFormat(m_hCamera, IMGFRMT_CMD_GET_LIST, (void *)pFormatList, nSize)) == IS_SUCCESS) {
710  for (i = 0; i < nNumber; i++) {
711  if ((pFormatList->FormatInfo[i].nSupportedCaptureModes & suppportMask) &&
712  pFormatList->FormatInfo[i].nHeight == (UINT)rectAOI.s32Height &&
713  pFormatList->FormatInfo[i].nWidth == (UINT)rectAOI.s32Width) {
714  format = pFormatList->FormatInfo[i].nFormatID;
715  break;
716  }
717  }
718  }
719  else {
720  throw(vpException(vpException::fatalError, "uEye error: is_ImageFormat returned %d", ret));
721  }
722 
723  delete (pFormatList);
724  }
725  else {
726  throw(vpException(vpException::fatalError, "uEye error: is_ImageFormat returned %d", ret));
727  }
728  return format;
729  }
730 
731  int setActiveCamera(unsigned int cam_index)
732  {
733  m_cameraList = new CameraList;
734  m_activeCameraSelected = m_cameraList->setActiveCamera(cam_index);
735  if (!m_activeCameraSelected) {
736  m_CamListInfo = m_cameraList->getCameraInfo();
737  }
738  delete m_cameraList;
739  return m_activeCameraSelected;
740  }
741 
742  std::string toUpper(const std::basic_string<char> &s)
743  {
744  std::string s_upper = s;
745  for (std::basic_string<char>::iterator p = s_upper.begin(); p != s_upper.end(); ++p) {
746  *p = toupper(*p);
747  }
748  return s_upper;
749  }
750 
751  int setColorMode(const std::string &color_mode)
752  {
753  if (!isConnected()) {
755  "Cannot set color mode. Connection to active uEye camera is not opened"));
756  }
757 
758  std::string color_mode_upper = toUpper(color_mode);
759  int cm = IS_CM_MONO8;
760  if (color_mode_upper == "MONO8") {
761  cm = IS_CM_MONO8;
762  }
763  else if (color_mode_upper == "RGB24") {
764  cm = IS_CM_BGR8_PACKED;
765  }
766  else if (color_mode_upper == "RGB32") {
767  cm = IS_CM_RGBA8_PACKED;
768  }
769  else if (color_mode_upper == "BAYER8") {
770  cm = IS_CM_SENSOR_RAW8;
771  }
772  else {
773  throw(vpException(vpException::fatalError, "Unsupported color mode %s", color_mode.c_str()));
774  }
775 
776  INT ret = IS_SUCCESS;
777  if ((ret = is_SetColorMode(m_hCamera, cm)) != IS_SUCCESS) {
778  std::cout << "Could not set color mode of " << m_CamListInfo.Model << " to " << color_mode << std::endl;
779  }
780  else {
781  setupCapture();
782  }
783  return ret;
784  }
785 
786  int setFrameRate(bool auto_frame_rate, double frame_rate_hz)
787  {
788  if (!isConnected()) {
790  "Cannot set frame rate. Connection to active uEye camera is not opened"));
791  }
792 
793  INT ret = IS_SUCCESS;
794 
795  // Auto
796  if (auto_frame_rate) {
797  double pval1 = 0, pval2 = 0;
798 
799  // Make sure that auto shutter is enabled before enabling auto frame rate
800  bool autoShutterOn = false;
801  is_SetAutoParameter(m_hCamera, IS_GET_ENABLE_AUTO_SENSOR_SHUTTER, &pval1, &pval2);
802  autoShutterOn |= (pval1 != 0);
803  is_SetAutoParameter(m_hCamera, IS_GET_ENABLE_AUTO_SHUTTER, &pval1, &pval2);
804  autoShutterOn |= (pval1 != 0);
805  if (!autoShutterOn) {
806  if (m_verbose) {
807  std::cout << "Auto shutter mode is not supported for " << m_CamListInfo.Model << std::endl;
808  }
809  return IS_NO_SUCCESS;
810  }
811 
812  // Set frame rate / auto
813  pval1 = auto_frame_rate;
814  if ((ret = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_FRAMERATE, &pval1, &pval2)) != IS_SUCCESS) {
815  if ((ret = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_FRAMERATE, &pval1, &pval2)) != IS_SUCCESS) {
816  if (m_verbose) {
817  std::cout << "Auto frame rate mode is not supported for " << m_CamListInfo.Model << std::endl;
818  }
819  return IS_NO_SUCCESS;
820  }
821  }
822  }
823  else { // Manual
824  double minFrameTime, maxFrameTime, intervalFrameTime, newFrameRate;
825  // Make sure that user-requested frame rate is achievable
826  if ((ret = is_GetFrameTimeRange(m_hCamera, &minFrameTime, &maxFrameTime, &intervalFrameTime)) != IS_SUCCESS) {
827  if (m_verbose) {
828  std::cout << "Failed to query valid frame rate range from " << m_CamListInfo.Model << std::endl;
829  }
830  return ret;
831  }
832  CAP(frame_rate_hz, 1.0 / maxFrameTime, 1.0 / minFrameTime);
833 
834  // Update frame rate
835  if ((ret = is_SetFrameRate(m_hCamera, frame_rate_hz, &newFrameRate)) != IS_SUCCESS) {
836  if (m_verbose) {
837  std::cout << "Failed to set frame rate to " << frame_rate_hz << " MHz for " << m_CamListInfo.Model
838  << std::endl;
839  }
840  return ret;
841  }
842  else if (frame_rate_hz != newFrameRate) {
843  frame_rate_hz = newFrameRate;
844  }
845  }
846 
847  if (m_verbose) {
848  std::cout << "Updated frame rate for " << m_CamListInfo.Model << ": "
849  << ((auto_frame_rate) ? "auto" : std::to_string(frame_rate_hz)) << " Hz" << std::endl;
850  }
851 
852  return ret;
853  }
854 
855  int setExposure(bool auto_exposure, double exposure_ms)
856  {
857  if (!isConnected()) {
858  throw(
859  vpException(vpException::fatalError, "Cannot set exposure. Connection to active uEye camera is not opened"));
860  }
861 
862  INT err = IS_SUCCESS;
863 
864  double minExposure, maxExposure;
865 
866  // Set auto exposure
867  if (auto_exposure) {
868  double pval1 = auto_exposure, pval2 = 0;
869  if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_SHUTTER, &pval1, &pval2)) != IS_SUCCESS) {
870  if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SHUTTER, &pval1, &pval2)) != IS_SUCCESS) {
871  std::cout << "Auto exposure mode is not supported for " << m_CamListInfo.Model << std::endl;
872  return IS_NO_SUCCESS;
873  }
874  }
875  }
876 
877  else { // Set manual exposure timing
878  // Make sure that user-requested exposure rate is achievable
879  if (((err = is_Exposure(m_hCamera, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MIN, (void *)&minExposure,
880  sizeof(minExposure))) != IS_SUCCESS) ||
881  ((err = is_Exposure(m_hCamera, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MAX, (void *)&maxExposure,
882  sizeof(maxExposure))) != IS_SUCCESS)) {
883  std::cout << "Failed to query valid exposure range from " << m_CamListInfo.Model << std::endl;
884  return err;
885  }
886  CAP(exposure_ms, minExposure, maxExposure);
887 
888  // Update exposure
889  if ((err = is_Exposure(m_hCamera, IS_EXPOSURE_CMD_SET_EXPOSURE, (void *)&(exposure_ms), sizeof(exposure_ms))) !=
890  IS_SUCCESS) {
891  std::cout << "Failed to set exposure to " << exposure_ms << " ms for " << m_CamListInfo.Model << std::endl;
892  return err;
893  }
894  }
895 
896  if (m_verbose) {
897  std::cout << "Updated exposure: " << ((auto_exposure) ? "auto" : std::to_string(exposure_ms) + " ms") << " for "
898  << m_CamListInfo.Model << std::endl;
899  }
900 
901  return err;
902  }
903 
904  int setGain(bool auto_gain, int master_gain, bool gain_boost)
905  {
906  if (!isConnected()) {
907  throw(vpException(vpException::fatalError, "Cannot set gain. Connection to active uEye camera is not opened"));
908  }
909 
910  INT err = IS_SUCCESS;
911 
912  // Validate arguments
913  CAP(master_gain, 0, 100);
914 
915  double pval1 = 0, pval2 = 0;
916 
917  if (auto_gain) {
918  // Set auto gain
919  pval1 = 1;
920  if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_GAIN, &pval1, &pval2)) != IS_SUCCESS) {
921  if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_GAIN, &pval1, &pval2)) != IS_SUCCESS) {
922  if (m_verbose) {
923  std::cout << m_CamListInfo.Model << " does not support auto gain mode" << std::endl;
924  }
925  return IS_NO_SUCCESS;
926  }
927  }
928  }
929  else {
930  // Disable auto gain
931  if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_GAIN, &pval1, &pval2)) != IS_SUCCESS) {
932  if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_GAIN, &pval1, &pval2)) != IS_SUCCESS) {
933  std::cout << m_CamListInfo.Model << " does not support auto gain mode" << std::endl;
934  }
935  }
936 
937  // Set gain boost
938  if (is_SetGainBoost(m_hCamera, IS_GET_SUPPORTED_GAINBOOST) != IS_SET_GAINBOOST_ON) {
939  gain_boost = false;
940  }
941  else {
942  if ((err = is_SetGainBoost(m_hCamera, (gain_boost) ? IS_SET_GAINBOOST_ON : IS_SET_GAINBOOST_OFF)) !=
943  IS_SUCCESS) {
944  std::cout << "Failed to " << ((gain_boost) ? "enable" : "disable") << " gain boost for "
945  << m_CamListInfo.Model << std::endl;
946  }
947  }
948 
949  // Set manual gain parameters
950  if ((err = is_SetHardwareGain(m_hCamera, master_gain, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER,
951  IS_IGNORE_PARAMETER)) != IS_SUCCESS) {
952  std::cout << "Failed to set manual master gain: " << master_gain << " for " << m_CamListInfo.Model << std::endl;
953  return IS_NO_SUCCESS;
954  }
955  }
956 
957  if (m_verbose) {
958  if (auto_gain) {
959  std::cout << "Updated gain for " << m_CamListInfo.Model << ": auto" << std::endl;
960  }
961  else {
962  std::cout << "Updated gain for " << m_CamListInfo.Model << ": manual master gain " << master_gain << std::endl;
963  }
964  std::cout << "\n gain boost: " << (gain_boost ? "enabled" : "disabled") << std::endl;
965  ;
966  }
967 
968  return err;
969  }
970 
971  void applySubsamplingSettings(int subsamplingMode, int nMode)
972  {
973  INT ret = IS_SUCCESS;
974  int currentSubsampling = is_SetSubSampling(m_hCamera, IS_GET_SUBSAMPLING);
975  if ((ret = is_SetSubSampling(m_hCamera, subsamplingMode | nMode)) != IS_SUCCESS) {
976  throw(vpException(vpException::fatalError, "Unable to apply subsampling factor"));
977  }
978 
979  int newSubsampling = is_SetSubSampling(m_hCamera, IS_GET_SUBSAMPLING);
980  if ((nMode == IS_SUBSAMPLING_DISABLE) && (currentSubsampling == newSubsampling)) {
981  // the subsampling nMode IS_SUBSAMPLING_DISABLE was expected, but the device
982  // did not changed the format, disable subsampling.
983  if ((ret = is_SetSubSampling(m_hCamera, IS_SUBSAMPLING_DISABLE)) != IS_SUCCESS) {
984  throw(vpException(vpException::fatalError, "Unable to apply subsampling factor"));
985  }
986  }
987  }
988 
989  void setSubsampling(int factor)
990  {
991  if (!isConnected()) {
993  "Cannot set sub sampling factor. Connection to active uEye camera is not opened"));
994  }
995 
996  INT hMode = IS_SUBSAMPLING_DISABLE, vMode = IS_SUBSAMPLING_DISABLE;
997 
998  switch (factor) {
999  case 2:
1000  hMode = IS_SUBSAMPLING_2X_HORIZONTAL;
1001  vMode = IS_SUBSAMPLING_2X_VERTICAL;
1002  break;
1003  case 3:
1004  hMode = IS_SUBSAMPLING_3X_HORIZONTAL;
1005  vMode = IS_SUBSAMPLING_3X_VERTICAL;
1006  break;
1007  case 4:
1008  hMode = IS_SUBSAMPLING_4X_HORIZONTAL;
1009  vMode = IS_SUBSAMPLING_4X_VERTICAL;
1010  break;
1011  case 5:
1012  hMode = IS_SUBSAMPLING_5X_HORIZONTAL;
1013  vMode = IS_SUBSAMPLING_5X_VERTICAL;
1014  break;
1015  case 6:
1016  hMode = IS_SUBSAMPLING_6X_HORIZONTAL;
1017  vMode = IS_SUBSAMPLING_6X_VERTICAL;
1018  break;
1019  case 8:
1020  hMode = IS_SUBSAMPLING_8X_HORIZONTAL;
1021  vMode = IS_SUBSAMPLING_8X_VERTICAL;
1022  break;
1023  case 16:
1024  hMode = IS_SUBSAMPLING_16X_HORIZONTAL;
1025  vMode = IS_SUBSAMPLING_16X_VERTICAL;
1026  break;
1027  default:
1028  hMode = IS_SUBSAMPLING_DISABLE;
1029  vMode = IS_SUBSAMPLING_DISABLE;
1030  }
1031 
1032  if (m_bLive && m_bLiveStarted) {
1033  is_StopLiveVideo(m_hCamera, IS_WAIT);
1034  }
1035 
1036  INT subsamplingModeH = is_SetSubSampling(m_hCamera, IS_GET_SUBSAMPLING) & IS_SUBSAMPLING_MASK_VERTICAL;
1037  applySubsamplingSettings(subsamplingModeH, hMode);
1038 
1039  INT subsamplingModeV = is_SetSubSampling(m_hCamera, IS_GET_SUBSAMPLING) & IS_SUBSAMPLING_MASK_HORIZONTAL;
1040  applySubsamplingSettings(subsamplingModeV, vMode);
1041 
1042  setupCapture();
1043  }
1044 
1045  void setWhiteBalance(bool auto_wb)
1046  {
1047  if (!isConnected()) {
1049  "Cannot set white balance. Connection to active uEye camera is not opened"));
1050  }
1051 
1052  double dblAutoWb = 0.0;
1053 
1054  if (auto_wb) {
1055  dblAutoWb = 0.0;
1056  is_SetAutoParameter(m_hCamera, IS_SET_AUTO_WB_ONCE, &dblAutoWb, nullptr);
1057 
1058  dblAutoWb = 1.0;
1059  is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_WHITEBALANCE, &dblAutoWb, nullptr);
1060  }
1061  else {
1062  dblAutoWb = 0.0;
1063  is_SetAutoParameter(m_hCamera, IS_SET_AUTO_WB_ONCE, &dblAutoWb, nullptr);
1064  is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_WHITEBALANCE, &dblAutoWb, nullptr);
1065  }
1066  }
1067 
1068  int setupCapture()
1069  {
1070  int width, height;
1071  // init the memorybuffer properties
1072  ZeroMemory(&m_BufferProps, sizeof(m_BufferProps));
1073 
1074  IS_RECT rectAOI;
1075  INT nRet = is_AOI(m_hCamera, IS_AOI_IMAGE_GET_AOI, (void *)&rectAOI, sizeof(rectAOI));
1076 
1077  if (nRet == IS_SUCCESS) {
1078  width = rectAOI.s32Width;
1079  height = rectAOI.s32Height;
1080 
1081  // get current colormode
1082  int colormode = is_SetColorMode(m_hCamera, IS_GET_COLOR_MODE);
1083 
1084  if (colormode == IS_CM_BGR5_PACKED) {
1085  is_SetColorMode(m_hCamera, IS_CM_BGR565_PACKED);
1086  colormode = IS_CM_BGR565_PACKED;
1087  std::cout << "uEye color format 'IS_CM_BGR5_PACKED' actually not supported by vpUeyeGrabber, patched to "
1088  "'IS_CM_BGR565_PACKED'"
1089  << std::endl;
1090  }
1091 
1092  // fill memorybuffer properties
1093  ZeroMemory(&m_BufferProps, sizeof(m_BufferProps));
1094  m_BufferProps.width = width;
1095  m_BufferProps.height = height;
1096  m_BufferProps.bitspp = getBitsPerPixel(colormode);
1097 
1098  // Reallocate image buffers
1099  allocImages();
1100 
1101  if (m_verbose) {
1102  std::cout << "Capture ready set up." << std::endl;
1103  }
1104  }
1105  return 0;
1106  }
1107 
1108  void setVerbose(bool verbose) { m_verbose = verbose; }
1109 
1110 private:
1111  HIDS m_hCamera; // handle to camera
1112  int m_activeCameraSelected;
1113  SENSORINFO m_SensorInfo; // sensor information struct
1114  CAMINFO m_CamInfo; // Camera (Board)info
1115  UEYE_CAMERA_INFO m_CamListInfo;
1116  char *m_pLastBuffer;
1117  CameraList *m_cameraList;
1118  struct sBufferProps m_BufferProps;
1119  struct sCameraProps m_CameraProps;
1120  UEYE_IMAGE m_Images[IMAGE_COUNT]; // uEye frame buffer array
1121  bool m_bLive; // live or snapshot indicator
1122  bool m_bLiveStarted; // live mode is started
1123  bool m_verbose;
1124  /* event waiting for */
1125  int m_event;
1126 #ifndef __linux__
1127  /* on windows we need an Event handle member */
1128  HANDLE m_hEvent;
1129 #endif
1130  vpImage<vpRGBa> m_I_temp; // Temp image used for Bayer conversion
1131  };
1132 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
1133 
1134 /*
1135  **********************************************************************************************
1136  */
1137 
1143 vpUeyeGrabber::vpUeyeGrabber() : m_impl(new vpUeyeGrabberImpl()) { }
1144 
1148 vpUeyeGrabber::~vpUeyeGrabber() { delete m_impl; }
1149 
1171 void vpUeyeGrabber::acquire(vpImage<unsigned char> &I, double *timestamp_camera, std::string *timestamp_system)
1172 {
1173  m_impl->acquire(I, timestamp_camera, timestamp_system);
1174 }
1175 
1196 void vpUeyeGrabber::acquire(vpImage<vpRGBa> &I, double *timestamp_camera, std::string *timestamp_system)
1197 {
1198  m_impl->acquire(I, timestamp_camera, timestamp_system);
1199 }
1200 
1206 std::string vpUeyeGrabber::getActiveCameraModel() const { return m_impl->getActiveCameraModel(); }
1207 
1213 std::string vpUeyeGrabber::getActiveCameraSerialNumber() const { return m_impl->getActiveCameraSerialNumber(); }
1214 
1222 std::vector<unsigned int> vpUeyeGrabber::getCameraIDList() const { return m_impl->getCameraIDList(); }
1223 
1231 std::vector<std::string> vpUeyeGrabber::getCameraModelList() const { return m_impl->getCameraModelList(); }
1232 
1240 std::vector<std::string> vpUeyeGrabber::getCameraSerialNumberList() const
1241 {
1242  return m_impl->getCameraSerialNumberList();
1243 }
1244 
1251 double vpUeyeGrabber::getFramerate() const { return m_impl->getFramerate(); }
1252 
1260 unsigned int vpUeyeGrabber::getFrameHeight() const { return m_impl->getFrameHeight(); }
1261 
1269 unsigned int vpUeyeGrabber::getFrameWidth() const { return m_impl->getFrameWidth(); }
1270 
1274 bool vpUeyeGrabber::isConnected() const { return m_impl->isConnected(); }
1275 
1281 void vpUeyeGrabber::loadParameters(const std::string &filename) { m_impl->loadParameters(filename); }
1282 
1287 void vpUeyeGrabber::open(vpImage<unsigned char> &I) { m_impl->open(I); }
1288 
1293 void vpUeyeGrabber::open(vpImage<vpRGBa> &I) { m_impl->open(I); }
1294 
1300 bool vpUeyeGrabber::setActiveCamera(unsigned int cam_index)
1301 {
1302  return (m_impl->setActiveCamera(cam_index) ? false : true);
1303 }
1304 
1320 bool vpUeyeGrabber::setColorMode(const std::string &color_mode)
1321 {
1322  return (m_impl->setColorMode(color_mode) ? false : true);
1323 }
1324 
1338 bool vpUeyeGrabber::setExposure(bool auto_exposure, double exposure_ms)
1339 {
1340  return (m_impl->setExposure(auto_exposure, exposure_ms) ? false : true);
1341 }
1342 
1373 bool vpUeyeGrabber::setFrameRate(bool auto_frame_rate, double manual_frame_rate_hz)
1374 {
1375  return (m_impl->setFrameRate(auto_frame_rate, manual_frame_rate_hz) ? false : true);
1376 }
1377 
1394 bool vpUeyeGrabber::setGain(bool auto_gain, int master_gain, bool gain_boost)
1395 {
1396  return (m_impl->setGain(auto_gain, master_gain, gain_boost) ? false : true);
1397 }
1398 
1409 void vpUeyeGrabber::setSubsampling(int factor) { m_impl->setSubsampling(factor); }
1410 
1421 void vpUeyeGrabber::setWhiteBalance(bool auto_wb) { m_impl->setWhiteBalance(auto_wb); }
1422 
1428 void vpUeyeGrabber::setVerbose(bool verbose) { m_impl->setVerbose(verbose); }
1429 END_VISP_NAMESPACE
1430 #elif !defined(VISP_BUILD_SHARED_LIBS)
1431 // Work around to avoid warning: libvisp_sensor.a(vpUeyeGrabber.cpp.o) has no symbols
1432 void dummy_vpUeyeGrabber() { };
1433 
1434 #endif
error that can be emitted by ViSP classes.
Definition: vpException.h:60
@ fatalError
Fatal error.
Definition: vpException.h:72
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int width, unsigned int height)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
static void BGRaToGrey(unsigned char *bgra, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
static void BGRToRGBa(unsigned char *bgr, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
static void demosaicRGGBToRGBaBilinear(const uint8_t *rggb, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads=0)
static void BGRaToRGBa(unsigned char *bgra, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:542
Type * bitmap
points toward the bitmap
Definition: vpImage.h:135
static bool checkFilename(const std::string &filename)
Definition: vpIoTools.cpp:786
void open(vpImage< unsigned char > &I)
std::vector< std::string > getCameraSerialNumberList() const
bool setExposure(bool auto_exposure, double exposure_ms=-1)
bool setFrameRate(bool auto_frame_rate, double manual_frame_rate_hz=-1)
void setVerbose(bool verbose)
void setWhiteBalance(bool auto_wb)
bool setGain(bool auto_gain, int master_gain=-1, bool gain_boost=false)
void acquire(vpImage< unsigned char > &I, double *timestamp_camera=nullptr, std::string *timestamp_system=nullptr)
double getFramerate() const
void loadParameters(const std::string &filename)
std::vector< std::string > getCameraModelList() const
std::vector< unsigned int > getCameraIDList() const
bool isConnected() const
void setSubsampling(int factor)
unsigned int getFrameHeight() const
unsigned int getFrameWidth() const
bool setActiveCamera(unsigned int cam_index)
bool setColorMode(const std::string &color_mode)
std::string getActiveCameraModel() const
std::string getActiveCameraSerialNumber() const
virtual ~vpUeyeGrabber()
VISP_EXPORT double measureTimeSecond()