uEye Camera Manual Version 4.90
![]() |
![]() |
USB 3 uEye XC XS |
USB 3 uEye XC XS |
Syntax
INT is_Focus (HIDS hCam, UINT nCommand, void *pParam, UINT nSizeOfParam)
Description
![]() |
This function is currently only supported by the camera models UI-3013XC and XS. |
Using is_Focus(), you can control the focus of the objective lens if supported by your uEye model.
For the XS, you can also use the focus measuring window for defining which area should be focused. The measuring window is divided into multiple zones. You can define a different weight for each zone. The size and position of the measuring window can be freely defined.
For the UI-3013XC, the zones of the focus measuring window are static and cannot be moved or re-sized. With the zones, you define the image area to be focused for the camera. The settings of the focus measuring window can only be used in snapshot mode. In live mode the camera always focuses on the image center.
The nCommand input parameter is used to select the function mode. The pParam input parameter depends on the selected function mode. If you select functions for setting or returning a value, pParam contains a pointer to a variable of the UINT type. The size of the memory area to which pParam refers is specified in the nSizeOfParam input parameter.
![]() |
According to the sensor manufacturer, there is no guarantee that a focal point set manually will lead to a reproducible focal distance. A focal value determined with one model will not necessarily result in the same focal point for a different model. |
Input parameters
hCam |
Camera handle |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pParam |
Pointer to a function parameter, whose function depends on nCommand. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nSizeOfParam |
Size (in bytes) of the memory area to which pParam refers. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Status flags from FOCUS_CAPABILITY_FLAGS
FOC_CAP_INVALID |
The camera does not support focus settings |
FOC_CAP_AUTOFOCUS_SUPPORTED |
The camera supports autofocus |
FOC_CAP_MANUAL_SUPPORTED |
The camera supports manual focus |
FOC_CAP_GET_DISTANCE |
The camera supports querying the focal distance |
FOC_CAP_SET_AUTOFOCUS_RANGE |
The camera supports the selection of the autofocus range |
FOC_CAP_AUTOFOCUS_ZONE |
The camera supports the use of the focus measuring window |
Return values
IS_CANT_COMMUNICATE_WITH_DRIVER |
Communication with the driver failed because no driver has been loaded. |
IS_CANT_OPEN_DEVICE |
An attempt to initialize or select the camera failed (no camera connected or initialization error). |
IS_INVALID_CAPTURE_MODE |
The function can not be executed in the current camera operating mode (free run, trigger or standby). |
IS_INVALID_CAMERA_HANDLE |
Invalid camera handle |
IS_INVALID_PARAMETER |
One of the submitted parameters is outside the valid range or is not supported for this sensor or is not available in this mode. |
IS_IO_REQUEST_FAILED |
An IO request from the uEye driver failed. Possibly the versions of the ueye_api.dll (API) and the driver file (ueye_usb.sys or ueye_eth.sys) do not match. |
IS_NO_SUCCESS |
General error message |
IS_NOT_SUPPORTED |
The camera model used here does not support this function or setting. |
IS_SUCCESS |
Function executed successfully |
UINT uiCaps = 0;
// Query if the camera supports autofocus
INT nRet = is_Focus (m_hCam, FDT_CMD_GET_CAPABILITIES, &uiCaps, sizeof (uiCaps) );
if (nRet == IS_SUCCESS && (uiCaps & FOC_CAP_AUTOFOCUS_SUPPORTED))
{
//If supported, enable autofocus
nRet = is_Focus (m_hCam, FOC_CMD_SET_ENABLE_AUTOFOCUS, NULL, 0);
}
// Trigger autofocus once
is_Focus(hCam, FOC_CMD_SET_ENABLE_AUTOFOCUS_ONCE, NULL, 0);
//Get autofocus status
INT nRet = 0;
INT nValue = 0;
nRet = is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_STATUS, (void*)&nValue, sizeof(nValue));
if (nValue == FOC_STATUS_FOCUSED)
{
…
}
/* set autofocus zone */
IS_RECT focusZoneRect;
focusZoneRect.s32X = 16;
focusZoneRect.s32Y = 16;
focusZoneRect.s32Width = 64;
focusZoneRect.s32Height = 64;
INT nRet = is_Focus(hCam, FOC_CMD_SET_AUTOFOCUS_ZONE_AOI, (void*)&focusZoneRect,
sizeof(focusZoneRect));
if (nRet == IS_SUCCESS)
{
...
}
/* get autofocus zone */
IS_RECT focusZoneRect;
INT nRet = is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_AOI, (void*)&focusZoneRect,
sizeof(focusZoneRect));
if (nRet == IS_SUCCESS)
{
...
}
/* receive min position */
IS_POINT_2D pointMin;
nRet = is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_POS_MIN, (void*)&pointMin, sizeof(pointMin));
/* receive max position */
IS_POINT_2D pointMax;
nRet = is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_POS_MAX, (void*)&pointMax, sizeof(pointMax));
Size
/* receive min size */
IS_SIZE_2D sizeMin;
is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_SIZE_MIN, (void*)&sizeMin, sizeof(sizeMin));
/* receive max size */
IS_SIZE_2D sizeMax;
is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_SIZE_MAX, (void*)&sizeMax, sizeof(sizeMax));
Gewichtung
/* receive zone count */
INT nFocusZoneCount;
nRet = is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_WEIGHT_COUNT, (void*)&nFocusZoneCount, sizeof(nFocusZoneCount));
/* receive current zone weights */
INT *pFocusZoneWeight = new INT[nFocusZoneCount];
nRet = is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_WEIGHT, (void*)pFocusZoneWeight, sizeof(INT) * nFocusZoneCount);
/* set focus zone weight for the left side */
pFocusZoneWeight[0] = FOC_ZONE_WEIGHT_STRONG;
pFocusZoneWeight[5] = FOC_ZONE_WEIGHT_STRONG;
pFocusZoneWeight[10] = FOC_ZONE_WEIGHT_STRONG;
pFocusZoneWeight[15] = FOC_ZONE_WEIGHT_STRONG;
pFocusZoneWeight[20] = FOC_ZONE_WEIGHT_STRONG;
/* set focus zone weights */
nRet = is_Focus(hCam, FOC_CMD_SET_AUTOFOCUS_ZONE_WEIGHT, (void*)pFocusZoneWeight,
sizeof(INT) * nFocusZoneCount);
// Set preset
int nPreset = FOC_ZONE_AOI_PRESET_BOTTOM_LEFT;
is_Focus(hCam, FOC_CMD_SET_AUTOFOCUS_ZONE_AOI_PRESET, &nPreset, sizeof(nPreset));
// Query preset
int nPreset;
is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_AOI_PRESET, &nPreset, sizeof(nPreset));
// Can the focus measuring window freely defined?
int nSupported;
is_Focus(hCam, FOC_CMD_GET_AUTOFOCUS_ZONE_ARBITRARY_AOI_SUPPORTED, &nSupported, sizeof(nSupported));
if (nSupported == 1)
{
…
}
Suggestion for improvement? Send us your short
Feedback on this chapter.
Thank you very much!
For technical questions please contact your local distributor or use the support form on our website.