예제 #1
0
//////////////////////////////////////////////////////////////////////////////////
// InitCamera --------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
INT ofxUeye::InitCamera (HIDS *m_hCam, HWND hWnd)
{
    INT nRet = is_InitCamera (m_hCam, hWnd);	
    /************************************************************************************************/
    /*                                                                                              */
    /*  If the camera returns with "IS_STARTER_FW_UPLOAD_NEEDED", an upload of a new firmware       */
    /*  is necessary. This upload can take several seconds. We recommend to check the required      */
    /*  time with the function is_GetDuration().                                                    */
    /*                                                                                              */
    /*  In this case, the camera can only be opened if the flag "IS_ALLOW_STARTER_FW_UPLOAD"        */ 
    /*  is "OR"-ed to m_hCam. This flag allows an automatic upload of the firmware.                 */
    /*                                                                                              */                        
    /************************************************************************************************/
    if (nRet == IS_STARTER_FW_UPLOAD_NEEDED)
    {
        // Time for the firmware upload = 25 seconds by default
        INT nUploadTime = 25000;
        is_GetDuration (*m_hCam, IS_STARTER_FW_UPLOAD, &nUploadTime);

        // Try again to open the camera. This time we allow the automatic upload of the firmware by
        // specifying "IS_ALLOW_STARTER_FIRMWARE_UPLOAD"
        *m_hCam = (HIDS) (((INT)*m_hCam) | IS_ALLOW_STARTER_FW_UPLOAD); 
        nRet = is_InitCamera (m_hCam, hWnd);   
    }

    return nRet;
}
INT UEyeCamDriver::connectCam(int new_cam_ID) {
    INT is_err = IS_SUCCESS;
    int numCameras;

    // Terminate any existing opened cameras
    setStandbyMode();

    // Updates camera ID if specified.
    if (new_cam_ID >= 0) {
        cam_id_ = new_cam_ID;
    }

    // Query for number of connected cameras
    if ((is_err = is_GetNumberOfCameras(&numCameras)) != IS_SUCCESS) {
        std::cerr << "Failed query for number of connected UEye cameras ("
                  << err2str(is_err) << ")" << std::endl;
        return is_err;
    } else if (numCameras < 1) {
        std::cerr << "No UEye cameras are connected" << std::endl;
        return IS_NO_SUCCESS;
    } // NOTE: previously checked if ID < numCameras, but turns out that ID can be arbitrary

    // Attempt to open camera handle, and handle case where camera requires a
    // mandatory firmware upload
    cam_handle_ = (HIDS) cam_id_;
    if ((is_err = is_InitCamera(&cam_handle_, NULL)) == IS_STARTER_FW_UPLOAD_NEEDED) {
        INT uploadTimeMSEC = 25000;
        is_GetDuration(cam_handle_, IS_STARTER_FW_UPLOAD, &uploadTimeMSEC);

        std::cout << "Uploading new firmware to UEye camera '" << cam_name_
                  << "'; please wait for about " << uploadTimeMSEC / 1000.0
                  << " seconds" << std::endl;

        // Attempt to re-open camera handle while triggering automatic firmware upload
        cam_handle_ = (HIDS) (((INT) cam_handle_) | IS_ALLOW_STARTER_FW_UPLOAD);
        is_err = is_InitCamera(&cam_handle_, NULL); // Will block for N seconds
    }
    if (is_err != IS_SUCCESS) {
        std::cerr << "Could not open UEye camera ID " << cam_id_ << " ("
                  << err2str(is_err) << ")" << std::endl;
        return is_err;
    }

    // Set display mode to Device Independent Bitmap (DIB)
    is_err = is_SetDisplayMode(cam_handle_, IS_SET_DM_DIB);

    // Fetch sensor parameters
    is_err = is_GetSensorInfo(cam_handle_, &cam_sensor_info_);

    // Initialize local camera frame buffer
    reallocateCamBuffer();

    return is_err;
}
예제 #3
0
INT WINAPI InitializeCamera(HIDS* m_hCam) {
	// open camera with the given ID
	INT result = is_InitCamera (m_hCam, NULL);
	if (result == IS_STARTER_FW_UPLOAD_NEEDED) {
        // Time for the firmware upload = 25 seconds by default
        INT nUploadTime = 25000;
        is_GetDuration (*m_hCam, IS_STARTER_FW_UPLOAD, &nUploadTime);
        /*CString Str1, Str2, Str3;
        Str1 = "This camera requires a new firmware. The upload will take about";
        Str2 = "seconds. Please wait ...";
        Str3.Format ("%s %d %s", Str1, nUploadTime / 1000, Str2);
        AfxMessageBox (Str3, MB_ICONWARNING);*/
        // Try again to open the camera. This time we allow the automatic upload of the firmware by
        // specifying "IS_ALLOW_STARTER_FIRMWARE_UPLOAD"
        *m_hCam = (HIDS) (((INT)*m_hCam) | IS_ALLOW_STARTER_FW_UPLOAD); 
        result = is_InitCamera (m_hCam, NULL);
    }	
	return result;
}