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;
}
Ejemplo n.º 2
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::setExtTriggerMode() {
    if (!isConnected())
        return IS_INVALID_CAMERA_HANDLE;

    INT is_err = IS_SUCCESS;

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

        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_SetExternalTrigger(cam_handle_, IS_SET_TRIGGER_HI_LO)) != IS_SUCCESS) {
            std::cerr << "Could not enable falling-edge external trigger mode on UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        if ((is_err = is_CaptureVideo(cam_handle_, IS_DONT_WAIT)) != IS_SUCCESS) {
            std::cerr << "Could not start external trigger live video mode on UEye camera '"
                      << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        std::cout << "Started falling-edge external trigger live video mode on UEye camera '" + cam_name_ + "'"
                  << std::endl;
    }

    return is_err;
}
Ejemplo n.º 4
0
bool IdsSourceSink::StartAcquisition(QString dev)
{
    if (dev!="IDS") qDebug()<<"Different devices not yet implemented";

    is_SetExternalTrigger (hCam, IS_SET_TRIGGER_OFF); //This makes that calling freeze image creates a new image

#ifdef Q_OS_WIN32
    hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    is_InitEvent(hCam, hEvent, IS_SET_EVENT_FRAME);
#endif

    is_EnableEvent(hCam, IS_SET_EVENT_FRAME);
    is_CaptureVideo(hCam, IS_WAIT);


    //this is to make it correspond to the default value in the gui
    SetInterval(100);
    SetShutter(100);

    return true;
}
Ejemplo n.º 5
0
int CameraApi::openCamera()
{
	int is_init = IS_NO_SUCCESS;
	int is_mode = IS_NO_SUCCESS;
	int is_alcM = IS_NO_SUCCESS;
	int isLoad = IS_NO_SUCCESS;

	is_init = is_InitCamera(&mhCam, 0);

	if(is_init == IS_SUCCESS)
	{
		is_mode = is_SetDisplayMode(mhCam, IS_SET_DM_DIB);
	}

	if(is_mode == IS_SUCCESS)
	{
		ringbuffer = new char* [ringbufferSize];
		ringbufferId = new int [ringbufferSize];

		IS_SIZE_2D maxAoi;
		is_AOI(mhCam, IS_AOI_IMAGE_GET_SIZE_MAX, &maxAoi, sizeof(maxAoi));

		for(int i=0; i<ringbufferSize; i++)
		{
			is_AllocImageMem(mhCam, maxAoi.s32Width, maxAoi.s32Height, bitspixel(), &ringbuffer[i], &ringbufferId[i]); 
			is_AddToSequence(mhCam, ringbuffer[i], ringbufferId[i]);
		}

		isLoad = is_LoadParameters(mhCam, "cameraParameter.ini");
		setAoi(0, 0, width(), height());

		is_SetExternalTrigger(mhCam, IS_SET_TRIGGER_OFF);
		is_CaptureVideo(mhCam, IS_WAIT);
	}

	if(isLoad == IS_SUCCESS)
		return IS_SUCCESS;
	else
		return IS_NO_SUCCESS;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
 inline bool extTriggerModeActive() {
   return ((cam_handle_ != (HIDS) 0) &&
       (is_SetExternalTrigger(cam_handle_, IS_GET_EXTERNALTRIGGER) == IS_SET_TRIGGER_HI_LO) &&
       (is_CaptureVideo(cam_handle_, IS_GET_LIVE) == TRUE));
 }
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
    // CHECK ARGS
    if (nrhs != 0) {
        mexErrMsgIdAndTxt( "Mscope:initialiseCamera:invalidNumInputs",
                "No Input arguments accepted.");
    }
    if (nlhs > 2) {
        mexErrMsgIdAndTxt( "Mscope:initialiseCamera:maxlhs",
                "Too many output arguments.");
    }    
    
    HCAM hCam = 0;
    
    // CONNECT TO CAMERA AND GET THE HANDLE
    int rv = is_InitCamera(&hCam, NULL);
    
    // SET THE PIXEL CLOCK
    UINT pixelClock = DFT_PX_CLOCK;
    rv = is_PixelClock(hCam, IS_PIXELCLOCK_CMD_SET, (void*) &pixelClock, sizeof(pixelClock));
    
    // FRAME RATE
    double frameRate = DFT_FRAME_RATE;
    double actualFrameRate;
    
    rv = is_SetFrameRate(hCam, frameRate, &actualFrameRate);
      
    // EXPOSURE TIME
    double expTime = 10; // exposure time in ms
    rv = is_Exposure(hCam, IS_EXPOSURE_CMD_SET_EXPOSURE, &expTime, 8);
    
    // TRIGGER MODE
    rv = is_SetExternalTrigger(hCam, IS_SET_TRIGGER_SOFTWARE);
    
    // COLOR MODE
    rv = is_SetColorMode(hCam, IS_CM_MONO8); // 8-bit monochrome
    
     // SET THE SUBSAMPLING
    rv = is_SetSubSampling(hCam, IS_SUBSAMPLING_4X_VERTICAL | IS_SUBSAMPLING_4X_HORIZONTAL);
    
    // ALLOCATE MEMORY
    int bitDepth = 8;
    char* pcImgMem;
    int id;
    rv = is_AllocImageMem(hCam, H_PIX, V_PIX, bitDepth, &pcImgMem, &id);
    
    // CALCULATE THE LINE PITCH
    int linePitch;
    rv = is_GetImageMemPitch(hCam, &linePitch);
    std::printf("\nLine Pitch = %i\n",linePitch);
    
    // SET MEMORY
    rv = is_SetImageMem(hCam, pcImgMem, id);
    
    // START CAPTURING
    rv = is_CaptureVideo(hCam, IS_DONT_WAIT);
    
    // RETURN CAMERA HANDLE
    UINT8_T hCam8 = (UINT8_T) hCam;
    
    mwSignedIndex scalarDims[2] = {1,1}; // elements in image
    
    plhs[0] = mxCreateNumericArray(1, scalarDims, mxUINT8_CLASS, mxREAL);
    double * hCamPtr = mxGetPr(plhs[0]);
    
    memcpy(hCamPtr, &hCam8, sizeof(hCam8));
    
    // RETURN MEMORY ID
    UINT32_T id32 = (UINT32_T) id;
    
    plhs[1] = mxCreateNumericArray(1, scalarDims, mxUINT32_CLASS, mxREAL);
    double * mIdPtr = mxGetPr(plhs[1]);
    
    memcpy(mIdPtr, &id32, sizeof(id32));
    
    return;
    
}