FG Camera Library
Loading...
Searching...
No Matches
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.
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.
UINT32 DLL_FG_API FG_get_version (FG_VERSION *lib_version)
 Returns the library version.
UINT32 DLL_FG_API FG_install_camera (enum eFG_CAMERA_TYPE camera_type,...)
 Opens and initializes the camera.
UINT32 DLL_FG_API FG_uninstall_camera (void)
 Closes the camera.

Function Documentation

◆ FG_get_camera_type()

UINT32 DLL_FG_API 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 DLL_FG_API 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));
}
@ FG_ERROR_CODE_InvalidArgument
The function arguments are invalid.
Definition FG_CameraInterface.h:148
@ FG_ERROR_CODE_NoError
The function was successful.
Definition FG_CameraInterface.h:146
@ FG_ERROR_CODE_Unknown
Unknown error.
Definition FG_CameraInterface.h:147
@ FG_ERROR_CODE_ExtraErrorInformation
Other errors, use FG_get_last_error() to obtain the error message.
Definition FG_CameraInterface.h:152
@ FG_ERROR_CODE_BrokenImage
Only valid for FG_get_image(): the returned image contents are invalid.
Definition FG_CameraInterface.h:151
@ FG_ERROR_CODE_GrabTimeOut
Only valid for FG_get_image(): acquisition timeout.
Definition FG_CameraInterface.h:150
@ FG_ERROR_CODE_InvalidCameraChannel
The selected camera channel is invalid.
Definition FG_CameraInterface.h:149
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:600
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_CAMERA_TYPE_X_X_IMAGO_Vxx_AUTO
IMAGO VisionCam/Sensor (automatic)
Definition FG_CameraInterface.h:54
UINT32 DLL_FG_API FG_install_camera(enum eFG_CAMERA_TYPE camera_type,...)
Opens and initializes the camera.
Definition FG_CameraInterface.cpp:278

◆ FG_get_version()

UINT32 DLL_FG_API 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);
UINT32 DLL_FG_API FG_get_version(FG_VERSION *lib_version)
Returns the library version.
Definition FG_CameraInterface.cpp:623
struct for the library version "libFGCamera.so.major.minor.patchlevel.buildnumber"
Definition FG_CameraInterface.h:180
UINT8 minor
Minor version number.
Definition FG_CameraInterface.h:182
UINT8 buildnumber
Build number.
Definition FG_CameraInterface.h:184
UINT8 major
Major version number.
Definition FG_CameraInterface.h:181
UINT8 patchlevel
Patch level.
Definition FG_CameraInterface.h:183
Returns
FG_ERROR_CODE_NoError (0) for success, other values indicate an error (see eFG_ERROR_CODE)

◆ FG_install_camera()

UINT32 DLL_FG_API FG_install_camera ( enum eFG_CAMERA_TYPE camera_type,
... )

Opens and initializes the camera.

This function must be called 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.
...For GigE cameras, the function expects a 32-bit value containing the device's IPv4 address.
Returns
FG_ERROR_CODE_NoError (0) for success, other values indicate an error (see eFG_ERROR_CODE)

◆ FG_uninstall_camera()

UINT32 DLL_FG_API 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)