How to use the virtual driver

<< Click to Display Table of Contents >>

Navigation:  Image Manager > CVB Technology >

How to use the virtual driver

 

CVB Virtual Drivers

 

Mock.vin

The CVMock.vin virtual driver is a driver which can be loaded as .vin driver instead of a camera driver. It then either loads an image set or an EMU file from disk or generates its own image. In contrast to the EMU format, a wider range of device options is supported an can be accessed programatically. In this manner a camera device can be simulated for testing and coding without the actual device present. The driver can be found under %CVB%drivers. When the driver is loaded, first the working directory is checked for a valid CVMock.ini file. If none is found, the driver's configuration file from %CVBDATA%drivers is loaded.

The configuration file consists of sections containing a number of settings.

A section is defined in squared brackets.

Currently, two section types are used: Options and Board/Channel configuration.

Options :

Main settings to customize the driver for own image acquisition.

mockType defines the type of mock which should be performed by the driver

 0 -> Mock generated image. A scrolling bar is created by the driver itself.

 1 -> Load Emu file from loadPath. If .emu files with loadAtOnce = 0 (found in .emu settings file) are loaded, the buffer size is set to imgBuff which then mustn't be 0!

 2 -> Load image files from loadPath

loadPath location where images or .emu files to load are stored.

Shortcuts for the leading path component are available for:

         Environment strings:

              To utilize an environment string as a part of the path, use the

              respective name enclosed in percentage signs (%).

              E.g. %CVB%/tutorial

 

          Application directory:

              If the images are to be read from the application directory itself,

              @APPDIR is dynamically adapted to reference this path.

              E.g. @APPDIR/clara.bmp

 

frameRate displays images in frames per second, this value overrides the .emu's frame rate specified by the delay value.

imgPrefix name which is part of each image to be loaded e.g. to load all img in img001.bmp and img002.bmp set the imgPrefix either as regex img.*.bmp or img*.bmp

imgBuff amount of image buffers available to preloaded images. A value of 0 will load all available images at once except when loading from .emu which defines loadAtOnce on its own.

profileName=Default required for valid ini format.

 

BoardX_ChannelY :

Emulates a capturing devices board and channel with custom parameters. For this mockType=0, an image is created from the CVMock itself which will show a roll from minimum to maximum available pixel intensity depending on the selected buffer format. A Mono8 buffer format for example will produce a monochrome roll over the buffers ranging from 0 to 255 in value. This option will be loaded when mockType=0. Following parameters can be customized:

bufferWidth width of the buffer to allocate, similar to image width

bufferHeight height of the buffer to allocate, similar to image height

bufferFormat one of several predefined buffer formats according to the key:

0   -> Mono8 ramp pattern

1   -> RGB24 red ramp others 0

2   -> RGB24 green ramp others 0

3   -> RGB24 blue ramp others 0

4   -> Mon10 4 x Mono8 ramp

5   -> RGB30 4 x red ramp others 0

6   -> RGB30 4 x green ramp others 0

7   -> RGB30 4 x blue ramp others 0

8   -> Mon12 16 x Mono8 ramp

9   -> RGB36 16 x red ramp others 0

10  -> RGB36 16 x green ramp others 0

11  -> RGB36 16 x blue ramp others 0

bufferCount amount of buffers to allocate

bufferDelay delay time before next buffer is displayed in milliseconds. This corresponds to FrameRate = 1000/bufferDelay.

bufferRoll steps to advance between images for moving buffer. Overall 256 steps are available for all formats.

 

EMU Format

 

An EMU file is a simple text file defining a number of images to be loaded. Using the IGrabber interface the application can 'acquire' from the image list.

Of course all images must have the same size and the same number of planes.

The file consists of a number of sections containing a number of settings.

A section is defined in squared brackets.

Currently two sections are used : General and Files.

General :

Within General two settings are defined Delay and LoadAtOnce.

Delay defines the delay between two calls to the Snap function to simulate a frame rate in ms.

If LoadAtOnce is set to 0 the files will be loaded while grabbing. This means the hard disk will be accessed while grabbing, but only one image is loaded at a time.

This saves memory but implies permanent hard disk access.

Any other value will force the load of all images of the list at startup, meaning the load time plus the memory usage is at a maximum, but the frame rate can be set to a minimum by specifying a delay of 0 (increases speed but needs most memory).

Files :

The files to be used are defined in the Files section. Within the section you might define a number of files to be loaded using the FileX (X = {1...65535}) settings.
A file is specified by it's full path.
To use any environment string you can specify it's name with leading and tailing % (e.g. %CVB%).
To specify the application directory use @APPDIR. Use @LISTDIR to specify the directory of the EMU file.

 

Samples:

File1=%CVB%\Tutorial\*.bmp

File2=@APPDIR\clara.bmp

File3=@LISTDIR\rot*.bmp

 

The following is an example used to load all bitmap files from the directory of the EMU file starting with rot:

The example defines a frame time of 50ms and all images are loaded at startup.

[General]

Delay = 50

LoadAtOnce = 1

[Files]

File1 = @LISTDIR\rot*.bmp

 

Control via the Digital IO Control:

For control tasks like changing the frame rate the DigIO control of the EMU- driver has been used.

The two relevant methods of the DigIO control are:

 

SetOutDWORD

sets a delay in ms

DigIOControl.SetOutDWORD (0, lDelayValue, 0);

GetInDWORD

retrieves the actual delay value in ms

lDelayVlaue = DigIOControl.GetInDWORD (0);

 

The values for the Parameters Port and Mask are always 0.

 

Related Topics

None

 

Sample Code in VC

 

// load default EMU file

m_cvImg.SetFilename("%CVB%\\Tutorial\\ClassicSwitch.emu");

// set grab

m_cvImg.SetGrab(true);

// get current delay in ms

m_nDelay = m_cvDigIO.GetInDWORD(0);

// set new delay in ms

lDelayValue = 100

m_cvDigIO.SetOutDWORD(0, lDelayValue, 0);

 

 

Examples

Visual C++

VCEmu