Exemplo n.º 1
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;
}
Exemplo n.º 3
0
INT WINAPI StartRunning(HIDS* m_hCam, const wchar_t* settingsFile, int* nMonitorId, void (WINAPI*OnWindowShow)(BOOL), HWND hWnd) { 
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	m_monitorId = nMonitorId;
	INT result = IS_SUCCESS;
	if (!m_bRunning && m_hCam) {
		if (!m_renderThread) {
			if( LoadSettings(m_hCam, settingsFile) != IS_SUCCESS) {
				// if settings from file cannot be loaded, then use default maximum size for the sensor
				GetMaxImageSize(m_hCam, &m_nSizeX, &m_nSizeY);
			}
			result = InitDisplayMode(m_hCam);
			if (result == IS_SUCCESS && !m_renderThread) {
				// start a new thread that will create a window to show the live video fullscreen
				m_renderThread = (CuEyeRenderThread *) AfxBeginThread(RUNTIME_CLASS(CuEyeRenderThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
				// set to false to prevent uncontrolled m_renderThread pointer invalidation
				m_renderThread->m_bAutoDelete = FALSE; 
				m_renderThread->Initialize(m_hCam, m_pcImageMemory, &m_lMemoryId, nMonitorId, OnWindowShow, hWnd);
				m_renderThread->ResumeThread();
			}
		} else if (!m_renderThread->m_pMainWnd && m_renderThread->GetHwnd() != hWnd) {
			// stop running was called and window handle invalidated
			PostThreadMessage(m_renderThread->m_nThreadID, IS_THREAD_MESSAGE, SET_HWND, (LPARAM) hWnd);
		}
		// start live video
		result |= is_CaptureVideo( *m_hCam, IS_DONT_WAIT );
		m_bRunning = TRUE;
	}
	return result;
}
Exemplo n.º 4
0
//////////////////////////////////////////////////////////////////////////////////
// enableLive --------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
void ofxUeye::enableLive()
{
    if(m_hCam != NULL)
    {
		bLive = true;
		is_CaptureVideo(m_hCam, IS_DONT_WAIT);
    }
}
Exemplo n.º 5
0
static PyObject *ids_core_Camera_getcontinuous_capture(ids_core_Camera *self,
                                                       void *closure) {
    int ret;

    ret = is_CaptureVideo(self->handle, IS_GET_LIVE);
    if (ret == TRUE) {
        Py_INCREF(Py_True);
        return Py_True;
    }

    Py_INCREF(Py_False);
    return Py_False;
}
Exemplo n.º 6
0
static int ids_core_Camera_setcontinuous_capture(ids_core_Camera *self,
                                                 PyObject *value, void *closure) {
    int ret;

    if (value == NULL) {
        PyErr_SetString(PyExc_TypeError, "Cannot delete attribute 'continuous_capture'");
        return -1;
    }

    if (!PyBool_Check(value)) {
        PyErr_SetString(PyExc_TypeError, "Attribute 'continuous_capture' must be boolean");
        return -1;
    }

    /* Enable continuous capture */
    if (value == Py_True) {
        ret = is_CaptureVideo(self->handle, IS_DONT_WAIT);
        switch (ret) {
        case IS_SUCCESS:
            break;
        case IS_TIMED_OUT:
            PyErr_SetString(PyExc_IOError, "Continuous capture start timed out.");
            return -1;
        case IS_NO_ACTIVE_IMG_MEM:
            PyErr_SetString(PyExc_IOError, "No image memory available.");
            return -1;
        default:
            raise_general_error(self, ret);
            return -1;
        }
    }
    /* Disable continuous capture */
    else if (value == Py_False) {
        ret = is_StopLiveVideo(self->handle, IS_FORCE_VIDEO_STOP);
        switch (ret) {
        case IS_SUCCESS:
            break;
        default:
            raise_general_error(self, ret);
            return -1;
        }
    }
    else {
        PyErr_SetString(PyExc_ValueError, "Unknown boolean value");
        return -1;
    }

    return 0;
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
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;
}
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.º 10
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;
}
Exemplo n.º 11
0
 inline bool isCapturing() {
   return ((cam_handle_ != (HIDS) 0) &&
       (is_CaptureVideo(cam_handle_, IS_GET_LIVE) == TRUE));
 }
Exemplo n.º 12
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;
    
}