예제 #1
0
// -------------------  UpdateFeaturesCtrls  -----------------------
//
void properties::UpdateFeaturesCtrls ()
{
    if (m_bInit || !m_hCamera)
        return;

    // get values
    INT nGamma = 0;
    is_Gamma(m_hCamera, IS_GAMMA_CMD_GET, &nGamma, sizeof(nGamma));
    m_bSoftwareGammaSet = nGamma == 180;
    m_bHardwareGammaSet = (is_SetHardwareGamma (m_hCamera, IS_GET_HW_GAMMA) == IS_SET_HW_GAMMA_ON);

    // Read out current mode
    INT nMode = 0;
    is_HotPixel(m_hCamera, IS_HOTPIXEL_GET_CORRECTION_MODE, (void*)&nMode, sizeof(nMode));
    m_bHotPixelCorrSet = nMode;

    m_bGainBoostSet = (is_SetGainBoost (m_hCamera, IS_GET_GAINBOOST) == IS_SET_GAINBOOST_ON);

    // set checked
    checkBoxSoftwareGamma->setChecked (m_bSoftwareGammaSet);
    checkBoxHardwareGamma->setChecked (m_bHardwareGammaSet);
    checkBoxBadPixel->setChecked (m_bHotPixelCorrSet);
    checkBoxGainBoost->setChecked (m_bGainBoostSet);
    // enable
    checkBoxSoftwareGamma->setEnabled (m_bHasSoftwareGamma);
    checkBoxHardwareGamma->setEnabled (m_bHasHardwareGamma);
    checkBoxBadPixel->setEnabled (TRUE);
    checkBoxGainBoost->setEnabled (m_bHasGainBoost);
}
예제 #2
0
void properties::initTabImage()
{
	INT nBlacklevelCaps;
	INT nRet = 0;

	nRet = is_Blacklevel(m_hCamera, IS_BLACKLEVEL_CMD_GET_CAPS, &nBlacklevelCaps, sizeof(nBlacklevelCaps));
	if(nRet == IS_SUCCESS)
	{
		m_bHasAutoBlackLevel = (nBlacklevelCaps & IS_BLACKLEVEL_CAP_SET_AUTO_BLACKLEVEL) != 0;
		m_bHasManualBlackLevel = (nBlacklevelCaps & IS_BLACKLEVEL_CAP_SET_OFFSET) != 0;
	}

    m_bHasHardwareGamma = (is_SetHardwareGamma (m_hCamera, IS_GET_HW_SUPPORTED_GAMMA)
            & IS_SET_HW_GAMMA_ON);
    INT nGamma;
    m_bHasSoftwareGamma = (is_Gamma (m_hCamera, IS_GAMMA_CMD_GET, &nGamma, sizeof(nGamma)) != IS_NO_SUCCESS);
    m_bHasGainBoost = (is_SetGainBoost (m_hCamera, IS_GET_SUPPORTED_GAINBOOST)
            & IS_SET_GAINBOOST_ON);

    // Timer for automatic updates
    connect(m_pTimerUpdateImageCtrl, SIGNAL(timeout()), this, SLOT(OnAutoUpdateImageCtrls()));
    m_pTimerUpdateImageCtrl->start(750);

    // Get Range for EdgeEnhancement
    UINT nRange[3];
    ZeroMemory(nRange, sizeof(nRange));

    nRet = is_EdgeEnhancement(m_hCamera, IS_EDGE_ENHANCEMENT_CMD_GET_RANGE, (void*)nRange, sizeof(nRange));
    if(nRet == IS_SUCCESS)
    {
    	m_weakEdgeEnhancement = nRange[1] / 2;
    	m_strongEdgeEnhancement = nRange[1];
    }
}
예제 #3
0
// -------------------  checkBoxGainBoost_clicked  -----------------------
//
void properties::checkBoxGainBoost_clicked ()
{
    if (m_bInit || !m_hCamera)
        return;

    is_SetGainBoost (m_hCamera, checkBoxGainBoost->isChecked () ? IS_SET_GAINBOOST_ON
                                                                : IS_SET_GAINBOOST_OFF);
}
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;
}
예제 #5
0
bool IdsSourceSink::Init()
{

    PUEYE_CAMERA_LIST m_pCamList;
    UEYE_CAMERA_INFO m_CameraInfo;
    // init the internal camera info structure
    ZeroMemory (&m_CameraInfo, sizeof(UEYE_CAMERA_INFO));

    // get the cameralist from SDK
    m_pCamList = new UEYE_CAMERA_LIST;
    m_pCamList->dwCount = 0;

    if (is_GetCameraList (m_pCamList) == IS_SUCCESS) {
            DWORD dw = m_pCamList->dwCount;
            delete m_pCamList;

            // Reallocate the required camera list size
            m_pCamList = (PUEYE_CAMERA_LIST)new char[sizeof(DWORD) + dw * sizeof(UEYE_CAMERA_INFO)];
            m_pCamList->dwCount = dw;

            // Get CameraList and store it ...
            if (is_GetCameraList (m_pCamList) != IS_SUCCESS) return false;
    } else return false;

    if (m_pCamList->dwCount==0) {
        qDebug()<<"No camera found";
        return false;
    } else if (m_pCamList->dwCount>1) {
        qDebug()<<"More than 1 camera: "<<m_pCamList->dwCount;
    }

    // will use camera 0
    memcpy (&m_CameraInfo, &m_pCamList->uci[0], sizeof(UEYE_CAMERA_INFO));
    hCam = (HIDS) (m_CameraInfo.dwDeviceID | IS_USE_DEVICE_ID);


    if(is_InitCamera (&hCam, NULL)!= IS_SUCCESS){
        qDebug()<<"init not successful";
           return false;
    }

//    double minFPS, maxFPS, FPSinterval;
//    is_GetFrameTimeRange (hCam, &minFPS, &maxFPS, &FPSinterval);
         //cout<< fixed << setprecision(4) << minFPS << " MINFPS " << maxFPS << " MAXFPS "<< FPSinterval << " FPSinterval " << endl;
         //myfile<< fixed << setprecision(4) << minFPS << " MINFPS " << maxFPS << " MAXFPS "<< FPSinterval << " FPSinterval " << endl;

    is_SetGainBoost (hCam, IS_SET_GAINBOOST_OFF);
    is_SetWhiteBalance (hCam, IS_SET_WB_DISABLE);
//    is_SetBrightness (hCam,0);
//    is_SetContrast (hCam,0);
//    is_SetGamma (hCam, 100);// Value multiplied by 100 (for the camera it goes from 0.01 to 10
    is_SetHWGainFactor (hCam, IS_SET_MASTER_GAIN_FACTOR, 100);
    uint pixelC=304;
    is_PixelClock(hCam, IS_PIXELCLOCK_CMD_SET, (void*)&pixelC, sizeof(pixelC));

    flagIDS= is_SetSubSampling (hCam, IS_SUBSAMPLING_2X_VERTICAL | IS_SUBSAMPLING_2X_HORIZONTAL); //Both are needed

    //Configuration section: very important to match the img_bpp=8 with the chacracteristics of the CV::MAT image to use
    //weird results like cropping or black lines can be obtained if not changed accordingly
    int img_width=2048, img_height=2048, img_bpp=8, factorSMP=2; //Variable to state the Linehopping
//    int img_step, img_data_size;

    imgMem = NULL;
    is_AllocImageMem(hCam, img_width/factorSMP, img_height/factorSMP, img_bpp, &imgMem, &memId);
    is_SetImageMem (hCam, imgMem, memId);
//    is_SetImageSize (hCam, img_width/factorSMP, img_height/factorSMP);

    is_SetColorMode (hCam, IS_CM_MONO8);

    is_SetDisplayMode (hCam, IS_SET_DM_DIB); // Direct buffer mode writes to RAM which is the only option on Linux

    //OpenCV variables: REMEMBER THE SUBSAMPLING
    buffer=cv::Mat::zeros(img_width/factorSMP,img_height/factorSMP, CV_8UC1);

    return true;
}