void CameraApi::getHardwareGain(int &master, int &red, int &green, int &blue) { red = is_SetHardwareGain(mhCam, IS_GET_RED_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); green = is_SetHardwareGain(mhCam, IS_GET_GREEN_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); blue = is_SetHardwareGain(mhCam, IS_GET_BLUE_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); master = is_SetHardwareGain(mhCam, IS_GET_MASTER_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); }
static int ids_core_Camera_setgain(ids_core_Camera *self, PyObject *value, void *closure) { int ret, gain; PyObject *exception; if (value == NULL) { PyErr_SetString(PyExc_TypeError, "Cannot delete attribute 'gain'"); return -1; } gain = (int) PyLong_AsLong(value); exception = PyErr_Occurred(); if (exception) { PyErr_SetString(exception, "Gain must be an int or long"); return -1; } ret = is_SetHardwareGain(self->handle, gain, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); switch (ret) { case IS_SUCCESS: return 0; case IS_INVALID_PARAMETER: PyErr_SetString(PyExc_ValueError, "Gain out of range."); return -1; default: raise_general_error(self, ret); return -1; } return -1; }
// ------------------- OnSliderChangeRed ----------------------- // void properties::OnSliderChangeRed (int value) { if (m_bInit || !m_hCamera) return; value = (value < m_minRGBGain) ? m_minRGBGain : value; value = (value > m_maxRGBGain) ? m_maxRGBGain : value; is_SetHardwareGain (m_hCamera, IS_IGNORE_PARAMETER, value, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); UpdateRGBGainCtrls (); }
// ------------------- UpdateMasterGainCtrls ----------------------- // void properties::UpdateMasterGainCtrls () { if (m_bInit || !m_hCamera) return; QString strTemp; double dblEnable = 0.0; // get values m_maxMasterGain = IS_MAX_GAIN; m_minMasterGain = IS_MIN_GAIN; m_incMasterGain = 1; m_nMasterGain = is_SetHardwareGain (m_hCamera, IS_GET_MASTER_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); is_SetAutoParameter (m_hCamera, IS_GET_ENABLE_AUTO_GAIN, &dblEnable, NULL); m_bAutoGain = (dblEnable != 0.0); // set text strTemp.setNum ((short int)m_minMasterGain, 10); textMinMasterGain->setText (strTemp); strTemp.setNum ((short int)m_maxMasterGain, 10); textMaxMasterGain->setText (strTemp); m_bInit = TRUE; // update slider control sliderMaster->setMinimum (m_minMasterGain); sliderMaster->setMaximum (m_maxMasterGain); sliderMaster->setSingleStep (m_incMasterGain); sliderMaster->setPageStep (4* m_incMasterGain); sliderMaster->setValue (m_nMasterGain); sliderMaster->setEnabled ((m_SensorInfo.bMasterGain == TRUE) && !m_bAutoGain); // update spin control spinBoxMaster->setMinimum (m_minMasterGain); spinBoxMaster->setMaximum (m_maxMasterGain); spinBoxMaster->setSingleStep (m_incMasterGain); spinBoxMaster->setValue (m_nMasterGain); spinBoxMaster->setEnabled ((m_SensorInfo.bMasterGain == TRUE) && !m_bAutoGain); // auto checkAutoGain->setChecked (m_bAutoGain); checkAutoGain->setEnabled (m_bHasAutoGain && !m_bAutoFramerate); m_bInit = FALSE; }
INT UEyeCamDriver::setGain(bool& auto_gain, INT& master_gain_prc, INT& red_gain_prc, INT& green_gain_prc, INT& blue_gain_prc, bool& gain_boost) { if (!isConnected()) return IS_INVALID_CAMERA_HANDLE; INT is_err = IS_SUCCESS; // Validate arguments CAP(master_gain_prc, 0, 100); CAP(red_gain_prc, 0, 100); CAP(green_gain_prc, 0, 100); CAP(blue_gain_prc, 0, 100); double pval1 = 0, pval2 = 0; if (auto_gain) { // Set auto gain pval1 = 1; if ((is_err = is_SetAutoParameter(cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_GAIN, &pval1, &pval2)) != IS_SUCCESS) { if ((is_err = is_SetAutoParameter(cam_handle_, IS_SET_ENABLE_AUTO_GAIN, &pval1, &pval2)) != IS_SUCCESS) { std::cerr << "Auto gain mode is not supported for UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; auto_gain = false; } } } else { // Disable auto gain if ((is_err = is_SetAutoParameter(cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_GAIN, &pval1, &pval2)) != IS_SUCCESS) { if ((is_err = is_SetAutoParameter(cam_handle_, IS_SET_ENABLE_AUTO_GAIN, &pval1, &pval2)) != IS_SUCCESS) { std::cout << "Auto gain mode is not supported for UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; } } // Set gain boost if (is_SetGainBoost(cam_handle_, IS_GET_SUPPORTED_GAINBOOST) != IS_SET_GAINBOOST_ON) { gain_boost = false; } else { if ((is_err = is_SetGainBoost( cam_handle_, (gain_boost) ? IS_SET_GAINBOOST_ON : IS_SET_GAINBOOST_OFF)) != IS_SUCCESS) { std::cerr << "Failed to " << ((gain_boost) ? "enable" : "disable") << " gain boost for UEye camera '" + cam_name_ + "'" << std::endl; } } // Set manual gain parameters if ((is_err = is_SetHardwareGain(cam_handle_, master_gain_prc, red_gain_prc, green_gain_prc, blue_gain_prc)) != IS_SUCCESS) { std::cerr << "Failed to set manual gains (master: " << master_gain_prc << "; red: " << red_gain_prc << "; green: " << green_gain_prc << "; blue: " << blue_gain_prc << ") for UEye camera '" + cam_name_ + "'" << std::endl; } } if (auto_gain) { std::cout << "Updated gain: auto" << std::endl; } else { std::cout << "Updated gain: manual" << "\n - master gain: " << master_gain_prc << "\n - red gain: " << red_gain_prc << "\n - green gain: " << green_gain_prc << "\n - blue gain: " << blue_gain_prc << "\n - gain boost: " << gain_boost << std::endl; } return is_err; }
void CameraApi::setHardwareGain(int master, int red, int green, int blue) { is_SetHardwareGain(mhCam, master, red, green, blue); }
static PyObject *ids_core_Camera_getgain(ids_core_Camera *self, void *closure) { int gain = is_SetHardwareGain(self->handle, IS_GET_MASTER_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); return PyLong_FromLong(gain); }
// ------------------- UpdateRGBGainCtrls ----------------------- // void properties::UpdateRGBGainCtrls () { if (m_bInit || !m_hCamera) return; QString strTemp; double dblEnable = 0.0; // get values m_maxRGBGain = IS_MAX_GAIN; m_minRGBGain = IS_MIN_GAIN; m_incRGBGain = 1; m_nRedGain = is_SetHardwareGain (m_hCamera, IS_GET_RED_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); m_nGreenGain = is_SetHardwareGain (m_hCamera, IS_GET_GREEN_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); m_nBlueGain = is_SetHardwareGain (m_hCamera, IS_GET_BLUE_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER); is_SetAutoParameter (m_hCamera, IS_GET_ENABLE_AUTO_WHITEBALANCE, &dblEnable, NULL); // set text strTemp.setNum ((short int)m_minRGBGain, 10); textMinRGBGain->setText (strTemp); strTemp.setNum ((short int)m_maxRGBGain, 10); textMaxRGBGain->setText (strTemp); m_bInit = TRUE; // update slider controls // red sliderRed->setMinValue (m_minRGBGain); sliderRed->setMaxValue (m_maxRGBGain); sliderRed->setSteps (m_incRGBGain, 4* m_incRGBGain ); sliderRed->setValue (m_nRedGain); sliderRed->setEnabled ((m_SensorInfo.bRGain == TRUE) && (dblEnable == 0.0)); // green sliderGreen->setMinValue (m_minRGBGain); sliderGreen->setMaxValue (m_maxRGBGain); sliderGreen->setSteps (m_incRGBGain, 4* m_incRGBGain ); sliderGreen->setValue (m_nGreenGain); sliderGreen->setEnabled ((m_SensorInfo.bGGain == TRUE) && (dblEnable == 0.0)); // blue sliderBlue->setMinValue (m_minRGBGain); sliderBlue->setMaxValue (m_maxRGBGain); sliderBlue->setSteps (m_incRGBGain, 4* m_incRGBGain ); sliderBlue->setValue (m_nBlueGain); sliderBlue->setEnabled ((m_SensorInfo.bBGain == TRUE) && (dblEnable == 0.0)); // update spin controls // red spinBoxRed->setMinValue (m_minRGBGain); spinBoxRed->setMaxValue (m_maxRGBGain); spinBoxRed->setSingleStep (m_incRGBGain); spinBoxRed->setValue (m_nRedGain); spinBoxRed->setEnabled ((m_SensorInfo.bRGain == TRUE) && (dblEnable == 0.0)); // green spinBoxGreen->setMinValue (m_minRGBGain); spinBoxGreen->setMaxValue (m_maxRGBGain); spinBoxGreen->setSingleStep (m_incRGBGain); spinBoxGreen->setValue (m_nGreenGain); spinBoxGreen->setEnabled ((m_SensorInfo.bGGain == TRUE) && (dblEnable == 0.0)); // blue spinBoxBlue->setMinValue (m_minRGBGain); spinBoxBlue->setMaxValue (m_maxRGBGain); spinBoxBlue->setSingleStep (m_incRGBGain); spinBoxBlue->setValue (m_nBlueGain); spinBoxBlue->setEnabled ((m_SensorInfo.bBGain == TRUE) && (dblEnable == 0.0)); m_bInit = FALSE; }