////////////////////////////////////////////////////////////////////////////////// // calculateMaxAOI --------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////////// void ofxUeye::calculateMaxAOI() { bool wasLive = bLive; if (wasLive) disableLive(); // Maximize AOI int curBinning = _binning; int curSubSampling = _subSampling; double curScaler = _scaler; is_SetBinning (m_hCam, IS_BINNING_DISABLE); is_SetSubSampling (m_hCam, IS_SUBSAMPLING_DISABLE); is_SetSensorScaler (m_hCam, IS_ENABLE_SENSOR_SCALER | IS_ENABLE_ANTI_ALIASING, 1.0); IS_RECT fullAOI; fullAOI.s32X = 0; fullAOI.s32Y = 0; fullAOI.s32Width = _sensorWidth; fullAOI.s32Height = _sensorHeight; is_AOI(m_hCam, IS_AOI_IMAGE_SET_AOI, (void*)&fullAOI, sizeof(fullAOI)); is_SetBinning (m_hCam, curBinning); is_SetSubSampling (m_hCam, curSubSampling); is_SetSensorScaler (m_hCam, IS_ENABLE_SENSOR_SCALER | IS_ENABLE_ANTI_ALIASING, curScaler); // Get the maximum AOI in the current binning, sub sampling and scaler IS_SIZE_2D maxAOI; is_AOI(m_hCam, IS_AOI_IMAGE_GET_SIZE_MAX, (void*)&maxAOI, sizeof(maxAOI)); _AOIMax.x = 0; _AOIMax.y = 0; _AOIMax.width = (float)maxAOI.s32Width; _AOIMax.height = (float)maxAOI.s32Height; if (wasLive) enableLive(); }
INT UEyeCamDriver::setSensorScaling(double& rate, bool reallocate_buffer) { if (!isConnected()) return IS_INVALID_CAMERA_HANDLE; INT is_err = IS_SUCCESS; // Stop capture to prevent access to memory buffer setStandbyMode(); SENSORSCALERINFO sensorScalerInfo; is_err = is_GetSensorScalerInfo(cam_handle_, &sensorScalerInfo, sizeof(sensorScalerInfo)); if (is_err == IS_NOT_SUPPORTED) { std::cerr << "Internal image scaling is not supported by camera" << std::endl; rate = 1.0; cam_sensor_scaling_rate_ = 1.0; return IS_SUCCESS; } else if (is_err != IS_SUCCESS) { std::cerr << "Could not obtain supported internal image scaling information (" << err2str(is_err) << ")" << std::endl; rate = 1.0; cam_sensor_scaling_rate_ = 1.0; return is_err; } else { if (rate < sensorScalerInfo.dblMinFactor || rate > sensorScalerInfo.dblMaxFactor) { std::cerr << "Requested internal image scaling rate of " << rate << " is not within supported bounds of [" << sensorScalerInfo.dblMinFactor << ", " << sensorScalerInfo.dblMaxFactor << "]; not updating current rate of " << sensorScalerInfo.dblCurrFactor << std::endl; rate = sensorScalerInfo.dblCurrFactor; return IS_SUCCESS; } } if ((is_err = is_SetSensorScaler(cam_handle_, IS_ENABLE_SENSOR_SCALER, rate)) != IS_SUCCESS) { std::cerr << "Could not set internal image scaling rate to " << rate << "X (" << err2str(is_err) << "); resetting to 1X" << std::endl; rate = 1.0; if ((is_err = is_SetSensorScaler(cam_handle_, IS_ENABLE_SENSOR_SCALER, rate)) != IS_SUCCESS) { std::cerr << "Could not set internal image scaling rate to 1X (" << err2str(is_err) << ")" << std::endl; return is_err; } } std::cout << "Updated internal image scaling rate to " << rate << "X" << std::endl; cam_sensor_scaling_rate_ = rate; return (reallocate_buffer ? reallocateCamBuffer() : IS_SUCCESS); }
////////////////////////////////////////////////////////////////////////////////// // setScaler --------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////////// int ofxUeye::setScaler(double factor) { bool wasLive = bLive; if (wasLive) disableLive(); // As the scaler change will make the camera irresponsive for a while, we need to flag as NOT ready for thread safety bReady = false; int result; result = is_SetSensorScaler (m_hCam, IS_ENABLE_SENSOR_SCALER | IS_ENABLE_ANTI_ALIASING, factor); if(result == IS_SUCCESS){ _scaler = factor; updateDimensions(); ofLog(OF_LOG_WARNING, "ofxUeye - setScaler - (%f) Success.", (float)factor); } else { if(bVerbose) ofLog(OF_LOG_WARNING, "ofxUeye - setScaler - Couldn't apply %f value.", (float)factor); } return result; }