Exemplo n.º 1
0
ImageCaptureInterface::CapErrorCode UEyeCaptureInterface::getCaptureProperty(int id, int *value)
{
 //   printf("Getting the values of capture properties is not supported for uEye interface yet.\n");

    switch (id)
    {
       case (CameraParameters::EXPOSURE):
       {
           double ms = 0.0;
           ueyeTrace(is_Exposure (leftCamera.mCamera , IS_EXPOSURE_CMD_GET_EXPOSURE, (void*)&ms, sizeof(double)));
           *value = ms * EXPOSURE_SCALER;
           return SUCCESS;
       }

       case (CameraParameters::FPS):
       {
           double newFps;
           ueyeTrace(is_SetFrameRate (leftCamera.mCamera , IS_GET_FRAMERATE, &newFps));
           *value = newFps * FPS_SCALER;
           return SUCCESS;
       }
       case (CameraParameters::MASTER_FLASH_DELAY):
       {
           IO_FLASH_PARAMS flashParams;
           flashParams.s32Delay    = 0;
           flashParams.u32Duration = 0;
           ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_GET_PARAMS, (void*)&flashParams, sizeof(flashParams)));
           *value = flashParams.s32Delay;
           return SUCCESS;
       }
       case (CameraParameters::MASTER_FLASH_DURATION):
       {
           IO_FLASH_PARAMS flashParams;
           flashParams.s32Delay    = 0;
           flashParams.u32Duration = 0;
           ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_GET_PARAMS, (void*)&flashParams, sizeof(flashParams)));
           *value = flashParams.u32Duration;
           return SUCCESS;
       }

       case (CameraParameters::SLAVE_TRIGGER_DELAY):
       {
           *value = is_SetTriggerDelay (rightCamera.mCamera, IS_GET_TRIGGER_DELAY);
           return SUCCESS;
       }


       default:
       {
           printf("Set request for unknown parameter (%d)\n", id);
           return ImageCaptureInterface::FAILURE;
       }
    }

    return FAILURE;
}
Exemplo n.º 2
0
static int ids_core_Camera_setflashparams(ids_core_Camera *self, PyObject *set_tuple) {
    int ret;
    IO_FLASH_PARAMS f = {
        .s32Delay    = (INT) PyLong_AsLong(PyTuple_GetItem(set_tuple, 0)),
        .u32Duration = (UINT) PyLong_AsUnsignedLong(PyTuple_GetItem(set_tuple, 1))
    };

    ret = is_IO(self->handle, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&f, sizeof(f));
    switch (ret) {
        case IS_SUCCESS:
            return 0;
        default:
            PyErr_SetString(PyExc_ValueError, "An error occurred when setting flash parameters.");
            return -1;
    }
}

static PyObject *ids_core_Camera_getaoi(ids_core_Camera *self, void *closure) {
    PyObject *ret_tuple = PyTuple_New(4);
    IS_RECT r;
    is_AOI(self->handle, IS_AOI_IMAGE_GET_AOI, &r, sizeof(r));
    PyTuple_SetItem(ret_tuple, 0, PyLong_FromLong(r.s32X));
    PyTuple_SetItem(ret_tuple, 1, PyLong_FromLong(r.s32Y));
    PyTuple_SetItem(ret_tuple, 2, PyLong_FromLong(r.s32Width));
    PyTuple_SetItem(ret_tuple, 3, PyLong_FromLong(r.s32Height));
    return ret_tuple;
}
Exemplo n.º 3
0
bool FlosIDSAdaptor::startCapture()
{	
    if(!isOpen()) {
        return false;
    }

    UINT   nMode;
    INT    nRet = IS_SUCCESS;
    double dNominal = 128;
    double dEnable  = 1;
            
    is_SetDisplayMode(m_deviceID, IS_SET_DM_DIB);
    is_SetExternalTrigger(m_deviceID, IS_SET_TRIGGER_SOFTWARE);

    nMode = IO_FLASH_MODE_TRIGGER_HI_ACTIVE;
    is_IO(m_deviceID, IS_IO_CMD_FLASH_SET_MODE, (void *)&nMode, sizeof(nMode));

    is_SetAutoParameter(m_deviceID, IS_SET_ENABLE_AUTO_GAIN, &dEnable, 0);
    is_SetAutoParameter(m_deviceID, IS_SET_AUTO_REFERENCE, &dNominal, 0);

    is_SetColorMode(m_deviceID, IS_CM_BGR8_PACKED);
    is_SetFrameRate(m_deviceID, 20, NULL);

    if((is_CaptureVideo(m_deviceID, IS_DONT_WAIT) != IS_SUCCESS)) {
        imaqkit::adaptorWarn("FlosIDSAdaptor:startCapture", "Could not start capturing.");
        return false;
    }

    setAcquisitionActive(true);
    PostThreadMessage(m_acquireThreadID, WM_USER, 0, 0);

    return true;
}
INT UEyeCamDriver::setFlashParams(INT& delay_us, UINT& duration_us) {
    INT is_err = IS_SUCCESS;

    // Make sure parameters are within range supported by camera
    IO_FLASH_PARAMS minFlashParams, maxFlashParams, newFlashParams;
    if ((is_err = is_IO(cam_handle_, IS_IO_CMD_FLASH_GET_PARAMS_MIN,
                        (void*) &minFlashParams, sizeof(IO_FLASH_PARAMS)))
        != IS_SUCCESS) {
        std::cerr << "Could not retrieve flash parameter info (min) for UEye camera '"
                  << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
        return is_err;
    }
    if ((is_err = is_IO(cam_handle_, IS_IO_CMD_FLASH_GET_PARAMS_MAX,
                        (void*) &maxFlashParams, sizeof(IO_FLASH_PARAMS)))
        != IS_SUCCESS) {
        std::cerr << "Could not retrieve flash parameter info (max) for UEye camera '"
                  << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
        return is_err;
    }
    delay_us =
            (delay_us < minFlashParams.s32Delay) ?
                    minFlashParams.s32Delay :
                    ((delay_us > maxFlashParams.s32Delay) ?
                            maxFlashParams.s32Delay : delay_us);
    duration_us =
            (duration_us < minFlashParams.u32Duration && duration_us != 0) ?
                    minFlashParams.u32Duration :
                    ((duration_us > maxFlashParams.u32Duration) ?
                            maxFlashParams.u32Duration : duration_us);
    newFlashParams.s32Delay = delay_us;
    newFlashParams.u32Duration = duration_us;
    // WARNING: Setting s32Duration to 0, according to documentation, means
    //          setting duration to total exposure time. If non-ext-triggered
    //          camera is operating at fastest grab rate, then the resulting
    //          flash signal will APPEAR as active LO when set to active HIGH,
    //          and vice versa. This is why the duration is set manually.
    if ((is_err = is_IO(cam_handle_, IS_IO_CMD_FLASH_SET_PARAMS,
                        (void*) &newFlashParams, sizeof(IO_FLASH_PARAMS)))
        != IS_SUCCESS) {
        std::cerr << "Could not set flash parameter info for UEye camera '"
                  << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
        return is_err;
    }

    return is_err;
}
Exemplo n.º 5
0
static PyObject *ids_core_Camera_getflashparams(ids_core_Camera *self, void *closure) {
    PyObject *ret_tuple = PyTuple_New(2);
    IO_FLASH_PARAMS f;
    is_IO(self->handle, IS_IO_CMD_FLASH_GET_PARAMS, (void*)&f, sizeof(f));
    PyTuple_SetItem(ret_tuple, 0, PyLong_FromLong((long) f.s32Delay));
    PyTuple_SetItem(ret_tuple, 1, PyLong_FromUnsignedLong((unsigned long) f.u32Duration));
    return ret_tuple;
}
INT UEyeCamDriver::setStandbyMode() {
    if (!isConnected())
        return IS_INVALID_CAMERA_HANDLE;

    INT is_err = IS_SUCCESS;

    if (extTriggerModeActive()) {
        if ((is_err = is_DisableEvent(cam_handle_, IS_SET_EVENT_FRAME)) != IS_SUCCESS) {
            std::cerr << "Could not disable frame event for UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        if ((is_err = is_SetExternalTrigger(cam_handle_, IS_SET_TRIGGER_OFF)) != IS_SUCCESS) {
            std::cerr
                    << "Could not disable external trigger mode on UEye camera '"
                    << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        is_SetExternalTrigger(cam_handle_, IS_GET_TRIGGER_STATUS); // documentation seems to suggest that this is needed to disable external trigger mode (to go into free-run mode)
        if ((is_err = is_StopLiveVideo(cam_handle_, IS_WAIT)) != IS_SUCCESS) {
            std::cerr << "Could not stop live video mode on UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        std::cout << "Stopped external trigger mode on UEye camera '" + cam_name_ + "'"
                  << std::endl;
    } else if (freeRunModeActive()) {
        UINT nMode = IO_FLASH_MODE_OFF;
        if ((is_err = is_IO(cam_handle_, IS_IO_CMD_FLASH_SET_MODE,
                            (void*) &nMode, sizeof(nMode)))
            != IS_SUCCESS) {
            std::cerr << "Could not disable flash output for UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        if ((is_err = is_DisableEvent(cam_handle_, IS_SET_EVENT_FRAME)) != IS_SUCCESS) {
            std::cerr << "Could not disable frame event for UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        if ((is_err = is_StopLiveVideo(cam_handle_, IS_WAIT)) != IS_SUCCESS) {
            std::cerr << "Could not stop live video mode on UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        std::cout << "Stopped free-run live video mode on UEye camera '" + cam_name_ + "'"
                  << std::endl;
    }
    if ((is_err = is_CameraStatus(cam_handle_, IS_STANDBY, IS_GET_STATUS)) != IS_SUCCESS) {
        std::cerr << "Could not set standby mode for UEye camera '" << cam_name_
                  << "' (" << err2str(is_err) << ")" << std::endl;
        return is_err;
    }

    return is_err;
}
INT UEyeCamDriver::setFreeRunMode() {
    if (!isConnected())
        return IS_INVALID_CAMERA_HANDLE;

    INT is_err = IS_SUCCESS;

    if (!freeRunModeActive()) {
        setStandbyMode(); // No need to check for success

        // Set the flash to a high active pulse for each image in the trigger mode
        INT flash_delay = 0;
        UINT flash_duration = 1000;
        setFlashParams(flash_delay, flash_duration);
        UINT nMode = IO_FLASH_MODE_FREERUN_HI_ACTIVE;
        if ((is_err = is_IO(cam_handle_, IS_IO_CMD_FLASH_SET_MODE,
                            (void*) &nMode, sizeof(nMode)))
            != IS_SUCCESS) {
            std::cerr << "Could not set free-run active-low flash output for UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }

        if ((is_err = is_EnableEvent(cam_handle_, IS_SET_EVENT_FRAME)) != IS_SUCCESS) {
            std::cerr << "Could not enable frame event for UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        if ((is_err = is_CaptureVideo(cam_handle_, IS_WAIT)) != IS_SUCCESS) {
            std::cerr << "Could not start free-run live video mode on UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        std::cout << "Started live video mode on UEye camera '" + cam_name_ + "'" << std::endl;
    }

    return is_err;
}
Exemplo n.º 8
0
UEyeCaptureInterface::CapErrorCode UEyeCaptureInterface::setCaptureProperty(int id, int value)
{
    int retL = 0;
    int retR = 0;

    switch (id)
    {
        case (CameraParameters::EXPOSURE):
        {
            double ms = 0.0;
            ms = (double)value / EXPOSURE_SCALER;
            ueyeTrace(is_Exposure (leftCamera.mCamera , IS_EXPOSURE_CMD_SET_EXPOSURE, (void*)&ms, sizeof(double)));
            ms = (double)value / EXPOSURE_SCALER;
            ueyeTrace(is_Exposure (rightCamera.mCamera, IS_EXPOSURE_CMD_SET_EXPOSURE, (void*)&ms, sizeof(double)));
            return SUCCESS;
        }
        case (CameraParameters::FPS):
        {
            double fps = (double)value / FPS_SCALER;
            double newFps;
            ueyeTrace(is_SetFrameRate (leftCamera.mCamera , fps, &newFps));
            ueyeTrace(is_SetFrameRate (rightCamera.mCamera, fps, &newFps));
            return SUCCESS;
        }
        case (CameraParameters::MASTER_FLASH_DELAY):
        {
            IO_FLASH_PARAMS flashParams;
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 0;
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_GET_PARAMS, (void*)&flashParams, sizeof(flashParams)));
            flashParams.s32Delay = value;
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));
            return SUCCESS;
        }
        case (CameraParameters::MASTER_FLASH_DURATION):
        {
            IO_FLASH_PARAMS flashParams;
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 0;
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_GET_PARAMS, (void*)&flashParams, sizeof(flashParams)));
            flashParams.u32Duration = value;
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));
            return SUCCESS;
        }

        case (CameraParameters::SLAVE_TRIGGER_DELAY):
        {
            is_SetTriggerDelay (rightCamera.mCamera, value);
            return SUCCESS;
        }
        case (CameraParameters::EXPOSURE_AUTO) :
        {
            double enable = value;
            ueyeTrace(is_SetAutoParameter(leftCamera.mCamera, IS_SET_ENABLE_AUTO_SHUTTER, &enable, 0));
            return SUCCESS;
        }
        default:
        {
            printf("Set request for unknown parameter (%d)\n", id);
            return ImageCaptureInterface::FAILURE;
        }
    }

    return (ImageCaptureInterface::CapErrorCode) ((bool) retL + (bool) retR);
}
Exemplo n.º 9
0
ImageCaptureInterface::CapErrorCode UEyeCaptureInterface::startCapture()
{
    qDebug("Start capture");

    printf("Enabling events...\n");
#ifdef Q_OS_WIN
    leftCamera.mWinEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    is_InitEvent(leftCamera.mCamera, leftCamera.mWinEvent, IS_SET_EVENT_FRAME);

    rightCamera.mWinEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    is_InitEvent(rightCamera.mCamera, rightCamera.mWinEvent, IS_SET_EVENT_FRAME);
#endif

    is_EnableEvent(leftCamera.mCamera, IS_SET_EVENT_FRAME);
    is_EnableEvent(rightCamera.mCamera, IS_SET_EVENT_FRAME);

    switch (sync)
    {
        case NO_SYNC:
            is_CaptureVideo (leftCamera.mCamera, IS_DONT_WAIT);
            is_CaptureVideo (rightCamera.mCamera, IS_DONT_WAIT);
            break;
        case SOFT_SYNC:
            is_SetExternalTrigger (leftCamera.mCamera , IS_SET_TRIGGER_SOFTWARE);
            is_SetExternalTrigger (rightCamera.mCamera, IS_SET_TRIGGER_SOFTWARE);
            break;
        case HARD_SYNC:
        {
            /* Should make a check that connection exist */
            /*Left camera will generate flash*/
            UINT nMode = IO_FLASH_MODE_FREERUN_HI_ACTIVE;
            printf("Setting left flash IO_FLASH_MODE_FREERUN_HI_ACTIVE...\n");
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_MODE, (void*)&nMode, sizeof(nMode)));

            /* Switching on leftCamera flash that will become right camera trigger */
            printf("Setting left flash duration and delay...\n");
            IO_FLASH_PARAMS flashParams;
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 5000;  // in us
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));


            /*right camera will generate flash also (for debug)*/
            nMode = IO_FLASH_MODE_FREERUN_HI_ACTIVE;
            printf("Setting right flash IO_FLASH_MODE_FREERUN_HI_ACTIVE...\n");
            ueyeTrace(is_IO(rightCamera.mCamera, IS_IO_CMD_FLASH_SET_MODE, (void*)&nMode, sizeof(nMode)));

            /* Switching on leftCamera flash that will become right camera trigger */
            printf("Setting right flash duration and delay...\n");
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 5000;
            ueyeTrace(is_IO(rightCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));

            /* Right camera is trigger based */
            ueyeTrace(is_SetExternalTrigger (rightCamera.mCamera, IS_SET_TRIGGER_LO_HI));
            //ueyeTrace(is_SetExternalTrigger (rightCamera.mCamera, IS_SET_TRIGGER_HI_LO));

			printf("Launching both cameras run...\n");
			/* Left camera is in free run mode */
			ueyeTrace(is_CaptureVideo (leftCamera.mCamera, IS_DONT_WAIT));
			/* Same for the right camera */
			ueyeTrace(is_CaptureVideo (rightCamera.mCamera, IS_DONT_WAIT));
        	break;
        }
        case FRAME_HARD_SYNC:
        {
            /* TODO: Should make a check that connection exist */
        	/* Both cams are now trigger based*/
            ueyeTrace(is_SetExternalTrigger (leftCamera.mCamera, IS_SET_TRIGGER_OFF));

            /*Left camera will generate flash*/
            UINT nMode = IO_FLASH_MODE_FREERUN_HI_ACTIVE;
            printf("Setting left flash IO_FLASH_MODE_TRIGGER_HI_ACTIVE...\n");
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_MODE, (void*)&nMode, sizeof(nMode)));

            /* Switching on leftCamera flash that will become right camera trigger */
            printf("Setting left flash duration and delay...\n");
            IO_FLASH_PARAMS flashParams;
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 5000;
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));

            printf("Setting right camera to TRIGGER MODE...\n");
            ueyeTrace(is_SetExternalTrigger (rightCamera.mCamera, IS_SET_TRIGGER_LO_HI   ));

            /*right camera will generate flash also (for debug)*/
            nMode = IO_FLASH_MODE_TRIGGER_HI_ACTIVE;
            printf("Setting right flash IO_FLASH_MODE_TRIGGER_HI_ACTIVE...\n");
            ueyeTrace(is_IO(rightCamera.mCamera, IS_IO_CMD_FLASH_SET_MODE, (void*)&nMode, sizeof(nMode)));

            /* Switching on leftCamera flash that will become right camera trigger */
            printf("Setting right flash duration and delay...\n");
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 5000;
            ueyeTrace(is_IO(rightCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));
            break;
        }
        case EXT_SYNC:
        {
            printf("Running on external syncro...\n");
        	/* Setting triggers for both cams*/
            printf("Setting left camera to TRIGGER MODE...\n");
            ueyeTrace(is_SetExternalTrigger (leftCamera.mCamera, IS_SET_TRIGGER_LO_HI));
            printf("Setting right camera to TRIGGER MODE...\n");
            ueyeTrace(is_SetExternalTrigger (rightCamera.mCamera,IS_SET_TRIGGER_LO_HI));

            /*Left camera will generate flash*/
            UINT nMode = IO_FLASH_MODE_TRIGGER_HI_ACTIVE;
            printf("Setting left flash IO_FLASH_MODE_TRIGGER_HI_ACTIVE...\n");
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_MODE, (void*)&nMode, sizeof(nMode)));

            /* Switching on leftCamera flash that will become right camera trigger */
            printf("Setting left flash duration and delay...\n");
            IO_FLASH_PARAMS flashParams;
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 5000;
            ueyeTrace(is_IO(leftCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));

            /*right camera will generate flash also (for debug)*/
            nMode = IO_FLASH_MODE_TRIGGER_HI_ACTIVE;
            printf("Setting right flash IO_FLASH_MODE_TRIGGER_HI_ACTIVE...\n");
            ueyeTrace(is_IO(rightCamera.mCamera, IS_IO_CMD_FLASH_SET_MODE, (void*)&nMode, sizeof(nMode)));

            /* Switching on leftCamera flash that will become right camera trigger */
            printf("Setting right flash duration and delay...\n");
            flashParams.s32Delay    = 0;
            flashParams.u32Duration = 5000;
            ueyeTrace(is_IO(rightCamera.mCamera, IS_IO_CMD_FLASH_SET_PARAMS, (void*)&flashParams, sizeof(flashParams)));

            /* Left camera is repeated run mode */
			ueyeTrace(is_CaptureVideo (leftCamera.mCamera, IS_DONT_WAIT));
			/* Same for the right camera */
			ueyeTrace(is_CaptureVideo (rightCamera.mCamera, IS_DONT_WAIT));
            break;

        }

    }

    shouldStopSpinThread = false;
    spin.start();
    return ImageCaptureInterface::SUCCESS;
}