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