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