You are here: Start » AVL.NET » AVL.NET - AVL Relation

AVL.NET - AVL Relation

Overview

AVL.NET is an AVL wrapper which means that when we call AVL.NET functions, we actually call native AVL functions. That requires the AVL.dll library to be present in the same location as the AvlNet.dll assembly when running the application that references AvlNet.dll assembly.

Functions

In .NET a function must be a member of some type (which makes it a method rather than a function). Therefore while in AVL functions may be accessed through the namespace only (e.g. avl::AddImages(...)), in AVL.NET all the library functions are static methods of the AVL class:


using AvlNet;
...

Image image1, image2;
... //obtain image1 and image2 values
Image imageSum;
...



Types

Most of the native AVL types have their counterpart in the AvlNet.dll assembly, which are native AVL type wrappers. Internally, a managed type contains a native pointer to the AVL type and because of those native pointers (unmanaged resources), objects of those types need to be disposed properly when not used any more to avoid memory leaks. This is guaranteed thanks to the System.IDisposable interface but it is the user's responsibility to call it's Dispose method to release resources immediately instead of leaving it to the next Garbage Collection. This may increase the application performance.

Optionals and Conditionals

There is no AVL.NET-specific optional/conditional wrapper for AVL's atl::Optional and atl::Conditional types. Instead atl::NIL values can be assigned just like null values in the .NET framework, i.e. through wrapping a T type with System.Nullable<T> for value types and direct assignment for reference types.

The table below lists AVL.NET equivalents of most important AVL types:

AVL TypeAVL.NET Type
avl::Image
AvlNet.Image
atl::Optional<avl::Image>
atl::Conditional<avl::Image>
avl::Region
AvlNet.Region
atl::Optional<avl::Region>
atl::Conditional<avl::Region>
float
float
atl::Optional<float>
System.Nullable<float>
atl::Conditional<float>
atl::Optional<int>
System.Nullable<int>
atl::Conditional<int>
atl::Optional<atl::Point2D>
System.Nullable<AvlNet.Point2D>
atl::Conditional<atl::Point2D>

The same type for regular and optional/conditional values in case of reference types (e.g. AvlNet.Image) has an important impact on function behavior when passing such a value as a function parameter. Passing null as a parameter that expects a non-NIL value will result in throwing ArgumentNullException. Such a situation takes place for example in AddChannels function:

void AddChannels
(
const avl::Image& inImage,
atl::Optional<const avl::Region&> inRoi,
avl::Image& outImage
)


(
AvlNet.Image inImage,
AvlNet.Region inRoi,
out AvlNet.Image outImage
)



Passing null for inRoi is completely legal and makes AddChannels perform on the entire image, while passing null for inImage is not and will result in throwing ArgumentNullException.

Settings

There are such options that may control the functions behavior as diagnostic mode, SSE acceleration, parallel computing, etc. Most of them can also be modified in AVL.NET with Settings class.

AVLAVL.NET
void avl::EnableSSEAcceleration(bool enable)
AvlNet.Settings.IsSSEEnabled setter
bool avl::GetSSEAccelerationEnabled()
AvlNet.Settings.IsSSEEnabled getter
void avl::SetParallelComputing(bool enabled, int num_threads)
AvlNet.Settings.IsParallelComputingEnabled setter

AvlNet.Settings.ParallelComputingThreadCount setter
int avl::GetParallelComputingThreadsCount()
AvlNet.Settings.ParallelComputingThreadCount getter
void avl::EnableAvlDiagnosticOutputs(bool enable)
AvlNet.Settings.IsDiagnosticModeEnabled setter
bool avl::GetAvlDiagnosticOutputsEnabled()
AvlNet.Settings.IsDiagnosticModeEnabled getter

Following snippet presents example Settings class usage. This is a part of the bigger example.

        //...
private void diagnosticModeButton_CheckedChanged(object sender, EventArgs e)
{
AvlNet.Settings.IsDiagnosticModeEnabled = (sender as ToolStripButton).Checked;

UpdateImages();
}
//...


In many functions in AVL optional inputs (e.g. inRoi in AddChannels) may be provided with atl::NIL value which makes the function execute with default ROI. In AVL.NET such methods have appropriate overloads with those optional values skipped.
The same refers to optional outputs. In AVL it is common to provide atl::NIL for such outputs when one does not want the function to calculate value for it. It is impossible in .NET to disable output calculation that way though. Instead, appropriate overloads may be used to skip the output calculation e.g. PathToLineDistance in one of its overloads skips the outConnectingSegment output.