Please enable JavaScript to view this site.

IDS Software Suite 4.96.1

Windows_Logo
Linux_Logo

USB 2.0

USB 3.x

GigE

USB 2.0

USB 3.x

GigE

Syntax

INT is_Measure(HIDS hCam, UINT nCommand, void* pParam, UINT cbSizeOfParam)

Description

The function allows the measurement of the sharpness in a defined AOI of the current image. To get a sharpness value the edges in the image are evaluated. The sharpness can only be indicated as a relative value as it depends on the edges in the current image. An image with less edges will not reach the sharpness value of an image with a lot of edges.

The higher the value, the better the sharpness. The value can be used in comparative measurements to detect changes in the image acquisition of the same object, e.g. caused by readjusted lenses.

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 cbSizeOfParam input parameter.

Input parameters

hCam

Camera handle

pParam

Pointer to a function parameter, whose function depends on nCommand.

cbSizeOfParam

Size (in bytes) of the memory area to which pParam refers.

Content of the MEASURE_SHARPNESS_INFO structure

UINT

u32NumberAOI

ID of the AOI

UINT

u32SharpnessValue

Relative sharpness value in the defined AOI

IS_RECT

rcAOI

Position and size of the AOI:

s32X: X position

s32Y: Y position

s32Width: AOI width

s32Height: AOI height

CHAR*

pcImageMem

Start address of the image buffer to be used for the calculation.

If pcImageMem is valid, the selected buffer is used. If pcImageMem == NULL or invalid, the active image buffer is used for the calculation.

Content of the MEASURE_SHARPNESS_AOI_PRESETS enumeration

IS_MEASURE_SHARPNESS_AOI_PRESET_1

Predefined AOI for the sharpness measurement (5 AOIs, in each of the four image corners and in the center, each of the 5 AOIs has a size of 1/3 x "total image width" and 1/3 x "total image height")

Content of the MEASURE_SHARPNESS_AOI_PRESETS enumeration

IS_MEASURE_SHARPNESS_AOI_PRESET_1

Predefined AOI for the sharpness measurement (in each of the four image corner and in the center)

Content of the MEASURE_SHARPNESS_CALCULATION_ALGORITHM enumeration

IS_MEASURE_SHARPNESS_CALCULATION_ALGORITHM_TENENGRAD

Tenengrad - contrast-based sharpness algorithm (convolution)

IS_MEASURE_SHARPNESS_CALCULATION_ALGORITHM_MEAN_SCORE

Mean Score - contrast-based sharpness algorithm (mean value)

IS_MEASURE_SHARPNESS_CALCULATION_ALGORITHM_HISTOGRAM_VARIANCE

Varianz - statistics-based sharpness algorithm

IS_MEASURE_SHARPNESS_CALCULATION_ALGORITHM_SOBEL

Sobel - contrast-based sharpness algorithm (convolution) / default setting

Return values

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_NO_ACTIVE_IMG_MEM

No active image memory available. You must set the memory to active using the is_SetImageMem() function or create a sequence using the is_AddToSequence() function.

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

Example 1

INT nRet = IS_SUCCESS;
 
/* Create info object */
MEASURE_SHARPNESS_INFO measureSharpnessInfo;
 
/* Set values of AOI_0: The position and size of the AOI equals the whole image */
measureSharpnessInfo.u32NumberAOI   = 0;
measureSharpnessInfo.rcAOI.s32X     = 0;
measureSharpnessInfo.rcAOI.s32Y     = 0;
measureSharpnessInfo.rcAOI.s32Width = m_s32MaxImageWidth;
measureSharpnessInfo.rcAOI.s32Height = m_s32MaxImageHeight;
 
/* Set AOI_0 */
nRet = is_Measure(m_hCam, IS_MEASURE_CMD_SHARPNESS_AOI_SET, (void*)&measureSharpnessInfo, sizeof(measureSharpnessInfo));
 
/* Set values of AOI_1 */
measureSharpnessInfo.u32NumberAOI   = 1;
measureSharpnessInfo.rcAOI.s32X     = 50;
measureSharpnessInfo.rcAOI.s32Y     = 50;
measureSharpnessInfo.rcAOI.s32Width = 200;
measureSharpnessInfo.rcAOI.s32Height = 200;
 
/* Set AOI_1 */
nRet = is_Measure(m_hCam, IS_MEASURE_CMD_SHARPNESS_AOI_SET, (void*)&measureSharpnessInfo, sizeof(measureSharpnessInfo));

Example 2

INT nRet = IS_SUCCESS;
 
/* Create algorithm info object */
MEASURE_SHARPNESS_CALCULATION_ALGORITHM measureSharpnessAlgorithm = IS_MEASURE_SHARPNESS_CALCULATION_ALGORITHM_HISTOGRAM_VARIANCE;
 
nRet = is_Measure(m_hCam, IS_MEASURE_CMD_SHARPNESS_CALCULATION_ALGORITHM_SET, (void*)&measureSharpnessAlgorithm, sizeof(measureSharpnessAlgorithm));

Example 3

INT nRet = IS_SUCCESS;
 
/* Create info object */
MEASURE_SHARPNESS_INFO measureSharpnessInfo;
 
/* Get values of AOI_0 */
measureSharpnessInfo.u32NumberAOI = 0;
 
/* Get sharpness of active image memory */
measureSharpnessInfo.pcImageMem = NULL;
 
nRet = is_Measure(m_hCam, IS_MEASURE_CMD_SHARPNESS_AOI_INQUIRE, (void*)&measureSharpnessInfo, sizeof(measureSharpnessInfo));
if (nRet == IS_SUCCESS)
{
float fSharpness = measureSharpnessInfo.fSharpnessValue;
}

Example 4

INT nRet = IS_SUCCESS;
 
/* Set preset */
UINT nPreset = IS_MEASURE_SHARPNESS_AOI_PRESET_1;
 
nRet = is_Measure(m_hCam, IS_MEASURE_CMD_SHARPNESS_AOI_SET_PRESET, (void*)&nPreset, sizeof(nPreset));

© 2022 IDS Imaging Development Systems GmbH