static int ids_core_Camera_setbinning(ids_core_Camera *self, PyObject *value, void *closure) { int ret; if (value == NULL) { ret = is_SetBinning(self->handle, IS_BINNING_DISABLE); switch (ret) { case IS_SUCCESS: return 0; break; case IS_INVALID_PARAMETER: PyErr_SetString(PyExc_ValueError, "An error occurred when disabling binning."); return -1; } } ret = is_SetBinning(self->handle, PyLong_AsLong(value)); switch (ret) { case IS_SUCCESS: return 0; break; case IS_INVALID_PARAMETER: PyErr_SetString(PyExc_ValueError, "Invalid binning configuration."); default: raise_general_error(self, ret); } return -1; }
////////////////////////////////////////////////////////////////////////////////// // 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(); }
////////////////////////////////////////////////////////////////////////////////// // setBinning -------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////////// int ofxUeye::setBinning(INT mode) { bool wasLive = bLive; if (wasLive) disableLive(); // As the binning 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_SetBinning (m_hCam, mode); if(result == IS_SUCCESS){ _binning = mode; updateDimensions(); ofLog(OF_LOG_WARNING, "ofxUeye - setBinning - (%i) Success.", mode); } else { if(bVerbose) ofLog(OF_LOG_WARNING, "ofxUeye - setBinning - Couldn't apply %i value.", mode); } if (wasLive) enableLive(); return result; }
INT UEyeCamDriver::setBinning(int& 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(); INT rate_flag; INT supportedRates; supportedRates = is_SetBinning(cam_handle_, IS_GET_SUPPORTED_BINNING); switch (rate) { case 1: rate_flag = IS_BINNING_DISABLE; break; case 2: rate_flag = IS_BINNING_2X; break; case 4: rate_flag = IS_BINNING_4X; break; case 8: rate_flag = IS_BINNING_8X; break; case 16: rate_flag = IS_BINNING_16X; break; default: std::cerr << "Invalid or unsupported binning rate: " << rate << ", resetting to 1X" << std::endl; rate = 1; rate_flag = IS_BINNING_DISABLE; break; } if ((supportedRates & rate_flag) == rate_flag) { if ((is_err = is_SetBinning(cam_handle_, rate_flag)) != IS_SUCCESS) { std::cerr << "Could not set binning rate to " << rate << "X (" << err2str(is_err) << ")" << std::endl; return is_err; } } else { std::cerr << "Camera does not support requested binning rate of " << rate << std::endl; // Query current rate INT currRate = is_SetBinning(cam_handle_, IS_GET_BINNING); if (currRate == IS_BINNING_DISABLE) { rate = 1; } else if (currRate == IS_BINNING_2X) { rate = 2; } else if (currRate == IS_BINNING_4X) { rate = 4; } else if (currRate == IS_BINNING_8X) { rate = 8; } else if (currRate == IS_BINNING_16X) { rate = 16; } else { std::cerr << "ColorCamera.has unsupported binning rate (" << currRate << "), resetting to 1X" << std::endl; if ((is_err = is_SetBinning(cam_handle_, IS_BINNING_DISABLE)) != IS_SUCCESS) { std::cerr << "Could not set binning rate to 1X (" << err2str(is_err) << ")" << std::endl; return is_err; } } return IS_SUCCESS; } std::cout << "Updated binning rate to " << rate << "X" << std::endl; cam_binning_rate_ = rate; return (reallocate_buffer ? reallocateCamBuffer() : IS_SUCCESS); }
static PyObject *ids_core_Camera_getbinning(ids_core_Camera *self, void *closure) { return PyLong_FromLong(is_SetBinning(self->handle, IS_GET_BINNING)); }