int IdsSourceSink::SetInterval(int msec) { double fps = 1000.0/((double)msec); double newfps; is_SetFrameRate(hCam,fps,&newfps); camTimeStep=1000.0/newfps; return camTimeStep; }
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; }
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; }
void CameraApi::setFrameRate(double frameRate, double* newFrameRate) { INT ret; if(mhCam != 0) { if(frameRate > 0.0) { ret = is_SetFrameRate(mhCam, frameRate, newFrameRate); } else { double stdRate; is_SetFrameRate(mhCam, IS_GET_DEFAULT_FRAMERATE, &stdRate); is_SetFrameRate(mhCam, stdRate, newFrameRate); } } else *newFrameRate = frameRate; }
////////////////////////////////////////////////////////////////////////////////// // setOptimalCameraTiming -------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////////// void ofxUeye::setOptimalCameraTiming(bool value) { if(value){ int pixelClock; double fps; int result = is_SetOptimalCameraTiming (m_hCam, IS_BEST_PCLK_RUN_ONCE, 10000, &pixelClock, &fps); is_SetPixelClock (m_hCam, pixelClock); is_SetFrameRate (m_hCam, fps, &fps); } }
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { // CHECK ARGS if (nrhs != 3) { mexErrMsgIdAndTxt( "Mscope:initialiseCamera:invalidNumInputs", "No Input arguments accepted."); } if (nlhs > 2) { mexErrMsgIdAndTxt( "Mscope:initialiseCamera:maxlhs", "Too many output arguments."); } if (!isScalarArray(prhs[0])) { mexErrMsgIdAndTxt( "Mscope:setAcqMode:invalidArg", "Camera handle is an integer"); } if (!isScalarArray(prhs[1])) { mexErrMsgIdAndTxt( "Mscope:setAcqMode:invalidArg", "Exposure is a double (in Hz)"); } if (!isScalarArray(prhs[1])) { mexErrMsgIdAndTxt( "Mscope:setAcqMode:invalidArg", "Frame rate rate is a double (in ms)"); } int hCam = (int) mxGetScalar(prhs[0]); double frameRate = (double) mxGetScalar(prhs[2]); double expTime = (double) mxGetScalar(prhs[1]); // FRAME RATE double actualFrameRate; int rv = is_SetFrameRate(hCam, frameRate, &actualFrameRate); // EXPOSURE TIME rv = is_Exposure(hCam, IS_EXPOSURE_CMD_SET_EXPOSURE, &expTime, 8); double actualExposure; rv = is_Exposure(hCam, IS_EXPOSURE_CMD_GET_EXPOSURE, &actualExposure, 8); // RETURN THE ACTUAL VALUES mwSignedIndex scalarDims[2] = {1,1}; // elements in image plhs[0] = mxCreateNumericArray(2, scalarDims, mxDOUBLE_CLASS, mxREAL); double * exposurePtr = mxGetPr(plhs[0]); memcpy(exposurePtr, &actualExposure, sizeof(actualExposure)); plhs[1] = mxCreateNumericArray(2, scalarDims, mxDOUBLE_CLASS, mxREAL); double * frameratePtr = mxGetPr(plhs[1]); memcpy(frameratePtr, &actualFrameRate, sizeof(actualFrameRate)); return; }
////////////////////////////////////////////////////////////////////////////////// // setFPS ------------------------------------------------------------------------ ////////////////////////////////////////////////////////////////////////////////// int ofxUeye::setFPS(double fps) { double newFPS; int result; result = is_SetFrameRate (m_hCam, fps, &newFPS); if(result == IS_SUCCESS) ofLog(OF_LOG_WARNING, "ofxUeye - setFPS - (%f) Success.", (float)newFPS); else ofLog(OF_LOG_WARNING, "ofxUeye - setFPS - Couldn't apply (%f).", (float)fps); return result; }
static int ids_core_Camera_setfps(ids_core_Camera *self, PyObject *value, void *closure) { int ret; double realfps; ret = is_SetFrameRate(self->handle, PyFloat_AsDouble(value), &realfps); switch (ret) { case IS_SUCCESS: return 0; case IS_INVALID_CAMERA_HANDLE: PyErr_SetString(PyExc_ValueError, "Invalid camera handle"); return -1; case IS_INVALID_MODE: PyErr_SetString(PyExc_ValueError, "Camera is in standby mode, function not allowed."); return -1; case IS_INVALID_PARAMETER: PyErr_SetString(PyExc_ValueError, "One of the submitted parameters is outside the valid range or is not supported for this sensor or is not available in this mode."); return -1; default: PyErr_SetString(PyExc_ValueError, "An error occurred when setting fps."); return -1; } }
INT UEyeCamDriver::setFrameRate(bool& auto_frame_rate, double& frame_rate_hz) { if (!isConnected()) return IS_INVALID_CAMERA_HANDLE; INT is_err = IS_SUCCESS; double pval1 = 0, pval2 = 0; double minFrameTime, maxFrameTime, intervalFrameTime, newFrameRate; // Make sure that auto shutter is enabled before enabling auto frame rate bool autoShutterOn = false; is_SetAutoParameter(cam_handle_, IS_GET_ENABLE_AUTO_SENSOR_SHUTTER, &pval1, &pval2); autoShutterOn |= (pval1 != 0); is_SetAutoParameter(cam_handle_, IS_GET_ENABLE_AUTO_SHUTTER, &pval1, &pval2); autoShutterOn |= (pval1 != 0); if (!autoShutterOn) { auto_frame_rate = false; } // Set frame rate / auto pval1 = auto_frame_rate; if ((is_err = is_SetAutoParameter(cam_handle_, IS_SET_ENABLE_AUTO_SENSOR_FRAMERATE, &pval1, &pval2)) != IS_SUCCESS) { if ((is_err = is_SetAutoParameter(cam_handle_, IS_SET_ENABLE_AUTO_FRAMERATE, &pval1, &pval2)) != IS_SUCCESS) { std::cerr << "Auto frame rate mode is not supported for UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; auto_frame_rate = false; } } if (!auto_frame_rate) { // Make sure that user-requested frame rate is achievable if ((is_err = is_GetFrameTimeRange(cam_handle_, &minFrameTime, &maxFrameTime, &intervalFrameTime)) != IS_SUCCESS) { std::cerr << "Failed to query valid frame rate range from UEye camera '" << cam_name_ << "'" << std::endl; return is_err; } CAP(frame_rate_hz, 1.0 / maxFrameTime, 1.0 / minFrameTime); // Update frame rate if ((is_err = is_SetFrameRate(cam_handle_, frame_rate_hz, &newFrameRate)) != IS_SUCCESS) { std::cerr << "Failed to set frame rate to " << frame_rate_hz << " MHz for UEye camera '" << cam_name_ << "'" << std::endl; return is_err; } else if (frame_rate_hz != newFrameRate) { frame_rate_hz = newFrameRate; } } std::cout << "Updated frame rate: " << ((auto_frame_rate) ? "auto" : to_string(frame_rate_hz)) << " Hz" << std::endl; return is_err; }
INT GetFrameRate( HIDS hCam, double &fr) { return is_SetFrameRate( hCam, IS_GET_FRAMERATE, &fr); }
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); }
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; }