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.

#include "stdafx.h"
#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 FPROCAP s_camCapabilities;
int main()
{
int32_t iResult;
uint32_t uiCapSize;
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
uiCapSize = sizeof(FPROCAP);
iResult = FPROSensor_GetCapabilities(s_iDeviceHandle, &s_camCapabilities, &uiCapSize);
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_camCapabilities.uiLowGain > 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_camCapabilities.uiLowGain;
pNewTable = new FPROGAINVALUE[s_camCapabilities.uiLowGain];
if (FPROSensor_GetGainTable(s_iDeviceHandle, 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;
// 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
// maintin the map between your list and this list you just received so you can properly
// set gain indeces using FPROSensor_SetGainIndex().
}
}
// Set the Low Gain to the second value in the list (index value of 1)
if (s_camCapabilities.uiLowGain >= 2)
{
// Set the gain index for the table
FPROSensor_SetGainIndex(s_iDeviceHandle, 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
FPROSensor_GetGainIndex(s_iDeviceHandle, FPRO_GAIN_TABLE_LOW_CHANNEL, &uiGainIndex);
}
}
}
// Close up shop
iResult = FPROCam_Close(s_iDeviceHandle);
}
}
return 0;
}