FLI libflipro API
CapabilitiesAndGainTables.cpp

Illustrates working with Capabilities and The Gain Tables.
This example shows you how to retrieve the Camera Capabilities from the device and extract the Gain Table information.

#if defined(_WIN32) || defined(_WINDOWS)
#include "stdafx.h"
#else
#include <stdio.h>
#endif
#include "stdint.h"
#include "stdlib.h"
#include "libflipro.h"
#define FLI_TEST_MAX_SUPPORTED_CAMERAS (4)
// Static Function declarations
// Static Data declarations
static int32_t s_iDeviceHandle;
uint32_t uiNumDetectedDevices;
static FPRODEVICEINFO s_camDeviceInfo[FLI_TEST_MAX_SUPPORTED_CAMERAS];
static uint32_t s_uiCaps[(uint32_t)FPROCAPS::FPROCAP_NUM];
int main()
{
int32_t iResult;
uint32_t uiCapNum;
uint32_t uiGainEntries;
uint32_t uiGainIndex;
float fGainValue;
FPROGAINVALUE *pNewTable;
// first get the list of available devices
uiNumDetectedDevices = FLI_TEST_MAX_SUPPORTED_CAMERAS;
iResult = FPROCam_GetCameraList(s_camDeviceInfo, &uiNumDetectedDevices);
if ((iResult >= 0) && (uiNumDetectedDevices > 0))
{
// Open the first device in the list
s_iDeviceHandle = -1;
iResult = FPROCam_Open(&s_camDeviceInfo[0], &s_iDeviceHandle);
if ((iResult >= 0) && (s_iDeviceHandle >= 0))
{
// Get the Camera Capabilities
uiCapNum = (uint32_t)FPROCAPS::FPROCAP_NUM;
iResult = FPROSensor_GetCapabilityList(s_iDeviceHandle,s_uiCaps, &uiCapNum);
if (iResult >= 0)
{
// Now that you have the capabilities information, you could populate a GUI with
// the pertinent information like drop down lists or max image sizes etc.
// Here we show you how to get the gain tables and set an index
// Each camera will have a set of gain tables for Low Gain Channel, High Gain Channel.
// The fields uiLowGain, and uiHighGain hold the number of entries in their respective table.
// If the entry is 0, the table does not exist for this camera.
// Note also that the High Gain Channel is used for the high gain image obtained in LDR modes.
// The Low Gain Channel is used for the low gain image in HDR modes.
if (s_uiCaps[(uint32_t)FPROCAPS::FPROCAP_LOW_GAIN_TABLE_SIZE] > 0)
{
// First make sure you have allocated enough memory for the gain table you
// would like to retrieve- here we are getting the LDR Table. Each entry is
// a FPROGAINVALUE structure so we allocate an array of FPROGAINVALUE.
uiGainEntries = s_uiCaps[(uint32_t)FPROCAPS::FPROCAP_LOW_GAIN_TABLE_SIZE];
pNewTable = new FPROGAINVALUE[uiGainEntries];
if (FPROSensor_GetGainTable(s_iDeviceHandle, FPROGAINTABLE::FPRO_GAIN_TABLE_LOW_CHANNEL, pNewTable, &uiGainEntries) >= 0)
{
// now that you have the table entries you can process them
for (uint32_t i = 0; i < uiGainEntries; ++i)
{
// Each gain value is scaled by the camera to produce an integer. To return the value
// to a floating point representation, apply the scale factor
fGainValue = (float)pNewTable[i].uiValue / (float)FPRO_GAIN_SCALE_FACTOR;
#if defined(_WIN32) || defined(_WINDOWS)
#else
printf("Gain index %d: %.4f\n",i, fGainValue);
#endif
// Here you could populate a drop down list for a GUI with the Gain value.
// Be aware that the gain values are set by there index in the table (pNewTable[i].uiDeviceIndex)
// just retrieved. So you could populate a GUI drop down list, but just make sure to
// maintain the map between your list and this list you just received so you can properly
// set gain indices using FPROSensor_SetGainIndex().
}
}
// Set the Low Gain to the second value in the list (index value of 1)
if (s_uiCaps[(uint32_t)FPROCAPS::FPROCAP_LOW_GAIN_TABLE_SIZE] >= 2)
{
// Set the gain index for the table
FPROSensor_SetGainIndex(s_iDeviceHandle, FPROGAINTABLE::FPRO_GAIN_TABLE_LOW_CHANNEL, pNewTable[1].uiDeviceIndex);
// Read it back- should be the same as what you set..
// This is not required for proper operation, just being shown
// for example purposes
}
}
}
// Close up shop
iResult = FPROCam_Close(s_iDeviceHandle);
}
}
return 0;
}
Finger Lakes Instrumentation Camera API.
LIBFLIPRO_API FPROSensor_GetCapabilityList(int32_t iHandle, uint32_t *pCapList, uint32_t *pNumCaps)
Retrieves the capabilities list for the connected camera.
#define FPRO_GAIN_SCALE_FACTOR
Gain Scale Factor.
Definition: libflipro.h:726
LIBFLIPRO_API FPROCam_Open(FPRODEVICEINFO *pDevInfo, int32_t *pHandle)
Connects to the camera specified by the pDevInfo parameter.
LIBFLIPRO_API FPROCam_Close(int32_t iHandle)
Disconnects from the camera an releases the handle.
@ FPROCAP_NUM
Number of supported capabilities.
Definition: libflipro.h:877
@ FPROCAP_LOW_GAIN_TABLE_SIZE
Number of Gain Values (Low Gain channel for low gain frame in HDR Modes)
Definition: libflipro.h:866
@ FPRO_GAIN_TABLE_LOW_CHANNEL
Low Gain Channel used for Low Gain images in HDR modes.
Definition: libflipro.h:752
LIBFLIPRO_API FPROSensor_SetGainIndex(int32_t iHandle, FPROGAINTABLE eTable, uint32_t uiGainIndex)
Sets the current setting for the Gain for the specified table.
LIBFLIPRO_API FPROSensor_GetGainIndex(int32_t iHandle, FPROGAINTABLE eTable, uint32_t *pGainIndex)
Retrieves the current setting for the Gain for the specified table.
LIBFLIPRO_API FPROCam_GetCameraList(FPRODEVICEINFO *pDeviceInfo, uint32_t *pNumDevices)
FPROCam_GetCameraList.
LIBFLIPRO_API FPROSensor_GetGainTable(int32_t iHandle, FPROGAINTABLE eTable, FPROGAINVALUE *pGainValues, uint32_t *pNumEntries)
Retrieves the specified Gain Table.
Definition: libflipro.h:365
Definition: libflipro.h:775