How to build and run the first example program
This document requires the user to have successfully walked through the "Getting Started Guide" for logging into the command line of the device. A basic understanding of using the Linux command line is also required.
IMAGO delivers the VisionCam and VisionSensor with a pre-installed Debian Linux root filesystem including development tools like the GNU GCC compiler and the Make utility. Additionally, the IMAGO SDK package provides the required kernel modules and libraries. In order to build and run the example program, there is no need to install or configure anything else.
The example program FGExample_Linux demonstrates the use of the library and can be used with the VisionSensor PV and the VisionCam XM. The source code is located at the following SDK directory:
/opt/ImagoTechnologies/SDK/examples/FGExample_Linux
The example directory contains a Makefile which uses the required library and compiler settings for building the program:
-I/opt/ImagoTechnologies/SDK/include
-L/opt/ImagoTechnologies/SDK/lib/
-lFGCamera
First, copy the source code to your home directory and build the project with 'make':
After successful build, the program can be started:
The console output should look like this:
The program can be stopped by pressing CTRL-C.
The following steps describe the typical workflow for using the library:
The example source code is located at /opt/ImagoTechnologies/SDK/examples/FGExample_Linux/src/main.c
The FG Camera library provides a single header file to the user: FG_CameraInterface.h
It's possible to specify the desired hardware and sensor type when opening the interface. The function will fail if the specified type is not available. For sensor independent applications, there is an autodetection type available which is used below:
After opening the interface, some basic parameters are configured. Most of them have default values and are therefore optional. But for better readability we suggest setting them explicitly. For almost every set-function there is also a get-function for reading parameters:
The API provides functions for image buffer allocation and management. It's important to note that buffer access is only allowed if the user is the owner. After a buffer is added to the acquisition queue with FG_append_image(), access is forbidden until it's returned to the user by FG_get_image(), or until image acquisition is stopped with FG_stop_image().
The code below shows the buffer allocation and the start of acquisition by adding the buffers to the ready queue:
The function FG_get_image() is used to wait for new images. After success, the function returns the given FG_Image structure with the next valid image buffer and the ownership is transferred back to the user. The example code doesn't implement any image processing, but the pixel buffer can be accessed using the pointer pixel_ptr:
After the user has finished processing the buffer contents, it can be put back to the ready queue by calling FG_append_image(). Please note that ownership of the buffer is also transfered to the user in case of the error value FG_ERROR_CODE_BrokenImage (parital valid image).
After calling FG_stop_image(), all previously allocated buffers can be released and the interface can be closed: