36 #include <visp3/core/vpConfig.h> 38 #if defined(VISP_HAVE_UEYE) 42 #include <visp3/core/vpImageConvert.h> 43 #include <visp3/core/vpIoTools.h> 44 #include <visp3/sensor/vpUeyeGrabber.h> 48 #include "vpUeyeGrabber_impl.h" 50 #ifndef DOXYGEN_SHOULD_SKIP_THIS 56 #define CAMINFO BOARDINFO 57 #define EVENTTHREAD_WAIT_TIMEOUT 1000 59 #define CAP(val, min, max) \ 63 } else if (val > max) { \ 79 bool bUsesImageFormats;
81 int nImgFmtDefaultNormal;
83 int nImgFmtDefaultTrigger;
89 typedef struct _UEYE_IMAGE
95 } UEYE_IMAGE, *PUEYE_IMAGE;
97 class vpUeyeGrabber::vpUeyeGrabberImpl
101 : m_hCamera((HIDS)0), m_nMemoryId(0), m_nColorMode(0), m_nBitsPerPixel(0), m_activeCameraSelected(-1),
102 m_pLastBuffer(NULL), m_cameraList(NULL), m_bLive(true), m_bLiveStarted(false), m_verbose(false)
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));
109 m_BufferProps.width = 0;
110 m_BufferProps.height = 0;
111 m_BufferProps.bitspp = 8;
119 m_activeCameraSelected = setActiveCamera(0);
129 INT ret = IS_SUCCESS;
137 ret = is_FreezeVideo(m_hCamera, IS_WAIT);
140 if (! m_bLiveStarted) {
141 ret = is_CaptureVideo(m_hCamera, IS_DONT_WAIT);
142 m_bLiveStarted =
true;
148 if (ret == IS_SUCCESS) {
150 char *pLast = NULL, *pMem = NULL;
152 is_GetActSeqBuf (m_hCamera, &dummy, &pMem, &pLast);
153 m_pLastBuffer = pLast;
155 if (!m_pLastBuffer || m_BufferProps.width < 1 || m_BufferProps.height < 1)
158 int nNum = getImageNum (m_pLastBuffer);
159 if (timestamp_camera != NULL || timestamp_system != NULL) {
160 int nImageID = getImageID(m_pLastBuffer);
161 UEYEIMAGEINFO ImageInfo;
162 if (is_GetImageInfo(m_hCamera, nImageID, &ImageInfo,
sizeof (ImageInfo)) == IS_SUCCESS) {
163 if (timestamp_camera != NULL) {
164 *timestamp_camera =
static_cast<double>(ImageInfo.u64TimestampDevice) / 10000.;
166 if (timestamp_system != NULL) {
167 std::stringstream ss;
168 ss << ImageInfo.TimestampSystem.wYear <<
":" 169 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wMonth <<
":" 170 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wDay <<
":" 171 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wHour <<
":" 172 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wMinute <<
":" 173 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wSecond <<
":" 174 << std::setfill(
'0') << std::setw(3) << ImageInfo.TimestampSystem.wMilliseconds;
175 *timestamp_system = ss.str();
180 helper::LockUnlockSeqBuffer lock(m_hCamera, nNum, m_pLastBuffer);
182 if (lock.OwnsLock()) {
184 int colormode = is_SetColorMode(m_hCamera, IS_GET_COLOR_MODE);
189 case IS_CM_SENSOR_RAW8:
190 memcpy(reinterpret_cast<unsigned char*>(I.
bitmap), reinterpret_cast<unsigned char*>(m_pLastBuffer), m_BufferProps.width * m_BufferProps.height * m_BufferProps.bitspp / 8);
192 case IS_CM_BGR565_PACKED:
195 case IS_CM_RGB8_PACKED:
197 m_BufferProps.width, m_BufferProps.height);
199 case IS_CM_BGR8_PACKED:
201 m_BufferProps.width, m_BufferProps.height);
203 case IS_CM_RGBA8_PACKED:
205 m_BufferProps.width, m_BufferProps.height);
207 case IS_CM_BGRA8_PACKED:
209 m_BufferProps.width, m_BufferProps.height);
217 void acquire(
vpImage<vpRGBa> &I,
double *timestamp_camera, std::string *timestamp_system)
219 INT ret = IS_SUCCESS;
227 ret = is_FreezeVideo(m_hCamera, IS_WAIT);
230 if (! m_bLiveStarted) {
232 ret = is_CaptureVideo(m_hCamera, IS_WAIT);
233 m_bLiveStarted =
true;
239 if (ret == IS_SUCCESS) {
241 char *pLast = NULL, *pMem = NULL;
243 is_GetActSeqBuf (m_hCamera, &dummy, &pMem, &pLast);
244 m_pLastBuffer = pLast;
246 if (!m_pLastBuffer || m_BufferProps.width < 1 || m_BufferProps.height < 1)
249 int nNum = getImageNum (m_pLastBuffer);
250 if (timestamp_camera != NULL || timestamp_system != NULL) {
251 int nImageID = getImageID(m_pLastBuffer);
252 UEYEIMAGEINFO ImageInfo;
253 if (is_GetImageInfo(m_hCamera, nImageID, &ImageInfo,
sizeof (ImageInfo)) == IS_SUCCESS) {
254 if (timestamp_camera != NULL) {
255 *timestamp_camera =
static_cast<double>(ImageInfo.u64TimestampDevice) / 10000.;
257 if (timestamp_system != NULL) {
258 std::stringstream ss;
259 ss << ImageInfo.TimestampSystem.wYear <<
":" 260 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wMonth <<
":" 261 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wDay <<
":" 262 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wHour <<
":" 263 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wMinute <<
":" 264 << std::setfill(
'0') << std::setw(2) << ImageInfo.TimestampSystem.wSecond <<
":" 265 << std::setfill(
'0') << std::setw(3) << ImageInfo.TimestampSystem.wMilliseconds;
266 *timestamp_system = ss.str();
271 helper::LockUnlockSeqBuffer lock(m_hCamera, nNum, m_pLastBuffer);
273 if (lock.OwnsLock()) {
275 int colormode = is_SetColorMode(m_hCamera, IS_GET_COLOR_MODE);
280 case IS_CM_SENSOR_RAW8:
282 m_BufferProps.width, m_BufferProps.height);
284 case IS_CM_BGR565_PACKED:
287 case IS_CM_RGB8_PACKED:
289 m_BufferProps.width, m_BufferProps.height);
291 case IS_CM_BGR8_PACKED:
293 m_BufferProps.width, m_BufferProps.height);
295 case IS_CM_RGBA8_PACKED:
296 memcpy(reinterpret_cast<unsigned char*>(I.
bitmap), reinterpret_cast<unsigned char*>(m_pLastBuffer), m_BufferProps.width * m_BufferProps.height * m_BufferProps.bitspp / 8);
298 case IS_CM_BGRA8_PACKED:
300 m_BufferProps.width, m_BufferProps.height);
310 m_pLastBuffer = NULL;
317 is_AOI(m_hCamera, IS_AOI_IMAGE_GET_POS_X_ABS, (
void*)&nAbsPosX ,
sizeof(nAbsPosX));
318 is_AOI(m_hCamera, IS_AOI_IMAGE_GET_POS_Y_ABS, (
void*)&nAbsPosY ,
sizeof(nAbsPosY));
320 is_ClearSequence(m_hCamera);
323 for (
unsigned int i = 0; i <
sizeof(m_Images) /
sizeof(m_Images[0]); i++) {
324 nWidth = m_BufferProps.width;
325 nHeight = m_BufferProps.height;
328 m_BufferProps.width = nWidth = m_SensorInfo.nMaxWidth;
331 m_BufferProps.height = nHeight = m_SensorInfo.nMaxHeight;
334 if (is_AllocImageMem (m_hCamera, nWidth, nHeight, m_BufferProps.bitspp, &m_Images[i].pBuf,
335 &m_Images[i].nImageID) != IS_SUCCESS)
337 if (is_AddToSequence (m_hCamera, m_Images[i].pBuf, m_Images[i].nImageID) != IS_SUCCESS)
340 m_Images[i].nImageSeqNum = i + 1;
341 m_Images[i].nBufferSize = nWidth * nHeight * m_BufferProps.bitspp / 8;
347 int cameraInitialized()
350 unsigned int uInitialParameterSet = IS_CONFIG_INITIAL_PARAMETERSET_NONE;
352 if ((ret=is_GetCameraInfo (m_hCamera, &m_CamInfo)) != IS_SUCCESS) {
355 else if ((ret=is_GetSensorInfo (m_hCamera, &m_SensorInfo)) != IS_SUCCESS) {
358 else if ((ret = is_Configuration(IS_CONFIG_INITIAL_PARAMETERSET_CMD_GET, &uInitialParameterSet,
sizeof(
unsigned int))) != IS_SUCCESS) {
369 if (uInitialParameterSet == IS_CONFIG_INITIAL_PARAMETERSET_NONE)
371 ret = is_ResetToDefault (m_hCamera);
375 if (m_SensorInfo.nColorMode >= IS_COLORMODE_BAYER) {
376 colormode = IS_CM_BGRA8_PACKED;
379 colormode = IS_CM_MONO8;
382 if (is_SetColorMode (m_hCamera, colormode) != IS_SUCCESS) {
387 ZeroMemory (&m_CameraProps,
sizeof(m_CameraProps));
390 m_CameraProps.bUsesImageFormats =
false;
391 INT nAOISupported = 0;
392 if (is_ImageFormat(m_hCamera, IMGFRMT_CMD_GET_ARBITRARY_AOI_SUPPORTED, (
void*)&nAOISupported,
393 sizeof(nAOISupported)) == IS_SUCCESS) {
394 m_CameraProps.bUsesImageFormats = (nAOISupported == 0);
398 if (m_CameraProps.bUsesImageFormats) {
400 m_CameraProps.nImgFmtNormal = searchDefImageFormats(CAPTMODE_FREERUN | CAPTMODE_SINGLE);
401 m_CameraProps.nImgFmtDefaultNormal = m_CameraProps.nImgFmtNormal;
402 m_CameraProps.nImgFmtTrigger = searchDefImageFormats(CAPTMODE_TRIGGER_SOFT_SINGLE);
403 m_CameraProps.nImgFmtDefaultTrigger = m_CameraProps.nImgFmtTrigger;
405 if ((ret=is_ImageFormat(m_hCamera, IMGFRMT_CMD_SET_FORMAT, (
void*)&m_CameraProps.nImgFmtNormal,
406 sizeof(m_CameraProps.nImgFmtNormal))) == IS_SUCCESS) {
415 enableEvent(IS_SET_EVENT_FRAME);
418 m_pLastBuffer = NULL;
425 if (m_hCamera == IS_INVALID_HIDS)
429 if (m_bLive && m_bLiveStarted) {
433 nRet = is_StopLiveVideo(m_hCamera, IS_WAIT);
435 m_bLiveStarted =
false;
438 is_ClearSequence(m_hCamera);
441 if (is_ExitCamera(m_hCamera) != IS_SUCCESS) {
453 is_DisableEvent (m_hCamera, m_event);
455 is_ExitEvent(m_hCamera, m_event);
456 CloseHandle(m_hEvent);
461 int enableEvent(
int event)
466 m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
467 if (m_hEvent == NULL) {
470 ret = is_InitEvent(m_hCamera, m_hEvent, m_event);
472 ret = is_EnableEvent (m_hCamera, m_event);
480 if (is_WaitEvent (m_hCamera, m_event, EVENTTHREAD_WAIT_TIMEOUT) == IS_SUCCESS) {
482 if (WaitForSingleObject(m_hEvent, EVENTTHREAD_WAIT_TIMEOUT) == WAIT_OBJECT_0) {
493 m_pLastBuffer = NULL;
495 for (
unsigned int i = 0; i <
sizeof(m_Images) /
sizeof(m_Images[0]); i++) {
496 if (NULL != m_Images[i].pBuf) {
497 is_FreeImageMem (m_hCamera, m_Images[i].pBuf, m_Images[i].nImageID);
500 m_Images[i].pBuf = NULL;
501 m_Images[i].nImageID = 0;
502 m_Images[i].nImageSeqNum = 0;
506 std::string getActiveCameraModel()
const 508 return m_CamListInfo.Model;
511 std::string getActiveCameraSerialNumber()
const 513 return m_CamListInfo.SerNo;
516 int getBitsPerPixel(
int colormode)
522 case IS_CM_SENSOR_RAW8:
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:
533 case IS_CM_RGB8_PACKED:
534 case IS_CM_BGR8_PACKED:
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:
546 std::vector<unsigned int> getCameraIDList()
const 548 CameraList camera_list;
549 return camera_list.getCameraIDList();
552 std::vector<std::string> getCameraModelList()
const 554 CameraList camera_list;
555 return camera_list.getCameraModelList();
558 std::vector<std::string> getCameraSerialNumberList()
const 560 CameraList camera_list;
561 return camera_list.getCameraSerialNumberList();
564 unsigned int getFrameHeight()
const 566 if (!isConnected()) {
569 return static_cast<unsigned int>(m_BufferProps.height);
572 unsigned int getFrameWidth()
const 574 if (!isConnected()) {
577 return static_cast<unsigned int>(m_BufferProps.width);
580 double getFramerate()
const 588 if (is_GetFramesPerSecond (m_hCamera, &fps) != IS_SUCCESS) {
590 std::cout <<
"Unable to get acquisition frame rate" << std::endl;
596 INT getImageID (
char* pbuf)
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;
608 INT getImageNum(
char* pbuf)
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;
620 bool isConnected()
const 622 return (m_hCamera != (HIDS) 0);
625 void loadParameters(
const std::string &filename)
631 const std::wstring filename_(filename.begin(), filename.end());
632 int ret = is_ParameterSet(m_hCamera, IS_PARAMETERSET_CMD_LOAD_FILE, (
void*) filename_.c_str(), 0);
634 if (ret == IS_INVALID_CAMERA_TYPE) {
637 else if (ret == IS_INCOMPATIBLE_SETTING) {
640 else if (ret != IS_SUCCESS) {
644 std::cout <<
"Parameters loaded sucessfully" << std::endl;
653 if (is_ExitCamera(m_hCamera) != IS_SUCCESS) {
659 m_hCamera = (HIDS) (m_CamListInfo.dwDeviceID | IS_USE_DEVICE_ID);
661 if (is_InitCamera(&m_hCamera, 0) != IS_SUCCESS) {
665 int ret = cameraInitialized();
666 if (ret != IS_SUCCESS) {
671 template <
class Type>
675 I.
resize(m_SensorInfo.nMaxHeight, m_SensorInfo.nMaxWidth);
683 int searchDefImageFormats(
int suppportMask)
685 int ret = IS_SUCCESS;
688 IMAGE_FORMAT_LIST *pFormatList;
691 if ((ret=is_ImageFormat(m_hCamera, IMGFRMT_CMD_GET_NUM_ENTRIES, (
void*)&nNumber,
sizeof(nNumber))) == IS_SUCCESS &&
692 (ret=is_AOI(m_hCamera, IS_AOI_IMAGE_GET_AOI, (
void*)&rectAOI,
sizeof(rectAOI))) == IS_SUCCESS) {
694 int nSize =
sizeof(IMAGE_FORMAT_LIST) + (nNumber - 1) *
sizeof(IMAGE_FORMAT_LIST);
695 pFormatList = (IMAGE_FORMAT_LIST*)(
new char[nSize]);
696 pFormatList->nNumListElements = nNumber;
697 pFormatList->nSizeOfListEntry =
sizeof(IMAGE_FORMAT_INFO);
699 if((ret=is_ImageFormat(m_hCamera, IMGFRMT_CMD_GET_LIST, (
void*)pFormatList, nSize)) == IS_SUCCESS) {
700 for(i=0; i<nNumber; i++) {
701 if ((pFormatList->FormatInfo[i].nSupportedCaptureModes & suppportMask) &&
702 pFormatList->FormatInfo[i].nHeight == (UINT)rectAOI.s32Height &&
703 pFormatList->FormatInfo[i].nWidth == (UINT)rectAOI.s32Width) {
704 format = pFormatList->FormatInfo[i].nFormatID;
713 delete (pFormatList);
722 int setActiveCamera(
unsigned int cam_index)
724 m_cameraList =
new CameraList;
725 m_activeCameraSelected = m_cameraList->setActiveCamera(cam_index);
726 if (! m_activeCameraSelected) {
727 m_CamListInfo = m_cameraList->getCameraInfo();
730 return m_activeCameraSelected;
733 std::string toUpper(
const std::basic_string<char>& s)
735 std::string s_upper = s;
736 for (std::basic_string<char>::iterator p = s_upper.begin(); p != s_upper.end(); ++p) {
742 int setColorMode(
const std::string &color_mode)
744 if (! isConnected()) {
748 std::string color_mode_upper = toUpper(color_mode);
749 int cm = IS_CM_MONO8;
750 if (color_mode_upper ==
"MONO8") {
753 else if (color_mode_upper ==
"RGB24") {
754 cm = IS_CM_BGR8_PACKED;
756 else if (color_mode_upper ==
"RGB32") {
757 cm = IS_CM_RGBA8_PACKED;
763 INT ret = IS_SUCCESS;
764 if ((ret = is_SetColorMode(m_hCamera, cm)) != IS_SUCCESS) {
765 std::cout <<
"Could not set color mode of " << m_CamListInfo.Model <<
" to " << color_mode << std::endl;
773 int setFrameRate(
bool auto_frame_rate,
double frame_rate_hz)
775 if (! isConnected()) {
779 INT ret = IS_SUCCESS;
782 if (auto_frame_rate) {
783 double pval1 = 0, pval2 = 0;
786 bool autoShutterOn =
false;
787 is_SetAutoParameter(m_hCamera, IS_GET_ENABLE_AUTO_SENSOR_SHUTTER, &pval1, &pval2);
788 autoShutterOn |= (pval1 != 0);
789 is_SetAutoParameter(m_hCamera, IS_GET_ENABLE_AUTO_SHUTTER, &pval1, &pval2);
790 autoShutterOn |= (pval1 != 0);
791 if (!autoShutterOn) {
793 std::cout <<
"Auto shutter mode is not supported for " << m_CamListInfo.Model << std::endl;
795 return IS_NO_SUCCESS;
799 pval1 = auto_frame_rate;
800 if ((ret = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_FRAMERATE,
801 &pval1, &pval2)) != IS_SUCCESS) {
802 if ((ret = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_FRAMERATE,
803 &pval1, &pval2)) != IS_SUCCESS) {
805 std::cout <<
"Auto frame rate mode is not supported for " << m_CamListInfo.Model << std::endl;
807 return IS_NO_SUCCESS;
812 double minFrameTime, maxFrameTime, intervalFrameTime, newFrameRate;
814 if ((ret = is_GetFrameTimeRange(m_hCamera, &minFrameTime,
815 &maxFrameTime, &intervalFrameTime)) != IS_SUCCESS) {
817 std::cout <<
"Failed to query valid frame rate range from " << m_CamListInfo.Model << std::endl;
821 CAP(frame_rate_hz, 1.0/maxFrameTime, 1.0/minFrameTime);
824 if ((ret = is_SetFrameRate(m_hCamera, frame_rate_hz, &newFrameRate)) != IS_SUCCESS) {
826 std::cout <<
"Failed to set frame rate to " << frame_rate_hz <<
827 " MHz for " << m_CamListInfo.Model << std::endl;
830 }
else if (frame_rate_hz != newFrameRate) {
831 frame_rate_hz = newFrameRate;
836 std::cout <<
"Updated frame rate for " << m_CamListInfo.Model <<
": " <<
837 ((auto_frame_rate) ?
"auto" : std::to_string(frame_rate_hz)) <<
" Hz" << std::endl;
843 int setExposure(
bool auto_exposure,
double exposure_ms)
845 if (! isConnected()) {
849 INT err = IS_SUCCESS;
851 double minExposure, maxExposure;
855 double pval1 = auto_exposure, pval2 = 0;
856 if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_SHUTTER,
857 &pval1, &pval2)) != IS_SUCCESS) {
858 if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SHUTTER,
859 &pval1, &pval2)) != IS_SUCCESS) {
860 std::cout <<
"Auto exposure mode is not supported for " << m_CamListInfo.Model << std::endl;
861 return IS_NO_SUCCESS;
868 if (((err = is_Exposure(m_hCamera, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MIN,
869 (
void*) &minExposure,
sizeof(minExposure))) != IS_SUCCESS) ||
870 ((err = is_Exposure(m_hCamera, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MAX,
871 (
void*) &maxExposure,
sizeof(maxExposure))) != IS_SUCCESS)) {
872 std::cout <<
"Failed to query valid exposure range from " << m_CamListInfo.Model << std::endl;
875 CAP(exposure_ms, minExposure, maxExposure);
878 if ((err = is_Exposure(m_hCamera, IS_EXPOSURE_CMD_SET_EXPOSURE,
879 (
void*) &(exposure_ms),
sizeof(exposure_ms))) != IS_SUCCESS) {
880 std::cout <<
"Failed to set exposure to " << exposure_ms <<
881 " ms for " << m_CamListInfo.Model << std::endl;
887 std::cout <<
"Updated exposure: " << ((auto_exposure) ?
"auto" : std::to_string(exposure_ms) +
" ms") <<
888 " for " << m_CamListInfo.Model << std::endl;
894 int setGain(
bool auto_gain,
int master_gain,
bool gain_boost)
896 if (! isConnected()) {
900 INT err = IS_SUCCESS;
903 CAP(master_gain, 0, 100);
905 double pval1 = 0, pval2 = 0;
910 if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_GAIN,
911 &pval1, &pval2)) != IS_SUCCESS) {
912 if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_GAIN,
913 &pval1, &pval2)) != IS_SUCCESS) {
915 std::cout << m_CamListInfo.Model <<
" does not support auto gain mode" << std::endl;
917 return IS_NO_SUCCESS;
922 if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_SENSOR_GAIN,
923 &pval1, &pval2)) != IS_SUCCESS) {
924 if ((err = is_SetAutoParameter(m_hCamera, IS_SET_ENABLE_AUTO_GAIN,
925 &pval1, &pval2)) != IS_SUCCESS) {
926 std::cout << m_CamListInfo.Model <<
" does not support auto gain mode" << std::endl;
931 if (is_SetGainBoost(m_hCamera, IS_GET_SUPPORTED_GAINBOOST) != IS_SET_GAINBOOST_ON) {
934 if ((err = is_SetGainBoost(m_hCamera,
935 (gain_boost) ? IS_SET_GAINBOOST_ON : IS_SET_GAINBOOST_OFF))
937 std::cout <<
"Failed to " << ((gain_boost) ?
"enable" :
"disable") <<
938 " gain boost for " << m_CamListInfo.Model << std::endl;
943 if ((err = is_SetHardwareGain(m_hCamera, master_gain,
944 IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER)) != IS_SUCCESS) {
945 std::cout <<
"Failed to set manual master gain: " << master_gain <<
" for " << m_CamListInfo.Model << std::endl;
946 return IS_NO_SUCCESS;
952 std::cout <<
"Updated gain for " << m_CamListInfo.Model <<
": auto" << std::endl;
954 std::cout <<
"Updated gain for " << m_CamListInfo.Model <<
": manual master gain " << master_gain << std::endl;
957 std::cout <<
"\n gain boost: " << (gain_boost ?
"enabled" :
"disabled") << std::endl;;
963 void applySubsamplingSettings(
int subsamplingMode,
int nMode)
965 INT ret = IS_SUCCESS;
966 int currentSubsampling = is_SetSubSampling(m_hCamera, IS_GET_SUBSAMPLING);
967 if ((ret = is_SetSubSampling (m_hCamera, subsamplingMode | nMode)) != IS_SUCCESS) {
971 int newSubsampling = is_SetSubSampling(m_hCamera, IS_GET_SUBSAMPLING);
972 if((nMode == IS_SUBSAMPLING_DISABLE) && (currentSubsampling == newSubsampling)) {
975 if ((ret = is_SetSubSampling (m_hCamera, IS_SUBSAMPLING_DISABLE)) != IS_SUCCESS) {
981 void setSubsampling(
int factor)
983 if (! isConnected()) {
987 INT hMode = IS_SUBSAMPLING_DISABLE, vMode = IS_SUBSAMPLING_DISABLE;
991 hMode = IS_SUBSAMPLING_2X_HORIZONTAL;
992 vMode = IS_SUBSAMPLING_2X_VERTICAL;
995 hMode = IS_SUBSAMPLING_3X_HORIZONTAL;
996 vMode = IS_SUBSAMPLING_3X_VERTICAL;
999 hMode = IS_SUBSAMPLING_4X_HORIZONTAL;
1000 vMode = IS_SUBSAMPLING_4X_VERTICAL;
1003 hMode = IS_SUBSAMPLING_5X_HORIZONTAL;
1004 vMode = IS_SUBSAMPLING_5X_VERTICAL;
1007 hMode = IS_SUBSAMPLING_6X_HORIZONTAL;
1008 vMode = IS_SUBSAMPLING_6X_VERTICAL;
1011 hMode = IS_SUBSAMPLING_8X_HORIZONTAL;
1012 vMode = IS_SUBSAMPLING_8X_VERTICAL;
1015 hMode = IS_SUBSAMPLING_16X_HORIZONTAL;
1016 vMode = IS_SUBSAMPLING_16X_VERTICAL;
1019 hMode = IS_SUBSAMPLING_DISABLE;
1020 vMode = IS_SUBSAMPLING_DISABLE;
1023 if (m_bLive && m_bLiveStarted) {
1024 is_StopLiveVideo (m_hCamera, IS_WAIT);
1027 INT subsamplingModeH = is_SetSubSampling (m_hCamera, IS_GET_SUBSAMPLING) & IS_SUBSAMPLING_MASK_VERTICAL;
1028 applySubsamplingSettings(subsamplingModeH, hMode);
1030 INT subsamplingModeV = is_SetSubSampling (m_hCamera, IS_GET_SUBSAMPLING) & IS_SUBSAMPLING_MASK_HORIZONTAL;
1031 applySubsamplingSettings(subsamplingModeV, vMode);
1036 void setWhiteBalance(
bool auto_wb)
1038 if (! isConnected()) {
1042 double dblAutoWb = 0.0;
1046 is_SetAutoParameter (m_hCamera, IS_SET_AUTO_WB_ONCE, &dblAutoWb, NULL);
1049 is_SetAutoParameter (m_hCamera, IS_SET_ENABLE_AUTO_WHITEBALANCE, &dblAutoWb, NULL);
1053 is_SetAutoParameter (m_hCamera, IS_SET_AUTO_WB_ONCE, &dblAutoWb, NULL);
1054 is_SetAutoParameter (m_hCamera, IS_SET_ENABLE_AUTO_WHITEBALANCE, &dblAutoWb, NULL);
1062 ZeroMemory(&m_BufferProps,
sizeof(m_BufferProps));
1065 INT nRet = is_AOI(m_hCamera, IS_AOI_IMAGE_GET_AOI, (
void*)&rectAOI,
sizeof(rectAOI));
1067 if (nRet == IS_SUCCESS) {
1068 width = rectAOI.s32Width;
1069 height = rectAOI.s32Height;
1072 int colormode = is_SetColorMode(m_hCamera, IS_GET_COLOR_MODE);
1074 if(colormode == IS_CM_BGR5_PACKED) {
1075 is_SetColorMode(m_hCamera, IS_CM_BGR565_PACKED);
1076 colormode = IS_CM_BGR565_PACKED;
1077 std::cout <<
"uEye color format 'IS_CM_BGR5_PACKED' actually not supported by vpUeyeGrabber, patched to 'IS_CM_BGR565_PACKED'" << std::endl;
1081 ZeroMemory (&m_BufferProps,
sizeof(m_BufferProps));
1082 m_BufferProps.width = width;
1083 m_BufferProps.height = height;
1084 m_BufferProps.bitspp = getBitsPerPixel(colormode);
1090 std::cout <<
"Capture ready set up." << std::endl;
1096 void setVerbose(
bool verbose)
1098 m_verbose = verbose;
1105 INT m_nBitsPerPixel;
1106 int m_activeCameraSelected;
1107 SENSORINFO m_SensorInfo;
1109 UEYE_CAMERA_INFO m_CamListInfo;
1110 char *m_pLastBuffer;
1111 CameraList *m_cameraList;
1112 struct sBufferProps m_BufferProps;
1113 struct sCameraProps m_CameraProps;
1114 UEYE_IMAGE m_Images[IMAGE_COUNT];
1116 bool m_bLiveStarted;
1125 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 1137 : m_impl(new vpUeyeGrabberImpl())
1173 m_impl->acquire(I, timestamp_camera, timestamp_system);
1198 m_impl->acquire(I, timestamp_camera, timestamp_system);
1208 return m_impl->getActiveCameraModel();
1218 return m_impl->getActiveCameraSerialNumber();
1230 return m_impl->getCameraIDList();
1242 return m_impl->getCameraModelList();
1254 return m_impl->getCameraSerialNumberList();
1265 return m_impl->getFramerate();
1277 return m_impl->getFrameHeight();
1289 return m_impl->getFrameWidth();
1298 return m_impl->isConnected();
1308 m_impl->loadParameters(filename);
1336 return (m_impl->setActiveCamera(cam_index) ?
false :
true);
1356 return (m_impl->setColorMode(color_mode) ?
false :
true);
1374 return (m_impl->setExposure(auto_exposure, exposure_ms) ?
false :
true);
1409 return (m_impl->setFrameRate(auto_frame_rate, manual_frame_rate_hz) ?
false :
true);
1430 return (m_impl->setGain(auto_gain, master_gain, gain_boost) ?
false :
true);
1445 m_impl->setSubsampling(factor);
1460 m_impl->setWhiteBalance(auto_wb);
1470 m_impl->setVerbose(verbose);
1473 #elif !defined(VISP_BUILD_SHARED_LIBS) 1475 void dummy_vpUeyeGrabber(){};
static void BGRToRGBa(unsigned char *bgr, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
void loadParameters(const std::string &filename)
void setWhiteBalance(bool auto_wb)
unsigned int getFrameWidth() const
void open(vpImage< unsigned char > &I)
void setSubsampling(int factor)
bool setFrameRate(bool auto_frame_rate, double manual_frame_rate_hz=-1)
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
std::vector< std::string > getCameraSerialNumberList() const
Type * bitmap
points toward the bitmap
VISP_EXPORT double measureTimeSecond()
static void BGRaToRGBa(unsigned char *bgra, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
unsigned int getFrameHeight() const
error that can be emited by ViSP classes.
bool setColorMode(const std::string &color_mode)
bool setGain(bool auto_gain, int master_gain=-1, bool gain_boost=false)
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)
std::vector< std::string > getCameraModelList() const
std::string getActiveCameraModel() const
bool setActiveCamera(unsigned int cam_index)
std::string getActiveCameraSerialNumber() const
void setVerbose(bool verbose)
static void RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsigned int width, unsigned int height, unsigned int nThreads=0)
void acquire(vpImage< unsigned char > &I, double *timestamp_camera=NULL, std::string *timestamp_system=NULL)
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
std::vector< unsigned int > getCameraIDList() const
static void BGRaToGrey(unsigned char *bgra, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false, unsigned int nThreads=0)
bool setExposure(bool auto_exposure, double exposure_ms=-1)
double getFramerate() const