示例#1
0
//////////////////////////////////////////////////////////////////////////////////
// calculateMaxAOI ---------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
void ofxUeye::calculateMaxAOI()
{
	bool wasLive = bLive;
	if (wasLive) disableLive();
	// Maximize AOI
	int curBinning = _binning;
	int curSubSampling = _subSampling;
	double curScaler = _scaler;
	is_SetBinning (m_hCam, IS_BINNING_DISABLE);
	is_SetSubSampling (m_hCam, IS_SUBSAMPLING_DISABLE);
	is_SetSensorScaler (m_hCam, IS_ENABLE_SENSOR_SCALER | IS_ENABLE_ANTI_ALIASING, 1.0);
	IS_RECT fullAOI;
	fullAOI.s32X = 0;
	fullAOI.s32Y = 0;
	fullAOI.s32Width = _sensorWidth;
	fullAOI.s32Height = _sensorHeight;
	is_AOI(m_hCam, IS_AOI_IMAGE_SET_AOI, (void*)&fullAOI, sizeof(fullAOI));
	is_SetBinning (m_hCam, curBinning);
	is_SetSubSampling (m_hCam, curSubSampling);
	is_SetSensorScaler (m_hCam, IS_ENABLE_SENSOR_SCALER | IS_ENABLE_ANTI_ALIASING, curScaler);

	// Get the maximum AOI in the current binning, sub sampling and scaler
	IS_SIZE_2D maxAOI;
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_SIZE_MAX, (void*)&maxAOI, sizeof(maxAOI));
	_AOIMax.x = 0;
	_AOIMax.y = 0;
	_AOIMax.width = (float)maxAOI.s32Width;
	_AOIMax.height = (float)maxAOI.s32Height;
	if (wasLive) enableLive();
}
示例#2
0
const int CameraApi::width() const
{
	IS_RECT rect;
	is_AOI(mhCam, IS_AOI_IMAGE_GET_AOI, &rect, sizeof(rect));

	return rect.s32Width;
}
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;
}
示例#4
0
//////////////////////////////////////////////////////////////////////////////////
// updateDimensions --------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
void ofxUeye::updateDimensions()
{
	bool wasLive = bLive;
	if (wasLive) disableLive();
	
	// Get current and maximum AOI
	IS_RECT  curAOI; 
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_AOI, (void*)&curAOI, sizeof(curAOI));
	calculateMaxAOI();

	// Update dimensions that might have changed
	_AOI.x = curAOI.s32X;
	_AOI.y = curAOI.s32Y;
	_AOI.height = curAOI.s32Height;
	_AOI.width = curAOI.s32Width;

	_AOINormalized.x = _AOI.x / _AOIMax.width;
	_AOINormalized.y = _AOI.y / _AOIMax.height;
	_AOINormalized.width = _AOI.width / _AOIMax.width;
	_AOINormalized.height = _AOI.height / _AOIMax.height;

	_width = curAOI.s32Width;
	_height = curAOI.s32Height;

	// reallocate our pixels for the new size
	if(_pixels != NULL) delete _pixels;
	_pixels = new unsigned char [_width*_height*_channels];
	if (wasLive) enableLive();
		
	// Notify that the dimensions has changed
	ofNotifyEvent(events.dimensionChanged, events.voidEventArgs);
}
示例#5
0
const int CameraApi::height() const
{
	IS_RECT rect;
	is_AOI(mhCam, IS_AOI_IMAGE_GET_AOI, &rect, sizeof(rect));

	return rect.s32Height;
}
INT GetImageSize(HIDS m_hCam, INT &xSze, INT &ySze)
{
	IS_RECT rectAOI;
	INT nRet = is_AOI(m_hCam, IS_AOI_IMAGE_GET_AOI, (void*)&rectAOI, sizeof(rectAOI));
	if (nRet == IS_SUCCESS) {
		xSze = rectAOI.s32Width;
		ySze = rectAOI.s32Height;
	}
	return IS_SUCCESS;
}
示例#7
0
void CameraApi::getAoi(int &left, int &top, int &width, int &height)
{
	IS_RECT nowAoi;
	is_AOI(mhCam, IS_AOI_IMAGE_GET_AOI, &nowAoi, sizeof(nowAoi));

	left = nowAoi.s32X;
	top = nowAoi.s32Y;
	width = nowAoi.s32Width;
	height = nowAoi.s32Height;
}
/* Image size functions */
INT GetImagePos(HIDS m_hCam, INT &xPos, INT &yPos)
{ 
	IS_RECT rectAOI;
	INT nRet = is_AOI(m_hCam, IS_AOI_IMAGE_GET_AOI, (void*)&rectAOI, sizeof(rectAOI));
	if (nRet == IS_SUCCESS) {
		xPos = rectAOI.s32X;
		yPos = rectAOI.s32Y;
	}
	return IS_SUCCESS; 
}
///////////////////////////////////////////////////////////////////////////////
//
// METHOD CIdsSimpleLiveDlg::InitDisplayMode() 
//
// DESCRIPTION: - initializes the display mode
//
///////////////////////////////////////////////////////////////////////////////
int InitDisplayMode(HIDS* m_hCam)
{
    INT result = IS_SUCCESS;
    INT		nColorMode;	// Y8/RGB16/RGB24/REG32
    if (m_hCam == NULL) {
		return IS_NO_SUCCESS;
	}
	
	// Get sensor info
	SENSORINFO m_sInfo;			// sensor information struct
	is_GetSensorInfo(*m_hCam, &m_sInfo);

    if (m_pcImageMemory != NULL) {
        is_FreeImageMem( *m_hCam, m_pcImageMemory, m_lMemoryId );
    }
    m_pcImageMemory = NULL;

	// Set display mode to DIB
    result = is_SetDisplayMode(*m_hCam, IS_SET_DM_DIB);
	if (m_sInfo.nColorMode == IS_COLORMODE_BAYER) {
		// setup the color depth to the current windows setting
        is_GetColorDepth(*m_hCam, &m_nBitsPerPixel, &nColorMode);
    } else if (m_sInfo.nColorMode == IS_COLORMODE_CBYCRY) {
        // for color camera models use RGB32 mode
        nColorMode = IS_CM_RGB8_PACKED;
        m_nBitsPerPixel = 32;
    } else {
        // for monochrome camera models use Y8 mode
        nColorMode = IS_CM_MONO8;
        m_nBitsPerPixel = 8;
    }

    // allocate an image memory.
    if (is_AllocImageMem(*m_hCam, m_nSizeX, m_nSizeY, m_nBitsPerPixel, &m_pcImageMemory, &m_lMemoryId ) != IS_SUCCESS) {
        AfxMessageBox(TEXT("Memory allocation failed!"), MB_ICONWARNING );
    } else {
		is_SetImageMem( *m_hCam, m_pcImageMemory, m_lMemoryId );
	}

    if (result == IS_SUCCESS) {
        // set the desired color mode
        result = is_SetColorMode(*m_hCam, nColorMode);
		// Sets the position and size of the image by using an object of the IS_RECT type.
		IS_RECT rectAOI;
		rectAOI.s32X     = 0;
		rectAOI.s32Y     = 0;
		rectAOI.s32Width = m_nSizeX;
		rectAOI.s32Height = m_nSizeY;
		result |= is_AOI(*m_hCam, IS_AOI_IMAGE_SET_AOI, (void*)&rectAOI, sizeof(rectAOI));
    }   
    return result;
}
示例#10
0
void CameraApi::setAoi(int X, int Y, int width, int height)
{
	IS_RECT nowAoi;
	is_AOI(mhCam, IS_AOI_IMAGE_GET_AOI, &nowAoi, sizeof(nowAoi));

	if(X == F_CAM_IGNORE_PARAMETER)
		X = nowAoi.s32X;
	if(Y == F_CAM_IGNORE_PARAMETER)
		Y = nowAoi.s32Y;
	if(width == F_CAM_IGNORE_PARAMETER)
		width = nowAoi.s32Width;
	if(height == F_CAM_IGNORE_PARAMETER)
		height = nowAoi.s32Height;

	IS_RECT rectAoi;
	rectAoi.s32X = X;
	rectAoi.s32Y = Y;
	rectAoi.s32Width = width;
	rectAoi.s32Height = height;

	is_AOI(mhCam, IS_AOI_IMAGE_SET_AOI, &rectAoi, sizeof(rectAoi));
}
INT UEyeCamDriver::setResolution(INT& image_width, INT& image_height,
                                 INT& image_left, INT& image_top,
                                 bool reallocate_buffer) {
    if (!isConnected())
        return IS_INVALID_CAMERA_HANDLE;

    INT is_err = IS_SUCCESS;

    // Validate arguments
    CAP(image_width, 8, (INT ) cam_sensor_info_.nMaxWidth);
    CAP(image_height, 4, (INT ) cam_sensor_info_.nMaxHeight);
    if (image_left >= 0 && (int) cam_sensor_info_.nMaxWidth - image_width
                           - image_left
                           < 0) {
        std::cerr << "Cannot set image left index to " << image_left
                  << " with an image width of " << image_width
                  << " and sensor max width of " << cam_sensor_info_.nMaxWidth
                  << std::endl;
        image_left = -1;
    }
    if (image_top >= 0 && (int) cam_sensor_info_.nMaxHeight - image_height - image_top < 0) {
        std::cerr << "Cannot set image top index to " << image_top
                  << " with an image height of " << image_height
                  << " and sensor max height of " << cam_sensor_info_.nMaxHeight << std::endl;
        image_top = -1;
    }
    cam_aoi_.s32X =
            (image_left < 0) ?
                    (cam_sensor_info_.nMaxWidth - image_width) / 2 : image_left;
    cam_aoi_.s32Y =
            (image_top < 0) ?
                    (cam_sensor_info_.nMaxHeight - image_height) / 2 : image_top;
    cam_aoi_.s32Width = image_width;
    cam_aoi_.s32Height = image_height;
    if ((is_err = is_AOI(cam_handle_, IS_AOI_IMAGE_SET_AOI, &cam_aoi_, sizeof(cam_aoi_)))
        != IS_SUCCESS) {
        std::cerr << "Failed to set UEye camera sensor's Area Of Interest to "
                  << image_width << " x " << image_height
                  << " with top-left corner at (" << cam_aoi_.s32X << ", "
                  << cam_aoi_.s32Y << ")" << std::endl;
        return is_err;
    }

    std::cout << "Updated resolution to " << image_width << " x "
              << image_height << " @ (" << image_left << ", " << image_top
              << ")" << std::endl;

    return (reallocate_buffer ? reallocateCamBuffer() : IS_SUCCESS);
}
INT UEyeCamDriver::loadCamConfig(string filename) {
    if (!isConnected())
        return IS_INVALID_CAMERA_HANDLE;

    INT is_err = IS_SUCCESS;

    // Convert filename to unicode, as requested by UEye API
    const wstring filenameU(filename.begin(), filename.end());
    if ((is_err = is_ParameterSet(cam_handle_, IS_PARAMETERSET_CMD_LOAD_FILE,
                                  (void*) filenameU.c_str(), 0))
        != IS_SUCCESS) {
        std::cerr << "Could not load UEye camera '" << cam_name_
                  << "' sensor parameters file " << filename << " ("
                  << err2str(is_err) << ")" << std::endl;
        return is_err;
    } else {
        // Update the AOI and bits per pixel
        if ((is_err = is_AOI(cam_handle_, IS_AOI_IMAGE_GET_AOI,
                             (void*) &cam_aoi_, sizeof(cam_aoi_)))
            != IS_SUCCESS) {
            std::cerr
                    << "Could not retrieve Area Of Interest from UEye camera '"
                    << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl;
            return is_err;
        }
        INT colorMode = is_SetColorMode(cam_handle_, IS_GET_COLOR_MODE);
        if (colorMode == IS_CM_BGR8_PACKED || colorMode == IS_CM_RGB8_PACKED) {
            bits_per_pixel_ = 24;
        } else if (colorMode == IS_CM_MONO8 || colorMode == IS_CM_SENSOR_RAW8) {
            bits_per_pixel_ = 8;
        } else {
            std::cerr
                    << "Current camera color mode is not supported by this wrapper;"
                    << "supported modes: {MONO8 | RGB8 | BAYER_RGGB8}; switching to RGB8 (24-bit)"
                    << std::endl;
            if ((is_err = setColorMode("rgb8", false)) != IS_SUCCESS)
                return is_err;
        }

        reallocateCamBuffer();

        std::cout << "Successfully loaded UEye camera '" << cam_name_
                  << "'s sensor parameter file: " << filename << std::endl;
    }

    return is_err;
}
示例#13
0
bool FlosIDSAdaptor::openDevice()
{
    if(isOpen()) { 
        return true;
    }

    INT nRet = is_InitCamera(&m_deviceID, NULL);

    if(nRet != IS_SUCCESS) {
        if(nRet == IS_STARTER_FW_UPLOAD_NEEDED) {
            return false;
        }
    } else {
        IS_SIZE_2D  imageSize;
        INT		    lMemoryId;
        char       *pcImageMemory;

        is_AOI(m_deviceID, IS_AOI_IMAGE_GET_SIZE, (void *)&imageSize, sizeof(imageSize));
        
        for(unsigned int i = 0; i < 25; i++) {
            is_AllocImageMem(m_deviceID, imageSize.s32Width, imageSize.s32Height, 24, &pcImageMemory, &lMemoryId);
            is_AddToSequence(m_deviceID, pcImageMemory, lMemoryId);
            is_SetImageMem(m_deviceID, pcImageMemory, lMemoryId);
        }

        if(is_InitImageQueue(m_deviceID, 0) != IS_SUCCESS) {
            imaqkit::adaptorWarn("FlosIDSAdaptor:openDevice","Something went wrong while allocating memory.");
            return false;
        }
    }

    m_acquireThread = CreateThread(NULL, 0, acquireThread, this, 0, &m_acquireThreadID);
    
    if(m_acquireThread == NULL) {
        closeDevice();
        return false;
    }
 
    while(PostThreadMessage(m_acquireThreadID, WM_USER + 1, 0, 0) == 0) {
        Sleep(10);
    }

    return true;
}
示例#14
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;
}
示例#15
0
static int ids_core_Camera_setaoi(ids_core_Camera *self, PyObject *set_tuple) {
    int ret;
    IS_RECT r = {
        .s32X      = PyLong_AsLong(PyTuple_GetItem(set_tuple, 0)),
        .s32Y      = PyLong_AsLong(PyTuple_GetItem(set_tuple, 1)),
        .s32Width  = PyLong_AsLong(PyTuple_GetItem(set_tuple, 2)),
        .s32Height = PyLong_AsLong(PyTuple_GetItem(set_tuple, 3))
    };

    ret = is_AOI(self->handle, IS_AOI_IMAGE_SET_AOI, &r, sizeof(r));
    switch (ret) {
        case IS_SUCCESS:
            return 0;
            break;
        default:
            PyErr_SetString(PyExc_ValueError, "An error occurred when setting AOI status.");
            return -1;
    }
}

static PyObject *ids_core_Camera_getclockrange(ids_core_Camera *self, void *closure) {
    int ret;
    UINT r[3];
    PyObject *ret_tuple = PyTuple_New(3);
    ZeroMemory(r, sizeof(r));

    ret = is_PixelClock(self->handle, IS_PIXELCLOCK_CMD_GET_RANGE, &r, sizeof(r));
    switch (ret) {
        case IS_SUCCESS:
            PyTuple_SetItem(ret_tuple, 0, PyLong_FromLong(r[0]));
            PyTuple_SetItem(ret_tuple, 1, PyLong_FromLong(r[1]));
            PyTuple_SetItem(ret_tuple, 2, PyLong_FromLong(r[2]));
            return ret_tuple;
        default:
            PyErr_SetString(PyExc_ValueError, "An error occurred when getting clock range.");
            return PyLong_FromLong(-1);
    }
}
void mexFunction( int nlhs, mxArray *plhs[],int nrhs, const mxArray*prhs[] )
{        

    /* Check for proper number of arguments */
    if (!(nrhs == 2)) 
    {   
        mexErrMsgTxt("You have to give me two inputs"); 
    } 
    
    if (!mxIsStruct(prhs[1]))
    {
        mexErrMsgTxt("That second input has to be an image structure, you know.");
    }
    
    int error = 0;
    int BitsPerPixel = 8;
    HCAM hCam = *(HCAM *)mxGetPr(prhs[0]);
    
    //Freeze the video feed for frame grab to prevent split frames
    error = is_FreezeVideo( hCam, IS_WAIT );
    if (error !=IS_SUCCESS)
    {   
       mexErrMsgTxt("Error freezing video");  
    }  
    
    int image_field = mxGetFieldNumber(prhs[1],"image");
    int pointer_field = mxGetFieldNumber(prhs[1],"pointer");
    int ID_field = mxGetFieldNumber(prhs[1],"id");

    mxArray *p_output_image = mxGetFieldByNumber(prhs[1],0,image_field);
    char *p_output = (char *)mxGetPr(p_output_image);
    
    mxArray *ppointer_field = mxGetFieldByNumber(prhs[1],0,pointer_field);
    char *p_image = (char *)*(int *)mxGetPr(ppointer_field);
    
    mxArray *pID_field = mxGetFieldByNumber(prhs[1],0,ID_field);
    int *ID = (int *)mxGetPr(pID_field); 
           
    error =  is_CopyImageMem (hCam, p_image, *ID, p_output);
    if (error !=IS_SUCCESS)
    {   
       mexErrMsgTxt("Error copying image data to output");  
    }
    
    //If a variable is supplied on the LHS, use it to output image frame data
    if (nlhs == 1)
    {
    IS_RECT rectAOI;
    INT nX, nY;
    error = is_AOI(hCam, IS_AOI_IMAGE_GET_AOI, (void*)&rectAOI, sizeof(rectAOI));
    if (error == IS_SUCCESS)
    {
    nX = rectAOI.s32Width;
    nY = rectAOI.s32Height;
    }

        mxArray *p_output_image_new = mxCreateNumericMatrix(nX, nY, mxUINT8_CLASS, mxREAL);
        p_output = (char *)mxGetPr(p_output_image_new);           
        error =  is_CopyImageMem (hCam, p_image, *ID, p_output);
        if (error !=IS_SUCCESS)
        {   
           mexErrMsgTxt("Error copying image data to output");  
        }
        
        //Set mex function output
        plhs[0] = p_output_image_new;
    
    } 
    return;   
}
示例#17
0
//////////////////////////////////////////////////////////////////////////////////
// setAOI ------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
int ofxUeye::setAOI(ofRectangle aoi)
{
	bool wasLive = bLive;
	if (wasLive) disableLive();
	// We need to request a native aoi, otherwise it will fail, it requeire a couple of steps to get it right...

	// Update the curent max AOI
	calculateMaxAOI();
	
	// Clamp the desired AOI to safe values;
	ofClamp(aoi.width, 0, _AOIMax.width);
	ofClamp(aoi.height, 0, _AOIMax.height);
	ofClamp(aoi.x,	0, (_AOIMax.width - aoi.width));
	ofClamp(aoi.y, 0, (_AOIMax.height - aoi.height));

	IS_RECT newAOI;
	newAOI.s32X = aoi.x;
	newAOI.s32Y = aoi.y;
	newAOI.s32Width = aoi.width;
	newAOI.s32Height = aoi.height;

	// Round the size value to a valid increment
	IS_SIZE_2D sizeInc; 
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_SIZE_INC, (void*)&sizeInc, sizeof(sizeInc));

	newAOI.s32Width = (newAOI.s32Width / sizeInc.s32Width) * sizeInc.s32Width;
	newAOI.s32Height = (newAOI.s32Height / sizeInc.s32Height) * sizeInc.s32Height;

	// Clamp size to min and max accepted by the sensor
	IS_SIZE_2D minSize; 
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_SIZE_MIN, (void*)&minSize, sizeof(minSize));
	IS_SIZE_2D maxSize; 
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_SIZE_MAX, (void*)&maxSize, sizeof(maxSize));

	ofClamp(newAOI.s32Width, minSize.s32Width, maxSize.s32Height);
	ofClamp(newAOI.s32Height, minSize.s32Height, maxSize.s32Height);

	// Now we are sure the size is valid, so we apply it in order to be abble get the max and min values for the position
	IS_RECT newAOISize;
	newAOISize.s32X = 0;
	newAOISize.s32Y = 0;
	newAOISize.s32Width = newAOI.s32Width;
	newAOISize.s32Height = newAOI.s32Height;
	is_AOI( m_hCam, IS_AOI_IMAGE_SET_AOI, (void*)&newAOISize, sizeof(newAOISize));

	// Round the position value to a valid increment
	IS_SIZE_2D posInc; 
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_POS_INC, (void*)&posInc, sizeof(posInc));

	newAOI.s32X = (newAOI.s32X / posInc.s32Width) * posInc.s32Width;
	newAOI.s32Y = (newAOI.s32Y / posInc.s32Height) * posInc.s32Height;

	// Clamp position to min and max accepted by the sensor
	IS_POINT_2D minPos; 
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_POS_MIN, (void*)&minPos, sizeof(minPos));
	IS_POINT_2D maxPos; 
	is_AOI(m_hCam, IS_AOI_IMAGE_GET_POS_MAX, (void*)&maxPos, sizeof(maxPos));
	ofClamp(newAOI.s32X, minPos.s32X, maxPos.s32X);
	ofClamp(newAOI.s32Y, minPos.s32Y, maxPos.s32Y);

	// As the AOI change will make the camera irresponsive for a while, we need to flag as NOT ready for thread safety
	bReady = false;

	// Apply the AOI
	int result;
	result = is_AOI( m_hCam, IS_AOI_IMAGE_SET_AOI, (void*)&newAOI, sizeof(newAOI));
	if(result == IS_SUCCESS) {
		updateDimensions();
		ofLog(OF_LOG_WARNING, "ofxUeye - setAOI - (%f, %f, %f, %f) Success.", _AOI.x, _AOI.y, _AOI.width, _AOI.height);
	}
	else {
		if(bVerbose)
			ofLog(OF_LOG_WARNING, "ofxUeye - setAOI - Couldn't apply (%i, %i, %i, %i) value.", newAOI.s32X, newAOI.s32Y, newAOI.s32Width, newAOI.s32Height);
	}
	if (wasLive) enableLive();

	return result;
}