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