Users Manual – svs4021, svs2020,svs2050, svs2051, svs1020, svs1050, svs285, svs340, svs625
p. 69
Last Update 20.07.2009
StreamingChannel_delete(StreamingChannel);
Between opening and closing the streaming channel an application specific
callback function will be called for every image that the camera has captured. It
is up to the application to process the image further in that callback function.
17.10.5
Receiving images in a callback function
It is important that the application defines the callback function as
__stdcall
in
order to make sure that the arguments are passed through correctly.
SVGigE_RETURN __stdcall ImageCallback(Image_handle Image, void* Context);
The
Context
argument will have the same value as it was provided by the
application when creating the streaming channel. It can be used for example for
establishing a reference to the object that is expected to receive that image
stream in one of its member functions.
In the
Image
parameter the application will find a handle to the just captured
camera image. That handle will be used to query all needed information about
the image from the SVGigE DLL. The image handle is valid only inside the
current call to the callback function. Any use of an image handle at a time will
always result in receiving an error code back from the function that was tried.
Thus the usual way for further image processing is to query all interesting
information inside the callback function and to copy that information into a
structure that remains accessible to the application after returning from the
callback function.
IMAGE_INFO *ImageInfo = new IMAGE_INFO;
ImageInfo->ImageData = Image_getDataPointer(Image);
ImageInfo->SizeX
= Image_getSizeX(Image);
ImageInfo->SizeY
= Image_getSizeY(Image);
ImageInfo->PixelType = Image_getPixelType(Image);
ImageInfo->ImageID
= Image_getImageID(Image);
The newly allocated structure can be posted for example by a Windows
message to a function that is responsible for displaying the image or for further
image processing.
17.10.6
Processing image data
Once an image has been forwarded by a callback function to a specific
processing function the image data will be worked on. Usually the camera has
already started capturing a subsequent image at the time when a previous
image is processed. This requires working with at least two image buffers in
order to avoid overwriting data that is being processed by a subsequent image
acquisition process.
The higher the delay between image acquisition and image processing becomes
the more buffer might be needed for avoiding any conflicts. The number of
needed buffers has to be estimated based on the specific runtime conditions.
The resulting number will be passed to the GigE driver as an argument when
creating a streaming channel. The driver will allocate that number of buffers
where each buffer will have enough space for holding one complete image.
An image processing function will operate for example based on the following
parameters:
ImageInfo->ImageData
ImageInfo->SizeX
ImageInfo->SizeY
The
ImageData
pointer will be a reference to a buffer that was allocated by the
driver from persistent kernel memory and which address is mapped to user
space. The application is responsible for not violating the boundary that is given
by the product of the
SizeX
and
SizeY
parameters.
In case of color images that are coded as bayer pattern the SVGigE API offers a
function for converting those images to a RGB format. The appropriate
conversion needs to be done inside the callback function.