59 UEyeCamDriver::UEyeCamDriver(
int cam_ID,
string cam_name):
67 cam_subsampling_rate_(1),
69 cam_sensor_scaling_rate_(1),
70 color_mode_(IS_CM_MONO8),
85 INT is_err = IS_SUCCESS;
92 if (new_cam_ID >= 0) {
97 if ((is_err = is_GetNumberOfCameras(&numCameras)) != IS_SUCCESS) {
98 ERROR_STREAM(
"Failed query for number of connected UEye cameras (" <<
101 }
else if (numCameras < 1) {
103 ERROR_STREAM(
"Hint: make sure that the IDS camera daemon (/etc/init.d/ueyeusbdrc) is running\n");
104 return IS_NO_SUCCESS;
110 if ((is_err = is_InitCamera(&
cam_handle_,
nullptr)) == IS_STARTER_FW_UPLOAD_NEEDED) {
111 INT uploadTimeMSEC = 25000;
112 is_GetDuration (
cam_handle_, IS_STARTER_FW_UPLOAD, &uploadTimeMSEC);
115 <<
"]; please wait for about " << uploadTimeMSEC/1000.0 <<
" seconds");
121 if (is_err != IS_SUCCESS) {
123 " (" <<
err2str(is_err) <<
")");
128 is_err = is_SetDisplayMode(
cam_handle_, IS_SET_DM_DIB);
129 if (is_err != IS_SUCCESS) {
131 " does not support Device Independent Bitmap mode;" <<
132 " driver wrapper not compatible with OpenGL/DirectX modes (" <<
err2str(is_err) <<
")");
138 if (is_err != IS_SUCCESS) {
140 "] (" <<
err2str(is_err) <<
")");
155 INT is_err = IS_SUCCESS;
178 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
180 INT is_err = IS_SUCCESS;
183 const wstring filenameU(filename.begin(), filename.end());
184 if ((is_err = is_ParameterSet(
cam_handle_, IS_PARAMETERSET_CMD_LOAD_FILE,
185 (
void*) filenameU.c_str(), 0)) != IS_SUCCESS) {
187 <<
"]'s sensor parameters file " << filename <<
" (" <<
err2str(is_err) <<
")");
188 if (ignore_load_failure) is_err = IS_SUCCESS;
205 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
207 INT is_err = IS_SUCCESS;
216 <<
"] to " << mode <<
" (not supported by this wrapper). " 217 <<
"switching to default mode: mono8");
223 "] to " << mode <<
" (" <<
err2str(is_err) <<
": " <<
color_mode_ <<
" / '" << mode <<
"'). switching to default mode: mono8");
229 "] to " << mode <<
" (" <<
err2str(is_err) <<
": " <<
color_mode_ <<
"/ " << mode <<
")");
242 INT& image_left, INT& image_top,
bool reallocate_buffer) {
243 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
245 INT is_err = IS_SUCCESS;
250 if (image_left >= 0 && static_cast<int>(
cam_sensor_info_.nMaxWidth) - image_width - image_left < 0) {
252 image_left <<
" with a frame width of " <<
253 image_width <<
" and sensor max width of " <<
257 if (image_top >= 0 &&
258 static_cast<int>(
cam_sensor_info_.nMaxHeight) - image_height - image_top < 0) {
260 image_top <<
" with a frame height of " <<
261 image_height <<
" and sensor max height of " <<
266 (
cam_sensor_info_.nMaxWidth - static_cast<unsigned int>(image_width)) / 2 : image_left;
268 (
cam_sensor_info_.nMaxHeight - static_cast<unsigned int>(image_height)) / 2 : image_top;
279 ERROR_STREAM(
"Failed to set Area Of Interest (AOI) to " <<
280 image_width <<
" x " << image_height <<
287 image_width <<
" x " << image_height <<
296 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
298 INT is_err = IS_SUCCESS;
306 supportedRates = is_SetSubSampling(
cam_handle_, IS_GET_SUPPORTED_SUBSAMPLING);
309 rate_flag = IS_SUBSAMPLING_DISABLE;
325 rate <<
", resetting to 1X");
327 rate_flag = IS_SUBSAMPLING_DISABLE;
331 if ((supportedRates & rate_flag) == rate_flag) {
332 if ((is_err = is_SetSubSampling(
cam_handle_, rate_flag)) != IS_SUCCESS) {
341 INT currRate = is_SetSubSampling(
cam_handle_, IS_GET_SUBSAMPLING);
342 if (currRate == IS_SUBSAMPLING_DISABLE) { rate = 1; }
349 currRate <<
"), resetting to 1X");
350 if ((is_err = is_SetSubSampling(
cam_handle_, IS_SUBSAMPLING_DISABLE)) != IS_SUCCESS) {
368 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
370 INT is_err = IS_SUCCESS;
378 supportedRates = is_SetBinning(
cam_handle_, IS_GET_SUPPORTED_BINNING);
381 rate_flag = IS_BINNING_DISABLE;
397 rate <<
", resetting to 1X");
399 rate_flag = IS_BINNING_DISABLE;
403 if ((supportedRates & rate_flag) == rate_flag) {
404 if ((is_err = is_SetBinning(
cam_handle_, rate_flag)) != IS_SUCCESS) {
406 rate <<
"X (" <<
err2str(is_err) <<
")");
413 INT currRate = is_SetBinning(
cam_handle_, IS_GET_BINNING);
414 if (currRate == IS_BINNING_DISABLE) { rate = 1; }
421 currRate <<
"), resetting to 1X");
422 if ((is_err = is_SetBinning(
cam_handle_, IS_BINNING_DISABLE)) != IS_SUCCESS) {
440 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
442 INT is_err = IS_SUCCESS;
447 SENSORSCALERINFO sensorScalerInfo;
448 is_err = is_GetSensorScalerInfo(
cam_handle_, &sensorScalerInfo,
sizeof(sensorScalerInfo));
449 if (is_err == IS_NOT_SUPPORTED) {
454 }
else if (is_err != IS_SUCCESS) {
455 ERROR_STREAM(
"Failed to obtain supported internal image scaling information for [" <<
461 if (rate < sensorScalerInfo.dblMinFactor || rate > sensorScalerInfo.dblMaxFactor) {
462 WARN_STREAM(
"Requested internal image scaling rate of " << rate <<
463 " is not within supported bounds for [" <<
cam_name_ <<
"]: " <<
464 sensorScalerInfo.dblMinFactor <<
", " << sensorScalerInfo.dblMaxFactor <<
465 "; not updating current rate of " << sensorScalerInfo.dblCurrFactor);
466 rate = sensorScalerInfo.dblCurrFactor;
471 if ((is_err = is_SetSensorScaler(
cam_handle_, IS_ENABLE_SENSOR_SCALER, rate)) != IS_SUCCESS) {
473 "] to " << rate <<
"X (" <<
err2str(is_err) <<
"); resetting to 1X");
475 if ((is_err = is_SetSensorScaler(
cam_handle_, IS_ENABLE_SENSOR_SCALER, rate)) != IS_SUCCESS) {
477 "] to 1X (" <<
err2str(is_err) <<
")");
491 INT& green_gain_prc, INT& blue_gain_prc,
bool& gain_boost) {
492 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
494 INT is_err = IS_SUCCESS;
497 CAP(master_gain_prc, 0, 100);
498 CAP(red_gain_prc, 0, 100);
499 CAP(green_gain_prc, 0, 100);
500 CAP(blue_gain_prc, 0, 100);
502 double pval1 = 0, pval2 = 0;
507 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_GAIN,
508 &pval1, &pval2)) != IS_SUCCESS) {
509 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_GAIN,
510 &pval1, &pval2)) != IS_SUCCESS) {
517 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_GAIN,
518 &pval1, &pval2)) != IS_SUCCESS) {
519 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_GAIN,
520 &pval1, &pval2)) != IS_SUCCESS) {
526 if (is_SetGainBoost(
cam_handle_, IS_GET_SUPPORTED_GAINBOOST) != IS_SET_GAINBOOST_ON) {
530 (gain_boost) ? IS_SET_GAINBOOST_ON : IS_SET_GAINBOOST_OFF))
532 WARN_STREAM(
"Failed to " << ((gain_boost) ?
"enable" :
"disable") <<
538 if ((is_err = is_SetHardwareGain(
cam_handle_, master_gain_prc,
539 red_gain_prc, green_gain_prc, blue_gain_prc)) != IS_SUCCESS) {
540 WARN_STREAM(
"Failed to set manual gains (master: " << master_gain_prc <<
541 "; red: " << red_gain_prc <<
"; green: " << green_gain_prc <<
542 "; blue: " << blue_gain_prc <<
") for [" <<
cam_name_ <<
"] (" <<
551 "\n master gain: " << master_gain_prc <<
552 "\n red gain: " << red_gain_prc <<
553 "\n green gain: " << green_gain_prc <<
554 "\n blue gain: " << blue_gain_prc <<
555 "\n gain boost: " << gain_boost);
563 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
565 INT is_err = IS_SUCCESS;
572 WARN_STREAM(
"Software gamma only possible when the color mode is debayered, " <<
573 "could not set software gamma for [" <<
cam_name_ <<
"]");
574 return IS_NO_SUCCESS;
578 if ((is_err = is_Gamma(
cam_handle_, IS_GAMMA_CMD_SET, (
void*) &software_gamma,
sizeof(software_gamma))) != IS_SUCCESS) {
580 "] (" <<
err2str(is_err) <<
")");
588 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
590 INT is_err = IS_SUCCESS;
592 double minExposure, maxExposure;
595 double pval1 = auto_exposure, pval2 = 0;
596 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_SHUTTER,
597 &pval1, &pval2)) != IS_SUCCESS) {
598 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_SHUTTER,
599 &pval1, &pval2)) != IS_SUCCESS) {
601 "] (" <<
err2str(is_err) <<
")");
602 auto_exposure =
false;
607 if ((is_err = is_SetAutoParameter (
cam_handle_, IS_SET_AUTO_REFERENCE,
608 &auto_exposure_reference, 0)) != IS_SUCCESS) {
610 "] (" <<
err2str(is_err) <<
")");
614 if (!auto_exposure) {
616 if (((is_err = is_Exposure(
cam_handle_, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MIN,
617 (
void*) &minExposure,
sizeof(minExposure))) != IS_SUCCESS) ||
618 ((is_err = is_Exposure(
cam_handle_, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MAX,
619 (
void*) &maxExposure,
sizeof(maxExposure))) != IS_SUCCESS)) {
623 CAP(exposure_ms, minExposure, maxExposure);
626 if ((is_err = is_Exposure(
cam_handle_, IS_EXPOSURE_CMD_SET_EXPOSURE,
627 (
void*) &(exposure_ms),
sizeof(exposure_ms))) != IS_SUCCESS) {
628 ERROR_STREAM(
"Failed to set exposure to " << exposure_ms <<
634 DEBUG_STREAM(
"Updated exposure: " << ((auto_exposure) ?
"auto" : to_string(exposure_ms)) <<
643 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
645 INT is_err = IS_SUCCESS;
647 CAP(red_offset, -50, 50);
648 CAP(blue_offset, -50, 50);
651 double pval1 = auto_white_balance, pval2 = 0;
653 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_WHITEBALANCE,
654 &pval1, &pval2)) != IS_SUCCESS) {
655 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_AUTO_WB_ONCE,
656 &pval1, &pval2)) != IS_SUCCESS) {
658 "] (" <<
err2str(is_err) <<
")");
659 auto_white_balance =
false;
662 if (auto_white_balance) {
665 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_AUTO_WB_OFFSET,
666 &pval1, &pval2)) != IS_SUCCESS) {
667 WARN_STREAM(
"Failed to set white balance red/blue offsets to " <<
668 red_offset <<
" / " << blue_offset <<
674 ((auto_white_balance) ?
"auto" :
"manual") <<
675 "\n red offset: " << red_offset <<
676 "\n blue offset: " << blue_offset);
683 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
685 INT is_err = IS_SUCCESS;
687 double pval1 = 0, pval2 = 0;
688 double minFrameTime, maxFrameTime, intervalFrameTime, newFrameRate;
691 bool autoShutterOn =
false;
692 is_SetAutoParameter(
cam_handle_, IS_GET_ENABLE_AUTO_SENSOR_SHUTTER, &pval1, &pval2);
693 autoShutterOn |= (pval1 != 0);
694 is_SetAutoParameter(
cam_handle_, IS_GET_ENABLE_AUTO_SHUTTER, &pval1, &pval2);
695 autoShutterOn |= (pval1 != 0);
696 if (!autoShutterOn) {
697 auto_frame_rate =
false;
701 pval1 = auto_frame_rate;
702 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_FRAMERATE,
703 &pval1, &pval2)) != IS_SUCCESS) {
704 if ((is_err = is_SetAutoParameter(
cam_handle_, IS_SET_ENABLE_AUTO_FRAMERATE,
705 &pval1, &pval2)) != IS_SUCCESS) {
707 "] (" <<
err2str(is_err) <<
")");
708 auto_frame_rate =
false;
711 if (!auto_frame_rate) {
713 if ((is_err = is_GetFrameTimeRange(
cam_handle_, &minFrameTime,
714 &maxFrameTime, &intervalFrameTime)) != IS_SUCCESS) {
716 "] (" <<
err2str(is_err) <<
")");
719 CAP(frame_rate_hz, 1.0/maxFrameTime, 1.0/minFrameTime);
722 if ((is_err = is_SetFrameRate(
cam_handle_, frame_rate_hz, &newFrameRate)) != IS_SUCCESS) {
723 ERROR_STREAM(
"Failed to set frame rate to " << frame_rate_hz <<
726 }
else if (frame_rate_hz != newFrameRate) {
727 frame_rate_hz = newFrameRate;
732 ((auto_frame_rate) ?
"auto" : to_string(frame_rate_hz)) <<
" Hz");
739 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
741 INT is_err = IS_SUCCESS;
743 UINT pixelClockList[150];
744 UINT numberOfSupportedPixelClocks = 0;
745 if ((is_err = is_PixelClock(
cam_handle_, IS_PIXELCLOCK_CMD_GET_NUMBER,
746 (
void*) &numberOfSupportedPixelClocks,
sizeof(numberOfSupportedPixelClocks))) != IS_SUCCESS) {
748 "] (" <<
err2str(is_err) <<
")");
751 if(numberOfSupportedPixelClocks > 0) {
752 ZeroMemory(pixelClockList,
sizeof(pixelClockList));
753 if((is_err = is_PixelClock(
cam_handle_, IS_PIXELCLOCK_CMD_GET_LIST,
754 (
void*) pixelClockList, numberOfSupportedPixelClocks *
sizeof(
int))) != IS_SUCCESS) {
756 "] (" <<
err2str(is_err) <<
")");
760 int minPixelClock =
static_cast<int>(pixelClockList[0]);
761 int maxPixelClock =
static_cast<int>(pixelClockList[numberOfSupportedPixelClocks-1]);
762 CAP(clock_rate_mhz, minPixelClock, maxPixelClock);
765 for(UINT i = 0; i < numberOfSupportedPixelClocks; i++) {
766 if(clock_rate_mhz <= static_cast<int>(pixelClockList[i])) {
767 clock_rate_mhz =
static_cast<INT
>(pixelClockList[i]);
772 if ((is_err = is_PixelClock(
cam_handle_, IS_PIXELCLOCK_CMD_SET,
773 (
void*) &(clock_rate_mhz),
sizeof(clock_rate_mhz))) != IS_SUCCESS) {
774 ERROR_STREAM(
"Failed to set pixel clock to " << clock_rate_mhz <<
786 INT is_err = IS_SUCCESS;
789 IO_FLASH_PARAMS minFlashParams, maxFlashParams, newFlashParams;
790 if ((is_err = is_IO(
cam_handle_, IS_IO_CMD_FLASH_GET_PARAMS_MIN,
791 (
void*) &minFlashParams,
sizeof(IO_FLASH_PARAMS))) != IS_SUCCESS) {
793 "] (" <<
err2str(is_err) <<
")");
796 if ((is_err = is_IO(
cam_handle_, IS_IO_CMD_FLASH_GET_PARAMS_MAX,
797 (
void*) &maxFlashParams,
sizeof(IO_FLASH_PARAMS))) != IS_SUCCESS) {
799 "] (" <<
err2str(is_err) <<
")");
802 delay_us = (delay_us < minFlashParams.s32Delay) ? minFlashParams.s32Delay :
803 ((delay_us > maxFlashParams.s32Delay) ? maxFlashParams.s32Delay : delay_us);
804 duration_us = (duration_us < minFlashParams.u32Duration && duration_us != 0) ? minFlashParams.u32Duration :
805 ((duration_us > maxFlashParams.u32Duration) ? maxFlashParams.u32Duration : duration_us);
806 newFlashParams.s32Delay = delay_us;
807 newFlashParams.u32Duration = duration_us;
813 if ((is_err = is_IO(
cam_handle_, IS_IO_CMD_FLASH_SET_PARAMS,
814 (
void*) &newFlashParams,
sizeof(IO_FLASH_PARAMS))) != IS_SUCCESS) {
816 "] (" <<
err2str(is_err) <<
")");
826 INT is_err = IS_SUCCESS;
827 IO_GPIO_CONFIGURATION gpioConfiguration;
828 gpioConfiguration.u32State = 0;
829 IO_PWM_PARAMS m_pwmParams;
832 gpioConfiguration.u32Gpio = IO_GPIO_1;
834 gpioConfiguration.u32Gpio = IO_GPIO_2;
837 case 0: gpioConfiguration.u32Configuration = IS_GPIO_INPUT;
break;
838 case 1: gpioConfiguration.u32Configuration = IS_GPIO_OUTPUT;
break;
840 gpioConfiguration.u32Configuration = IS_GPIO_OUTPUT;
841 gpioConfiguration.u32State = 1;
843 case 3: gpioConfiguration.u32Configuration = IS_GPIO_FLASH;
break;
845 gpioConfiguration.u32Configuration = IS_GPIO_PWM;
846 m_pwmParams.dblFrequency_Hz = pwm_freq;
847 m_pwmParams.dblDutyCycle = pwm_duty_cycle;
849 case 5: gpioConfiguration.u32Configuration = IS_GPIO_TRIGGER;
break;
853 if ((is_err = is_IO(
cam_handle_, IS_IO_CMD_GPIOS_SET_CONFIGURATION, (
void*)&gpioConfiguration,
sizeof(gpioConfiguration))) != IS_SUCCESS) {
854 ERROR_STREAM(
"Tried to set GPIO: " << gpioConfiguration.u32Gpio <<
" and got error code: " << is_err);
858 if ((is_err == IS_SUCCESS) && (mode == 4)) {
859 if ((is_err = is_IO(
cam_handle_, IS_IO_CMD_PWM_SET_PARAMS, (
void*)&m_pwmParams,
sizeof(m_pwmParams))) != IS_SUCCESS) {
860 ERROR_STREAM(
"Tried to set PWM to: " << m_pwmParams.dblFrequency_Hz <<
" hz and " << m_pwmParams.dblDutyCycle <<
861 " % and got error code: " << is_err);
870 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
872 INT is_err = IS_SUCCESS;
879 UINT flash_duration = 1000;
881 UINT nMode = IO_FLASH_MODE_FREERUN_HI_ACTIVE;
882 if ((is_err = is_IO(
cam_handle_, IS_IO_CMD_FLASH_SET_MODE,
883 (
void*) &nMode,
sizeof(nMode))) != IS_SUCCESS) {
885 "] (" <<
err2str(is_err) <<
")");
886 WARN_STREAM(
"WARNING: camera hardware does not support ueye_cam's master-slave synchronization method");
888 IS_INIT_EVENT init_events[] = {{IS_SET_EVENT_FRAME, FALSE, FALSE}};
889 if ((is_err = is_Event(
cam_handle_, IS_EVENT_CMD_INIT, init_events,
sizeof(init_events))) != IS_SUCCESS) {
891 "] (" <<
err2str(is_err) <<
")");
894 UINT events[] = {IS_SET_EVENT_FRAME};
895 if ((is_err = is_Event(
cam_handle_,IS_EVENT_CMD_ENABLE, events,
sizeof(events))) != IS_SUCCESS) {
897 "] (" <<
err2str(is_err) <<
")");
900 if ((is_err = is_CaptureVideo(
cam_handle_, IS_WAIT)) != IS_SUCCESS) {
902 "] (" <<
err2str(is_err) <<
")");
913 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
915 INT is_err = IS_SUCCESS;
920 IS_INIT_EVENT init_events[] = {{IS_SET_EVENT_FRAME, FALSE, FALSE}};
921 if ((is_err = is_Event(
cam_handle_, IS_EVENT_CMD_INIT, init_events,
sizeof(init_events))) != IS_SUCCESS) {
923 "] (" <<
err2str(is_err) <<
")");
926 UINT events[] = {IS_SET_EVENT_FRAME};
927 if ((is_err = is_Event(
cam_handle_,IS_EVENT_CMD_ENABLE, events,
sizeof(events))) != IS_SUCCESS) {
929 "] (" <<
err2str(is_err) <<
")");
933 if ((is_err = is_SetExternalTrigger(
cam_handle_, IS_SET_TRIGGER_HI_LO)) != IS_SUCCESS) {
934 ERROR_STREAM(
"Could not enable falling-edge external trigger mode for [" <<
938 if ((is_err = is_CaptureVideo(
cam_handle_, IS_DONT_WAIT)) != IS_SUCCESS) {
939 ERROR_STREAM(
"Could not start external trigger live video mode for [" <<
943 DEBUG_STREAM(
"Started falling-edge external trigger live video mode for [" <<
952 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
954 INT is_err = IS_SUCCESS;
956 is_err = is_SetRopEffect(
cam_handle_,IS_SET_ROP_MIRROR_UPDOWN,1,0);
958 is_err = is_SetRopEffect(
cam_handle_,IS_SET_ROP_MIRROR_UPDOWN,0,0);
965 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
967 INT is_err = IS_SUCCESS;
969 is_err = is_SetRopEffect(
cam_handle_,IS_SET_ROP_MIRROR_LEFTRIGHT,1,0);
971 is_err = is_SetRopEffect(
cam_handle_,IS_SET_ROP_MIRROR_LEFTRIGHT,0,0);
978 if (!
isConnected())
return IS_INVALID_CAMERA_HANDLE;
980 INT is_err = IS_SUCCESS;
982 UINT events[] = {IS_SET_EVENT_FRAME};
985 if ((is_err = is_Event(
cam_handle_,IS_EVENT_CMD_DISABLE, events,
sizeof(events))) != IS_SUCCESS) {
987 "] (" <<
err2str(is_err) <<
")");
990 if ((is_err = is_Event(
cam_handle_,IS_EVENT_CMD_EXIT, events,
sizeof(events))) != IS_SUCCESS) {
992 "] (" <<
err2str(is_err) <<
")");
995 if ((is_err = is_SetExternalTrigger(
cam_handle_, IS_SET_TRIGGER_OFF)) != IS_SUCCESS) {
997 "] (" <<
err2str(is_err) <<
")");
1000 is_SetExternalTrigger(
cam_handle_, IS_GET_TRIGGER_STATUS);
1001 if ((is_err = is_StopLiveVideo(
cam_handle_, IS_WAIT)) != IS_SUCCESS) {
1003 "] (" <<
err2str(is_err) <<
")");
1008 UINT nMode = IO_FLASH_MODE_OFF;
1009 if ((is_err = is_IO(
cam_handle_, IS_IO_CMD_FLASH_SET_MODE,
1010 (
void*) &nMode,
sizeof(nMode))) != IS_SUCCESS) {
1012 "] (" <<
err2str(is_err) <<
")");
1015 if ((is_err = is_Event(
cam_handle_,IS_EVENT_CMD_DISABLE, events,
sizeof(events))) != IS_SUCCESS) {
1017 "] (" <<
err2str(is_err) <<
")");
1020 if ((is_err = is_Event(
cam_handle_,IS_EVENT_CMD_EXIT, events,
sizeof(events))) != IS_SUCCESS) {
1022 "] (" <<
err2str(is_err) <<
")");
1025 if ((is_err = is_StopLiveVideo(
cam_handle_, IS_WAIT)) != IS_SUCCESS) {
1027 "] (" <<
err2str(is_err) <<
")");
1032 if ((is_err = static_cast<int>(is_CameraStatus(
cam_handle_, IS_STANDBY, IS_GET_STATUS))) != IS_SUCCESS) {
1034 "] (" <<
err2str(is_err) <<
")");
1045 INT is_err = IS_SUCCESS;
1048 UINT events[] = {IS_SET_EVENT_FRAME};
1049 IS_WAIT_EVENTS wait_events = {events, 1, FALSE, timeout_ms, 0, 0};
1050 if ((is_err = is_Event(
cam_handle_, IS_EVENT_CMD_WAIT, &wait_events,
sizeof(wait_events))) != IS_SUCCESS) {
1051 if (is_err == IS_TIMED_OUT) {
1053 "] (" <<
err2str(is_err) <<
")");
1054 ERROR_STREAM(
"If this is occurring frequently, see https://github.com/anqixu/ueye_cam/issues/6#issuecomment-49925549");
1058 "] (" <<
err2str(is_err) <<
")");
1068 INT is_err = IS_SUCCESS;
1071 if ((is_err = is_AOI(
cam_handle_, IS_AOI_IMAGE_GET_AOI,
1073 ERROR_STREAM(
"Could not retrieve Area Of Interest (AOI) information from [" <<
1080 <<
") for [" <<
cam_name_ <<
"] is not supported by this wrapper; " 1082 <<
"switching to default mode: " << dft_mode_str);
1083 if ((is_err =
setColorMode(dft_mode_str,
false)) != IS_SUCCESS)
return is_err;
1089 SENSORSCALERINFO sensorScalerInfo;
1090 is_err = is_GetSensorScalerInfo(
cam_handle_, &sensorScalerInfo,
sizeof(sensorScalerInfo));
1091 if (is_err == IS_NOT_SUPPORTED) {
1093 }
else if (is_err != IS_SUCCESS) {
1094 ERROR_STREAM(
"Could not obtain supported internal image scaling information for [" <<
1102 const INT currSubsamplingRate = is_SetSubSampling(
cam_handle_, IS_GET_SUBSAMPLING);
1103 switch (currSubsamplingRate) {
1110 WARN_STREAM(
"Current sampling rate (IDS setting: " << currSubsamplingRate
1111 <<
") for [" <<
cam_name_ <<
"] is not supported by this wrapper; resetting to 1X");
1112 if ((is_err = is_SetSubSampling(
cam_handle_, IS_SUBSAMPLING_DISABLE)) != IS_SUCCESS) {
1114 <<
"] to 1X (" <<
err2str(is_err) <<
")");
1121 const INT currBinningRate = is_SetBinning(
cam_handle_, IS_GET_BINNING);
1122 switch (currBinningRate) {
1129 WARN_STREAM(
"Current binning rate (IDS setting: " << currBinningRate
1130 <<
") for [" <<
cam_name_ <<
"] is not supported by this wrapper; resetting to 1X");
1131 if ((is_err = is_SetBinning(
cam_handle_, IS_BINNING_DISABLE)) != IS_SUCCESS) {
1133 <<
"] to 1X (" <<
err2str(is_err) <<
")");
1141 "] and ensured compatibility with driver wrapper:" <<
1142 "\n AOI width: " <<
cam_aoi_.s32Width <<
1143 "\n AOI height: " <<
cam_aoi_.s32Height <<
1144 "\n AOI top-left X: " <<
cam_aoi_.s32X <<
1145 "\n AOI top-left Y: " <<
cam_aoi_.s32Y <<
1158 INT is_err = IS_SUCCESS;
1170 if ((is_err = is_AOI(
cam_handle_, IS_AOI_IMAGE_GET_AOI,
1172 ERROR_STREAM(
"Could not retrieve Area Of Interest (AOI) information for [" <<
1181 " image buffer for [" <<
cam_name_ <<
"]");
1187 ERROR_STREAM(
"Failed to associate image buffer to IDS driver for [" <<
1196 ERROR_STREAM(
"Failed to query buffer step size / pitch / stride for [" <<
1203 "]\n(THIS IS A CODING ERROR, PLEASE CONTACT PACKAGE AUTHOR)");
1209 "\n buffer width: " <<
cam_aoi_.s32Width <<
1210 "\n buffer height: " <<
cam_aoi_.s32Height <<
1220 #define CASE(s) case s: return #s; break 1222 CASE(IS_NO_SUCCESS);
1224 CASE(IS_INVALID_CAMERA_HANDLE);
1225 CASE(IS_IO_REQUEST_FAILED);
1226 CASE(IS_CANT_OPEN_DEVICE);
1227 CASE(IS_CANT_OPEN_REGISTRY);
1228 CASE(IS_CANT_READ_REGISTRY);
1229 CASE(IS_NO_IMAGE_MEM_ALLOCATED);
1230 CASE(IS_CANT_CLEANUP_MEMORY);
1231 CASE(IS_CANT_COMMUNICATE_WITH_DRIVER);
1232 CASE(IS_FUNCTION_NOT_SUPPORTED_YET);
1233 CASE(IS_INVALID_CAPTURE_MODE);
1234 CASE(IS_INVALID_MEMORY_POINTER);
1235 CASE(IS_FILE_WRITE_OPEN_ERROR);
1236 CASE(IS_FILE_READ_OPEN_ERROR);
1237 CASE(IS_FILE_READ_INVALID_BMP_ID);
1238 CASE(IS_FILE_READ_INVALID_BMP_SIZE);
1239 CASE(IS_NO_ACTIVE_IMG_MEM);
1240 CASE(IS_SEQUENCE_LIST_EMPTY);
1241 CASE(IS_CANT_ADD_TO_SEQUENCE);
1242 CASE(IS_SEQUENCE_BUF_ALREADY_LOCKED);
1243 CASE(IS_INVALID_DEVICE_ID);
1244 CASE(IS_INVALID_BOARD_ID);
1245 CASE(IS_ALL_DEVICES_BUSY);
1247 CASE(IS_NULL_POINTER);
1248 CASE(IS_INVALID_PARAMETER);
1249 CASE(IS_OUT_OF_MEMORY);
1250 CASE(IS_ACCESS_VIOLATION);
1252 CASE(IS_CAPTURE_RUNNING);
1253 CASE(IS_IMAGE_NOT_PRESENT);
1254 CASE(IS_TRIGGER_ACTIVATED);
1256 CASE(IS_NOT_YET_RELEASED);
1257 CASE(IS_WAITING_FOR_KERNEL);
1258 CASE(IS_NOT_SUPPORTED);
1259 CASE(IS_TRIGGER_NOT_ACTIVATED);
1260 CASE(IS_OPERATION_ABORTED);
1261 CASE(IS_BAD_STRUCTURE_SIZE);
1262 CASE(IS_INVALID_BUFFER_SIZE);
1263 CASE(IS_INVALID_PIXEL_CLOCK);
1264 CASE(IS_INVALID_EXPOSURE_TIME);
1265 CASE(IS_AUTO_EXPOSURE_RUNNING);
1266 CASE(IS_CANNOT_CREATE_BB_SURF);
1267 CASE(IS_CANNOT_CREATE_BB_MIX);
1268 CASE(IS_BB_OVLMEM_NULL);
1269 CASE(IS_CANNOT_CREATE_BB_OVL);
1270 CASE(IS_NOT_SUPP_IN_OVL_SURF_MODE);
1271 CASE(IS_INVALID_SURFACE);
1272 CASE(IS_SURFACE_LOST);
1273 CASE(IS_RELEASE_BB_OVL_DC);
1274 CASE(IS_BB_TIMER_NOT_CREATED);
1275 CASE(IS_BB_OVL_NOT_EN);
1276 CASE(IS_ONLY_IN_BB_MODE);
1277 CASE(IS_INVALID_COLOR_FORMAT);
1278 CASE(IS_INVALID_WB_BINNING_MODE);
1279 CASE(IS_INVALID_I2C_DEVICE_ADDRESS);
1280 CASE(IS_COULD_NOT_CONVERT);
1281 CASE(IS_TRANSFER_ERROR);
1282 CASE(IS_PARAMETER_SET_NOT_PRESENT);
1283 CASE(IS_INVALID_CAMERA_TYPE);
1284 CASE(IS_INVALID_HOST_IP_HIBYTE);
1285 CASE(IS_CM_NOT_SUPP_IN_CURR_DISPLAYMODE);
1286 CASE(IS_NO_IR_FILTER);
1287 CASE(IS_STARTER_FW_UPLOAD_NEEDED);
1288 CASE(IS_DR_LIBRARY_NOT_FOUND);
1289 CASE(IS_DR_DEVICE_OUT_OF_MEMORY);
1290 CASE(IS_DR_CANNOT_CREATE_SURFACE);
1291 CASE(IS_DR_CANNOT_CREATE_VERTEX_BUFFER);
1292 CASE(IS_DR_CANNOT_CREATE_TEXTURE);
1293 CASE(IS_DR_CANNOT_LOCK_OVERLAY_SURFACE);
1294 CASE(IS_DR_CANNOT_UNLOCK_OVERLAY_SURFACE);
1295 CASE(IS_DR_CANNOT_GET_OVERLAY_DC);
1296 CASE(IS_DR_CANNOT_RELEASE_OVERLAY_DC);
1297 CASE(IS_DR_DEVICE_CAPS_INSUFFICIENT);
1298 CASE(IS_INCOMPATIBLE_SETTING);
1299 CASE(IS_DR_NOT_ALLOWED_WHILE_DC_IS_ACTIVE);
1300 CASE(IS_DEVICE_ALREADY_PAIRED);
1301 CASE(IS_SUBNETMASK_MISMATCH);
1302 CASE(IS_SUBNET_MISMATCH);
1303 CASE(IS_INVALID_IP_CONFIGURATION);
1304 CASE(IS_DEVICE_NOT_COMPATIBLE);
1305 CASE(IS_NETWORK_FRAME_SIZE_INCOMPATIBLE);
1306 CASE(IS_NETWORK_CONFIGURATION_INVALID);
1307 CASE(IS_ERROR_CPU_IDLE_STATES_CONFIGURATION);
1309 return "UNKNOWN ERROR";
1311 return "UNKNOWN ERROR";
1317 #define CASE(s) case s: return #s; break 1323 CASE(IS_CM_SENSOR_RAW16);
1324 CASE(IS_CM_SENSOR_RAW12);
1325 CASE(IS_CM_SENSOR_RAW10);
1326 CASE(IS_CM_SENSOR_RAW8);
1327 CASE(IS_CM_RGB12_UNPACKED);
1328 CASE(IS_CM_RGB10_UNPACKED);
1329 CASE(IS_CM_RGB10_PACKED);
1330 CASE(IS_CM_RGB8_PACKED);
1331 CASE(IS_CM_RGBA12_UNPACKED);
1332 CASE(IS_CM_RGBA8_PACKED);
1333 CASE(IS_CM_RGBY8_PACKED);
1334 CASE(IS_CM_BGR12_UNPACKED);
1335 CASE(IS_CM_BGR10_UNPACKED);
1336 CASE(IS_CM_BGR10_PACKED);
1337 CASE(IS_CM_BGR8_PACKED);
1338 CASE(IS_CM_BGRA12_UNPACKED);
1339 CASE(IS_CM_BGRA8_PACKED);
1340 CASE(IS_CM_BGRY8_PACKED);
1341 CASE(IS_CM_RGB8_PLANAR);
1342 CASE(IS_CM_BGR565_PACKED);
1343 CASE(IS_CM_BGR5_PACKED);
1344 CASE(IS_CM_UYVY_PACKED);
1345 CASE(IS_CM_CBYCRY_PACKED);
1346 CASE(IS_CM_PREFER_PACKED_SOURCE_FORMAT);
1377 return "UNKNOWN COLOR MODE";
1379 return "UNKNOWN COLOR MODE";
1386 case IS_CM_SENSOR_RAW8:
1389 case IS_CM_SENSOR_RAW10:
1390 case IS_CM_SENSOR_RAW12:
1391 case IS_CM_SENSOR_RAW16:
1395 case IS_CM_BGR5_PACKED:
1396 case IS_CM_BGR565_PACKED:
1397 case IS_CM_UYVY_PACKED:
1398 case IS_CM_UYVY_MONO_PACKED:
1399 case IS_CM_UYVY_BAYER_PACKED:
1400 case IS_CM_CBYCRY_PACKED:
1402 case IS_CM_RGB8_PACKED:
1403 case IS_CM_BGR8_PACKED:
1404 case IS_CM_RGB8_PLANAR:
1406 case IS_CM_RGBA8_PACKED:
1407 case IS_CM_BGRA8_PACKED:
1408 case IS_CM_RGBY8_PACKED:
1409 case IS_CM_BGRY8_PACKED:
1410 case IS_CM_RGB10_PACKED:
1411 case IS_CM_BGR10_PACKED:
1413 case IS_CM_RGB10_UNPACKED:
1414 case IS_CM_BGR10_UNPACKED:
1415 case IS_CM_RGB12_UNPACKED:
1416 case IS_CM_BGR12_UNPACKED:
1418 case IS_CM_RGBA12_UNPACKED:
1419 case IS_CM_BGRA12_UNPACKED:
1430 case IS_CM_SENSOR_RAW8:
1431 case IS_CM_SENSOR_RAW10:
1432 case IS_CM_SENSOR_RAW12:
1433 case IS_CM_SENSOR_RAW16:
1438 case IS_CM_RGB8_PACKED:
1439 case IS_CM_BGR8_PACKED:
1440 case IS_CM_RGB8_PLANAR:
1441 case IS_CM_RGB10_PACKED:
1442 case IS_CM_BGR10_PACKED:
1443 case IS_CM_RGB10_UNPACKED:
1444 case IS_CM_BGR10_UNPACKED:
1445 case IS_CM_RGB12_UNPACKED:
1446 case IS_CM_BGR12_UNPACKED:
1468 {
"bayer_rggb8", IS_CM_SENSOR_RAW8 },
1469 {
"bayer_rggb10", IS_CM_SENSOR_RAW10 },
1470 {
"bayer_rggb12", IS_CM_SENSOR_RAW12 },
1471 {
"bayer_rggb16", IS_CM_SENSOR_RAW16 },
1472 {
"mono8", IS_CM_MONO8 },
1473 {
"mono10", IS_CM_MONO10 },
1474 {
"mono12", IS_CM_MONO12 },
1475 {
"mono16", IS_CM_MONO16 },
1476 {
"rgb8", IS_CM_RGB8_PACKED },
1477 {
"bgr8", IS_CM_BGR8_PACKED },
1478 {
"rgb10", IS_CM_RGB10_PACKED },
1479 {
"bgr10", IS_CM_BGR10_PACKED },
1480 {
"rgb10u", IS_CM_RGB10_UNPACKED },
1481 {
"bgr10u", IS_CM_BGR10_UNPACKED },
1482 {
"rgb12u", IS_CM_RGB12_UNPACKED },
1483 {
"bgr12u", IS_CM_BGR12_UNPACKED }
1488 const std::map<std::string, INT>::const_iterator iter =
COLOR_DICTIONARY.find(name);
1490 return iter->second;
1500 if (value.second == mode) {
1504 return std::string();
1509 switch (color_mode) {
1510 case IS_CM_RGB10_PACKED:
1511 case IS_CM_BGR10_PACKED:
1513 case IS_CM_SENSOR_RAW10:
1515 case IS_CM_RGB10_UNPACKED:
1516 case IS_CM_BGR10_UNPACKED:
1518 case IS_CM_SENSOR_RAW12:
1520 case IS_CM_RGB12_UNPACKED:
1521 case IS_CM_BGR12_UNPACKED:
1537 uint32_t* from =
static_cast<uint32_t*
>(src);
1538 uint16_t* to =
static_cast<uint16_t*
>(dst);
1540 for (
size_t i=0; i<num/4; ++i) {
1542 to[0] =
static_cast<unsigned short>(pixel);
1545 to[1] =
static_cast<unsigned short>(pixel);
1546 to[1] &= 0b1111111111000000;
1548 to[2] =
static_cast<unsigned short>(pixel);
1549 to[2] &= 0b1111111111000000;
1563 uint16_t* from =
static_cast<uint16_t*
>(src);
1564 uint16_t* to =
static_cast<uint16_t*
>(dst);
1566 for (
size_t i=0; i<num/2; ++i) {
1580 uint16_t* from =
static_cast<uint16_t*
>(src);
1581 uint16_t* to =
static_cast<uint16_t*
>(dst);
1583 for (
size_t i=0; i<num/2; ++i) {
1592 UEYEIMAGEINFO ImageInfo;
1594 *timestamp = ImageInfo.TimestampSystem;
1602 UEYEIMAGEINFO ImageInfo;
1604 *tick = ImageInfo.u64TimestampDevice;
virtual INT connectCam(int new_cam_ID=-1)
static void * unpackRGB10(void *dst, void *src, size_t num)
const char * processNextFrame(UINT timeout_ms)
INT setExposure(bool &auto_exposure, double &auto_exposure_reference, double &exposure_ms)
static const std::string colormode2name(INT mode)
static const std::function< void *(void *, void *, size_t)> getUnpackCopyFunc(INT color_mode)
INT setMirrorLeftRight(bool flip_vertical)
virtual void handleTimeout()
INT setFlashParams(INT &delay_us, UINT &duration_us)
bool getTimestamp(UEYETIME *timestamp)
SENSORINFO cam_sensor_info_
#define CAP(val, min, max)
INT setGpioMode(const INT &gpio, INT &mode, double &pwm_freq, double &pwm_duty_cycle)
INT setWhiteBalance(bool &auto_white_balance, INT &red_offset, INT &blue_offset)
bool extTriggerModeActive()
INT setColorMode(std::string &mode, bool reallocate_buffer=true)
INT setMirrorUpsideDown(bool flip_horizontal)
static bool isSupportedColorMode(INT mode)
#define IS_SUBSAMPLING_2X
#define DEBUG_STREAM(...)
INT setSensorScaling(double &rate, bool reallocate_buffer=true)
#define ERROR_STREAM(...)
INT setPixelClockRate(INT &clock_rate_mhz)
#define IS_SUBSAMPLING_4X
static INT name2colormode(const std::string &name)
static const char * err2str(INT error)
unsigned int cam_subsampling_rate_
INT setSubsampling(int &rate, bool reallocate_buffer=true)
double cam_sensor_scaling_rate_
INT setResolution(INT &image_width, INT &image_height, INT &image_left, INT &image_top, bool reallocate_buffer=true)
static const char * colormode2str(INT mode)
virtual INT syncCamConfig(std::string dft_mode_str="mono8")
virtual INT disconnectCam()
INT setBinning(int &rate, bool reallocate_buffer=true)
INT setFrameRate(bool &auto_frame_rate, double &frame_rate_hz)
unsigned int cam_binning_rate_
static INT colormode2bpp(INT mode)
static void * unpack10u(void *dst, void *src, size_t num)
unsigned int cam_buffer_size_
static void * unpack12u(void *dst, void *src, size_t num)
static const std::map< std::string, INT > COLOR_DICTIONARY
INT reallocateCamBuffer()
bool getClockTick(uint64_t *tick)
#define IS_SUBSAMPLING_8X
INT setSoftwareGamma(INT &software_gamma)
INT loadCamConfig(std::string filename, bool ignore_load_failure=true)
#define IS_SUBSAMPLING_16X
INT setGain(bool &auto_gain, INT &master_gain_prc, INT &red_gain_prc, INT &green_gain_prc, INT &blue_gain_prc, bool &gain_boost)