Streaming and Using HW Merge Example Code.
This example shows you how to create a streaming application that uses the hardware merging capabilities on host the PCIE Fibre card.
#include "stdint.h"
#include "stdlib.h"
#include "stdio.h"
#if defined(_WIN32) || defined(_WINDOWS)
#include "windows.h"
#else
#include "unistd.h"
#include "string.h"
#endif
#include "wchar.h"
#define FLI_TEST_MAX_SUPPORTED_CAMERAS (4)
static int32_t SetFrameInfo(int32_t iDeviceHandle);
static int32_t CheckReferenceMetaData(FILE* pFile);
static int32_t SendHWMergeReferenceFiles(int32_t iHandle, const char* pDSNUFileName, const char* pPRNUFileName, uint32_t uiWidth, uint32_t uiHeight);
static int32_t s_iDeviceHandle;
uint32_t uiNumDetectedDevices;
static FPRODEVICEINFO s_camDeviceInfo[FLI_TEST_MAX_SUPPORTED_CAMERAS];
#define STREAMER_PATH_MAX (1024)
static wchar_t s_wcStreamerPath[STREAMER_PATH_MAX];
static wchar_t s_wcStreamerPrefix[STREAMER_PATH_MAX];
int main()
{
int32_t iResult;
uiNumDetectedDevices = FLI_TEST_MAX_SUPPORTED_CAMERAS;
if ((iResult >= 0) && (uiNumDetectedDevices > 0))
{
s_iDeviceHandle = -1;
iResult =
FPROCam_Open(&s_camDeviceInfo[0], &s_iDeviceHandle);
if ((iResult >= 0) && (s_iDeviceHandle >= 0))
{
if (iResult >= 0)
iResult = SetFrameInfo(s_iDeviceHandle);
}
}
return 0;
}
{
int32_t iResult;
uint32_t uiFramSizeInBytes;
uint32_t uiNumFrames;
if (iResult >= 0)
{
if (iResult >= 0)
{
uiNumFrames = 10;
#if defined(_WIN32) || defined(_WINDOWS)
wcscpy_s(s_wcStreamerPath, STREAMER_PATH_MAX, L"./StreamerFiles");
wcscpy_s(s_wcStreamerPrefix, STREAMER_PATH_MAX, L"myFiles");
#else
wcscpy(s_wcStreamerPath, L"./StreamerFiles");
wcscpy(s_wcStreamerPrefix, L"myFiles");
#endif
if (iResult >= 0)
{
if (iResult >= 0)
{
while ((iResult >= 0) &&
{
#if defined(_WIN32) || defined(_WINDOWS)
Sleep(1000);
#else
sleep(1);
#endif
fflush(stdout);
}
printf("\n");
{
printf("Stream Error\n");
}
}
}
}
}
}
int32_t
SetFrameInfo(int32_t iDeviceHandle)
{
int32_t iResult;
iResult = 0;
if (iResult >= 0)
if (iResult >= 0)
return(iResult);
}
int32_t CheckReferenceMetaData(FILE* pFile)
{
int32_t iResult;
size_t uiBytesRead;
uint32_t uiMetaSize;
uint32_t uiFileSize;
uint8_t uiMetaCheck[6];
iResult = -1;
fseek(pFile, 0L, SEEK_END);
uiFileSize = ftell(pFile);
fseek(pFile, 0L, SEEK_SET);
#if defined(_WIN32) || defined(_WINDOWS)
uiBytesRead = fread_s(uiMetaCheck, 6, 1, 6, pFile);
#else
uiBytesRead= fread(uiMetaCheck, 1, 6, pFile);
#endif
if (uiBytesRead == 6)
{
if ((uiMetaCheck[0] == 'M') && (uiMetaCheck[1] == 'e') && (uiMetaCheck[2] == 't') && (uiMetaCheck[3] == 'a'))
{
uiMetaSize = ((uint32_t)uiMetaCheck[4] & 0xFF) << 8;
uiMetaSize |= (uint32_t)uiMetaCheck[5] & 0xFF;
if (uiMetaSize < uiFileSize)
{
iResult = 0;
fseek(pFile, uiMetaSize, SEEK_SET);
}
}
}
return(iResult);
}
int32_t SendHWMergeReferenceFiles(int32_t iHandle, const char* pDSNUFileName, const char* pPRNUFileName, uint32_t uiWidth, uint32_t uiHeight)
{
int32_t iResult;
FILE* pDSNUFile;
FILE* pPRNUFile;
uint32_t uiFrameSize;
size_t uiBytesRead;
iResult = 0;
memset(&refFrames, 0, sizeof(refFrames));
pDSNUFile = NULL;
pPRNUFile = NULL;
if (pDSNUFileName)
{
#if defined(_WIN32) || defined(_WINDOWS)
fopen_s(&pDSNUFile, pDSNUFileName, "r+b");
#else
pDSNUFile= fopen(pDSNUFileName, "r+b");
#endif
iResult = CheckReferenceMetaData(pDSNUFile);
}
if ((pPRNUFileName) && (iResult >= 0))
{
#if defined(_WIN32) || defined(_WINDOWS)
fopen_s(&pPRNUFile, pPRNUFileName, "r+b");
#else
pPRNUFile= fopen(pPRNUFileName, "r+b");
#endif
iResult = CheckReferenceMetaData(pPRNUFile);
}
if (iResult >= 0)
{
iResult = 0;
if (pDSNUFile)
{
{
uiFrameSize = uiWidth * uiHeight * sizeof(uint16_t);
#if defined(_WIN32) || defined(_WINDOWS)
uiBytesRead = fread_s(refFrames.
pAdditiveLowGain, uiFrameSize, 1, uiFrameSize, pDSNUFile);
#else
#endif
if (uiBytesRead != uiFrameSize)
iResult = -1;
if (iResult >= 0)
{
#if defined(_WIN32) || defined(_WINDOWS)
uiBytesRead = fread_s(refFrames.
pAdditiveHighGain, uiFrameSize, 1, uiFrameSize, pDSNUFile);
#else
#endif
if (uiBytesRead != uiFrameSize)
iResult = -1;
}
}
}
if (pPRNUFile)
{
{
if (iResult >= 0)
{
#if defined(_WIN32) || defined(_WINDOWS)
#else
#endif
if (uiBytesRead != uiFrameSize)
iResult = -1;
}
if (iResult >= 0)
{
#if defined(_WIN32) || defined(_WINDOWS)
#else
#endif
if (uiBytesRead != uiFrameSize)
iResult = -1;
}
}
}
if (iResult >= 0)
{
}
if (pDSNUFile)
fclose(pDSNUFile);
if (pPRNUFile)
fclose(pPRNUFile);
}
return(iResult);
}
Finger Lakes Instrumentation Camera API.
LIBFLIPRO_API FPROAlgo_SetHardwareMergeEnables(int32_t iHandle, FPRO_HWMERGEENABLE mergeEnables)
Enable/disable hardware merging options.
LIBFLIPRO_API FPROFrame_StreamDeinitialize(int32_t iHandle)
Deinitializes the Streamer interfaces.
LIBFLIPRO_API FPROAlgo_SetHardwareMergeReferenceFiles(int32_t iHandle, const wchar_t *pDSNUFile, const wchar_t *pPRNUFile)
Sets the reference frames used in PCIE Fibre hardware image merging.
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.
LIBFLIPRO_API FPROAlgo_SetHardwareMergeReferenceFrames(int32_t iHandle, FPRO_REFFRAMES *pRefFrames)
Sets the reference frames used in PCIE Fibre hardware image merging.
FPRO_IMAGE_FORMAT
Output Frame Formats for image merging and conversion.
Definition: libflipro.h:1349
@ IFORMAT_RCD
FLI native RCD Frame.
Definition: libflipro.h:1351
@ IFORMAT_TIFF
TIFF Formatted image.
Definition: libflipro.h:1352
LIBFLIPRO_API FPROFrame_StreamInitialize(int32_t iHandle, uint32_t uiFrameSizeBytes, wchar_t *pRootPath, wchar_t *pFilePrefix)
Initializes the Streamer interfaces.
LIBFLIPRO_API FPROFrame_StreamStart(int32_t iHandle, uint32_t uiFrameCount, uint64_t uiFrameIntervalMS)
Start the streaming operation.
LIBFLIPRO_API FPROFrame_StreamStop(int32_t iHandle)
Stop the streaming operation.
LIBFLIPRO_API FPROFrame_ComputeFrameSize(int32_t iHandle)
Computes the size in bytes of the image frame.
LIBFLIPRO_API FPROCtrl_SetExposure(int32_t iHandle, uint64_t uiExposureTime, uint64_t uiFrameDelay, bool bImmediate)
Sets the exposure time of the image sensor.
FPRO_HWMERGEFRAMES
Enables for Hardware Image Merging.
Definition: libflipro.h:1564
@ HWMERGE_FRAME_HIGHONLY
Only the corrected high gain pixels will be sent through to the API. The low gain pixels will be igno...
Definition: libflipro.h:1567
@ HWMERGE_FRAME_BOTH
Normal merge, both low and high gain planes are corrected and merged.
Definition: libflipro.h:1565
@ HWMERGE_FRAME_LOWONLY
Only the corrected low gain pixels will be sent through to the API. The high gain pixels will be igno...
Definition: libflipro.h:1566
LIBFLIPRO_API FPROFrame_SetImageArea(int32_t iHandle, uint32_t uiColOffset, uint32_t uiRowOffset, uint32_t uiWidth, uint32_t uiHeight)
Sets the area of the image sensor to be used to produce image frame data.
@ FPRO_STREAMER_STOPPED
Streaming Stopped. This is the default state. It also enters this state when the requested number of ...
Definition: libflipro.h:1142
@ FPRO_STREAMER_STOPPED_ERROR
If streaming has stopped due to an error, the status will be less than 0. Consult the log file for er...
Definition: libflipro.h:1141
LIBFLIPRO_API FPROCam_GetCameraList(FPRODEVICEINFO *pDeviceInfo, uint32_t *pNumDevices)
FPROCam_GetCameraList.
LIBFLIPRO_API FPROFrame_StreamGetStatistics(int32_t iHandle, FPROSTREAMSTATS *pStats)
Stop the streaming operation.
Definition: libflipro.h:365
Definition: libflipro.h:1184
FPROSTREAMERSTATUS iStatus
The status of the streamer. See FPROSTREAMERSTATUS.
Definition: libflipro.h:1192
uint64_t uiDiskFramesWritten
The total number of frames written to disk.
Definition: libflipro.h:1187
Definition: libflipro.h:1607
FPRO_IMAGE_FORMAT eMergeFormat
The image file format for the merged image. The Actual PCIE card only supports RCD and TIFF....
Definition: libflipro.h:1609
FPRO_HWMERGEFRAMES eMergeFrames
Specifies the frames to merge.
Definition: libflipro.h:1610
bool bMergeEnable
True if merging enabled. This must be true for the other enables to have any effect....
Definition: libflipro.h:1608
Definition: libflipro.h:1321
uint16_t * pMultiplicativeLowGain
Low Gain Multiply Reference Frame.
Definition: libflipro.h:1327
int16_t * pAdditiveHighGain
High Gain Additive Reference Frame.
Definition: libflipro.h:1326
int16_t * pAdditiveLowGain
Low Gain Additive Reference Frame.
Definition: libflipro.h:1325
uint32_t uiWidth
Width of the frames in pixels.
Definition: libflipro.h:1322
uint32_t uiHeight
Height of the frames in pixels.
Definition: libflipro.h:1323
uint16_t * pMultiplicativeHighGain
High Gain Multiply Reference Frame.
Definition: libflipro.h:1328