FG Camera Library  1.5.0.0 (2023-09-08)
Handle camera and library

Detailed Description

Functions for management of cameras and the library.

Functions

UINT32 DLL_FG_API FG_get_camera_type (enum eFG_CAMERA_TYPE *camera_type)
 Returns the installed camera type. More...
 
UINT32 DLL_FG_API FG_get_last_error (char *error_sting, UINT32 max_string_size)
 Returns an error description for the last failed library call. More...
 
UINT32 DLL_FG_API FG_get_version (FG_VERSION *lib_version)
 Returns the library version. More...
 
UINT32 DLL_FG_API FG_install_camera (enum eFG_CAMERA_TYPE camera_type)
 Opens and initializes the camera. More...
 
UINT32 DLL_FG_API FG_uninstall_camera (void)
 Closes the camera. More...
 

Function Documentation

◆ FG_get_camera_type()

UINT32 FG_get_camera_type ( enum eFG_CAMERA_TYPE camera_type)

Returns the installed camera type.

This function is useful if automatic detection of the camera type was used when calling FG_install_camera() (e.g. FG_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO).

Parameters
camera_typePointer for storing the camera type
Returns
FG_ERROR_CODE_NoError (0) for success, other values indicate an error (see eFG_ERROR_CODE)

◆ FG_get_last_error()

UINT32 FG_get_last_error ( char *  error_sting,
UINT32  max_string_size 
)

Returns an error description for the last failed library call.

Note
  • This function can be called multiple times without clearing the error description.
  • The message should not be parsed by the application because the message text can change for new versions of the library.
  • Beginning with library version 1.4.0.0, error messages are stored for each thread separately. Therefore, this function must be called by the same thread as the function which failed.
  • Beginning with library version 1.4.0.0, the error message is updated for all types of errors, not only for FG_ERROR_CODE_ExtraErrorInformation.
Parameters
error_stingA pointer to a preallocated buffer, which contains a zero-terminated string after a successful call.
max_string_sizeThe total size of the passed buffer. The string will be truncated if the error message is too long.
Returns
FG_ERROR_CODE_NoError (0) for success, other values indicate an error (see eFG_ERROR_CODE)
Example:
The following helper function checks the result of a library function and throws an exception with the error description in case of an error.
void TestFGResultAndThrowException(UINT32 fgResult)
{
if (fgResult == FG_ERROR_CODE_NoError)
return;
{
char ErrText[500];
FG_get_last_error(ErrText, sizeof(ErrText));
throw std::runtime_error(ErrText);
}
else if (fgResult == FG_ERROR_CODE_InvalidArgument)
throw std::runtime_error("Invalid argument");
else if (fgResult == FG_ERROR_CODE_InvalidCameraChannel)
throw std::runtime_error("Invalid camera channel");
else if (fgResult == FG_ERROR_CODE_GrabTimeOut)
throw std::runtime_error("Acquisition timeout");
else if (fgResult == FG_ERROR_CODE_BrokenImage)
throw std::runtime_error("Image is broken");
else if (fgResult == FG_ERROR_CODE_Unknown)
throw std::runtime_error("Unknown error");
else
throw std::runtime_error(std::string("Unknown error code: ") + std::to_string(fgResult));
}
The helper function can then be used like follows:
try {
TestFGResultAndThrowException(FG_install_camera(FG_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO));
} catch (std::exception &err) {
printf("FG Camera function failed:\n%s\n", err.what());
}

◆ FG_get_version()

UINT32 FG_get_version ( FG_VERSION lib_version)

Returns the library version.

A short summary which features the dependencies can be found in the Introduction. But this library is part of a complete SDK and inside this you will find a release document which describes the changes from version to version in detail.

Parameters
lib_versionPointer for storing the libary version
// read and print the version
FG_VERSION lib_version;
if( FG_get_version(&lib_version) == FG_ERROR_CODE_NoError )
printf("\nuse FGCamera: \n - v%d.%d.%d.%d\n\n",
lib_version.major, lib_version.minor, lib_version.patchlevel, lib_version.buildnumber);
Returns
FG_ERROR_CODE_NoError (0) for success, other values indicate an error (see eFG_ERROR_CODE)

◆ FG_install_camera()

UINT32 FG_install_camera ( enum eFG_CAMERA_TYPE  camera_type)

Opens and initializes the camera.

This function must be used before other camera functions can be used. All sensor parameters are initialized with default values.

Parameters
camera_typeSelects the camera type to use. The value FG_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO can be used for automatic detection. Call FG_get_camera_type() to get the installed type.
Returns
FG_ERROR_CODE_NoError (0) for success, other values indicate an error (see eFG_ERROR_CODE)

◆ FG_uninstall_camera()

UINT32 FG_uninstall_camera ( void  )

Closes the camera.

Before calling this function, image acquisition should be stopped and all image buffers should be released, please refer to the example code.

Returns
FG_ERROR_CODE_NoError (0) for success, other values indicate an error (see eFG_ERROR_CODE)
FG_VERSION::minor
UINT8 minor
Minor version number.
Definition: FG_CameraInterface.h:165
FG_VERSION::patchlevel
UINT8 patchlevel
Patch level.
Definition: FG_CameraInterface.h:166
FG_VERSION::major
UINT8 major
Major version number.
Definition: FG_CameraInterface.h:164
FG_get_last_error
UINT32 DLL_FG_API FG_get_last_error(char *error_sting, UINT32 max_string_size)
Returns an error description for the last failed library call.
Definition: FG_CameraInterface.cpp:521
FG_install_camera
UINT32 DLL_FG_API FG_install_camera(enum eFG_CAMERA_TYPE camera_type)
Opens and initializes the camera.
Definition: FG_CameraInterface.cpp:282
FG_ERROR_CODE_GrabTimeOut
@ FG_ERROR_CODE_GrabTimeOut
Only valid for FG_get_image(): acquisition timeout.
Definition: FG_CameraInterface.h:133
FG_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO
@ FG_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO
IMAGO VisionCam/Sensor (automatic)
Definition: FG_CameraInterface.h:54
FG_get_version
UINT32 DLL_FG_API FG_get_version(FG_VERSION *lib_version)
Returns the library version.
Definition: FG_CameraInterface.cpp:544
FG_ERROR_CODE_BrokenImage
@ FG_ERROR_CODE_BrokenImage
Only valid for FG_get_image(): the returned image contents are invalid.
Definition: FG_CameraInterface.h:134
FG_ERROR_CODE_InvalidArgument
@ FG_ERROR_CODE_InvalidArgument
The function arguments are invalid.
Definition: FG_CameraInterface.h:131
FG_ERROR_CODE_InvalidCameraChannel
@ FG_ERROR_CODE_InvalidCameraChannel
The selected camera channel is invalid.
Definition: FG_CameraInterface.h:132
FG_ERROR_CODE_NoError
@ FG_ERROR_CODE_NoError
The function was successful.
Definition: FG_CameraInterface.h:129
FG_VERSION
struct for the library version "libFGCamera.so.major.minor.patchlevel.buildnumber"
Definition: FG_CameraInterface.h:163
FG_ERROR_CODE_ExtraErrorInformation
@ FG_ERROR_CODE_ExtraErrorInformation
Other errors, use FG_get_last_error() to obtain the error message.
Definition: FG_CameraInterface.h:135
FG_VERSION::buildnumber
UINT8 buildnumber
Build number.
Definition: FG_CameraInterface.h:167
FG_ERROR_CODE_Unknown
@ FG_ERROR_CODE_Unknown
Unknown error.
Definition: FG_CameraInterface.h:130