VKL - Videokernel Library- Overview and Release Notes -first revision from October 2006 based on getsequence v3.1rc and videofileload v3.1rc created by Stefan Weisse Table of Contents
OverviewThe video kernel library was designed for users of the PITZ Video System in order to be able to use the core functions of it. Included functionality is taking frames using socket connection, loading and saving of own image file formats (IMM, IMC, BKG, BKC) and applying certain algorithms, like creating average and envelope background, calculating significance mask and applying x-ray filtering. The library was written in such a way that it is instantaneously possible to use it on Linux32, Linux64, Win32 and ROOT (32 and 64 bit) platforms. It may work on any other Little-Endian based platform with little adjustments. Big Endian (e.g. Sun) platform support is not done. This may change as it is requested by user demands. To not be confused by the terminology, one should know that the term library in this document means a set of source code and header files to be used on many platforms. One may create by hand a shared library (.so) for Scientific Linux 3 (SL3) or a shared library (.dll) for Windows operating system using Visual C++ v6. These steps are not provided. The examples for Linux and Windows show how to integrate the main source and include files into example projects. Cross-platform compatibility is met by definition of data types (to be independent of 32 / 64 bit compilers) and by encapsulating certain functions inside platform.c and platform.h. For ROOT v4/v5 a makefile in order to create a shared library for using the functions inside ROOT C interpreter (CINT) is provided as example. The library is expected to compile and link without any error on Linux, ROOT (v4, v5) and Windows. It was tested with Visual C++ V6 SP6, GCC on Scientific Linux 3 (SL3) and using ROOT v4.02.00 under Linux (SL3). The flawless execution on a 64-bit platform was tested under Linux. Note: The library is only compatible with platforms that use Little-Endian byte ordering, like Intel X86 processors. Sourcecode has to be changed in certain positions if the library is going to be used on Solaris (e.g. using SPARC CPUs with Big-Endian byte ordering). Directory Contents
Linux (gcc on SL3)
Using the supplied makefile getsequence.mak (make -f getsequence.mak) one should be able to compile the
example code without errors or warnings on SL3. The result will be an executable file getsequence which
should be working. Root v4/v5 on Linux
Using the supplied makefile rootlib.mak (make -f rootlib.mak) one should be able to compile the example root
library without errors or warnings on SL3. It is a good idea to clean the current directory first
(make -f rootlib.mak clean). It might be possible that the makefile needs to be adjusted (see commented-out
ROOTSYS line and PLATFORM line) if the ROOTSYS variable is missing in the environment or points to a wrong installation.
The second makefile (rootlibd.mak) creates a library (videokernelD.sl) with debug info. This code was tested and proved
to be working on ROOT_64 under 64-bit Linux. The result of making will be a root shared library file
videokernel.sl which can be loaded into Root interpreter and tested by using the following sequence: $> root root [0] gSystem->Load("videokernel.sl"); root [1] .X rootexample.CXX root [2] .X rootexample_vfl.CXX Note: The example code inside rootexample.CXX is shown for reference and may not work (just because the test server to acquire frames from is not running by accident). For rootexample_vfl.CXX the proper input file (see source) must be located at the appropriate directory. Windows (MS Visual C++ v6)
After starting MS Visual C++ v6, one should load in the workspace file "getsequence.dsw". All pathes
should be relative so directly compiling and linking without any warning or error should be no problem.
The library and the provided example code was written to compile and link without a single error
even at highest warning level !
If this does not work, one may check the include pathes as well as the output pathes for
correctness. It is also a good advise to check the supplied files for read-only attribute and
clear it in case it is set.
The result will be an executable file getsequence.exe which should be working. API reference
Variable type mappings typedef int INT32; typedef unsigned int UINT32; typedef double DOUBLE; typedef char CHAR; typedef unsigned char UCHAR; typedef unsigned short UINT16; typedef signed short INT16; typedef void VOID; typedef void * VOIDP; typedef unsigned long uLong; typedef unsigned char Byte; #define Bytef Byte #define uLongf uLongIn order to meet certain platform independent criterias, C variable data types are mapped to unique names inside the programming interface. All types are wrapped by #ifndef / #endif in case the types are already defined. It is unknown what might happen if other types are mapped to variable types listed above. Pay attention! The second block is required for zlib compression support in IMC and BKC files. You are encouraged to use the first block when defining your own variables because it will give advantages of a certain degree of platform independence. You must not use the second block for defining your own variables, it is just documented here for completeness. Type reference #define TYPE_NONE_EMPTY -1 #define TYPE_CHOOSE 0 #define TYPE_IMM 1 #define TYPE_IMC 2 #define TYPE_BKG 3 #define TYPE_BKC 4 #define TYPE_SIGNIFICANCE 5These types are used to set and define the file types. TYPE_NONE_EMPTY is used to declare a VIDINFHDR to be empty. #define FCN_NONE 0 #define FCN_AVERAGE 1 #define FCN_ENVELOPE 2 #define FCN_SIGNIFICANCE 3These types are used to pass appropriate a downscale function when converting a multiple image buffer to BKG file format. Structure reference struct VIDINFHDR { UINT32 width; UINT32 height; UINT32 bpp; UINT32 bpp_effective; DOUBLE scale; INT32 numframes; INT32 type; // TYPE_ VOID **framebits; DOUBLE *framescales; }; The structure VIDINFHDR is used in memory to describe and define a set of single images that were loaded from a file or are about to be saved. The parameters are explained in detail:
In principle an image set is defined that all images have the same width, height, bpp, bpp_effective and scale values. The value scale is used as an easy way to access the scale value. The framescales values are only used for the sake of completeness and all of them should contain the same value as scale !
A one-dimensional array is the physical representation of the two-dimensional image data.
The data is organized inside the array in the following scheme: Function reference void initialize_vidinfhdr( struct VIDINFHDR *vinf );
This function is used to preinitialize a VIDINFHDR structure that was just defined. One must call
it in order to use the structure afterwards. void free_vidinfhdr( struct VIDINFHDR *vinf );
This function is used to deinitialize a VIDINFHDR structure that was used throughout the program.
One must call it in order to free memory and clean up things after using the structure ! INT32 load_file( INT32 type, const CHAR *filename, struct VIDINFHDR *vinf ); This function loads in any file type (with file name filename) created by the video system into the VIDINFHDR structure vinf. The type of the file is specified by passing the appropriate type of the file, either a proper TYPE_XXX if one knows the file format or TYPE_CHOOSE and the function will detect the filetype based on the extension of the passed filename parameter. The structure vinf needs to be initialized first and it needs to be empty. The return values and their meanings are:
INT32 load_imm_file( const CHAR *filename, struct VIDINFHDR *vinf ); This function loads in the IMM file filename into the VIDINFHDR structure vinf. The structure needs to be initialized first and it needs to be empty. The return values and their meanings are:
INT32 load_bkg_file( const CHAR *filename, struct VIDINFHDR *vinf ); This function loads in the BKG file filename into the VIDINFHDR structure vinf. The structure needs to be initialized first and it needs to be empty. The return values and their meanings are:
INT32 load_imc_bkc_file( const CHAR *filename, struct VIDINFHDR *vinf, INT32 type); This function loads in either an IMC or a BKC file filename into the VIDINFHDR structure vinf. The type of the file is specified by passing the appropriate type of the file, either TYPE_IMC or TYPE_BKC respectively. The structure needs to be initialized first and it needs to be empty. The return values and their meanings are:
INT32 load_imc_file( const CHAR *filename, struct VIDINFHDR *vinf ); This function loads in the IMC file filename into the VIDINFHDR structure vinf. The structure needs to be initialized first and it needs to be empty. The return values and their meanings are:
INT32 load_bkc_file( const CHAR *filename, struct VIDINFHDR *vinf ); This function loads in the BKC file filename into the VIDINFHDR structure vinf. The structure needs to be initialized first and it needs to be empty. The return values and their meanings are:
INT32 save_file( INT32 type, const CHAR *filename, const struct VIDINFHDR *vinf ); This function saves an image file (given by filename) out of the structure vinf (VIDINFHDR). One has to choose the type by itself (specify the right type, e.g. TYPE_IMM) or pass TYPE_CHOOSE. If TYPE_CHOOSE is passed, the contents of vinf (type field in structure) are checked and stored to a proper image file. In this case, the file extension is appended automatically inside the function after the file type was chosen. The image data inside the structure vinf will be checked for validity, e.g. a BKG file can only contain a single frame. The parameters and their meanings are:
INT32 save_imm_file( const CHAR *filename, const struct VIDINFHDR *vinf ); This function writes the image data inside a passed vinf (VIDINFHDR) into a newly created IMM file with name 'filename'. The parameters and their meanings are:
INT32 save_bkg_file( const CHAR *filename, const struct VIDINFHDR *vinf ); This function writes the image data inside a passed vinf (VIDINFHDR) into a newly created BKG file with name 'filename'. The parameters and their meanings are:
INT32 save_bkc_file( const CHAR *filename, const struct VIDINFHDR *vinf ); This function writes the image data inside a passed vinf (VIDINFHDR) into a newly created BKC file with name 'filename'. The parameters and their meanings are:
INT32 save_imc_file( const CHAR *filename, const struct VIDINFHDR *vinf ); This function writes the image data inside a passed vinf (VIDINFHDR) into a newly created IMC file with name 'filename'. The parameters and their meanings are:
INT32 grabframes( const CHAR *servername, const UINT16 net_port, UINT32 num_frames, struct VIDINFHDR *vinf); In order to acquire frames from any GrabServer2 program running, one should use this function. It is blocking and returns if either one of the error conditions is met or all frames have been acquired successfully. The parameters are:
The return values and their meanings are:
Remarks: Any error after a successful connection attempt alters the vinf structure. INT32 convert_format( struct VIDINFHDR *vinf, UINT32 newtype, UINT32 downscale_function); This function is used to conveniently convert between different formats inside a VIDINFHDR. Most conversions are lossless, however, conversion of a VIDINFHDR with multiple images to FILE_BKG will be lossy because a downscale function is required and will be used. The parameters are:
Remarks: INT32 calculate_significance_map( const struct VIDINFHDR *sig_and_back, const struct VIDINFHDR *back, struct VIDINFHDR *out, double sigma); This function can be used to calculate a so-called significance map of two sets of matching frames (signal and background images). In case of no error, the resulting VIDINFHDR out will contain a single image with the same physical bpp as sig_and_back and back. A value of 0 means that the signal value at that position should be masked out (not significant). A value of 1 means that the signal value at that position should not be masked out (significant data). Using sigma (default value is 1.0) one is able to increase the significance of RMS of noise. Sigma is used as a factor to RMS. The bigger sigma gets, the more the rms of noise will increase and thus, more parts of the signal might be filtered out. The parameters are:
Remarks: INT32 xrayfilter( struct VIDINFHDR *vinout ); Using this function one is able to apply x-ray filtering like the Video Client 2 does to a single frame or sets of frames. If this function is successful, it is lossy. The old data available inside vinout will no longer be available. It was overwritten. The parameters are:
|
Last modified: October 27, 2006 |