CVB.Net 14.0
TrainingSet Class Reference

A Minos Training Set from which a classifier can be generated. More...

Inherits INativeHandle.

Classes

class  ImageInfo
 Image that has been added to a training set. More...
 
class  ImageInfoCollection
 Class that maintains the collection of Training Images inside a Minos Training Set. More...
 
class  ImageInstanceInfoCollection
 Instance information collection that is attached to a training set image. More...
 
class  InstanceInfo
 InstanceInformation that has been added to a training set. More...
 
class  InstanceInfoCollection
 Class that maintains the collection of Training Images inside a Minos Training Set. More...
 
class  ModelInfo
 InstanceInformation that has been added to a training set. More...
 
class  ModelInfoCollection
 ModelInformationCollection class that aggregates the collection of Models inside a Minos Training Set. More...
 
class  ModelInstanceInfoCollection
 Instance information collection that is attached to a training set model. More...
 
class  TrainingSetObject
 Base class for all objects that can be inside a training set. More...
 
class  TrainingSetObjectInfoCollection
 Additional inheritance level of the InformationCollection object from the Image Manager wrapper that specifies stronger constraints on the TInfo generic parameter More...
 

Public Member Functions

 TrainingSet ()
 Create an empty training set. More...
 
 TrainingSet (string fileName)
 Load a saved training set from a file. More...
 
 TrainingSet (byte[] buffer)
 
 TrainingSet (byte[] buffer, int offset, int size)
 Recreate a serialized Minos training set from a byte array. More...
 
TrainingSet Transform (Matrix2D transformation)
 Generate a new training set by transforming this training set with a 2x2 transformation matrix. More...
 
void Save (string fileName)
 Write the training set to a file. More...
 
unsafe SearchResult[] CheckConsistency (double threshold, double density)
 Test all images in the parent training set for instances of this model that might have been forgotten during the training process. More...
 
void Dispose ()
 Dispose function to get rid of resources allocated by this object.
 
override int GetHashCode ()
 Retrieve a hash code for this object. More...
 
override bool Equals (object obj)
 Check two TrainingSet objects for equality. More...
 

Protected Member Functions

virtual void OnImageAdded (ImageInfo img)
 Event router for the ImageAdded event. More...
 
virtual void OnImageRemoved (ImageRemovedEventArgs args)
 Event router for the ImageRemoved event. More...
 
virtual void OnModelAdded (ModelInfo mdl)
 Event router for the ModelAdded event. More...
 
virtual void OnModelRemoved (ModelRemovedEventArgs args)
 Event router for the ModelRemoved event. More...
 
virtual void OnInstanceAdded (InstanceInfo mdl)
 Event router for the InstanceAdded event. More...
 
virtual void OnInstanceRemoved (InstanceRemovedEventArgs args)
 Event router for the InstanceRemoved event. More...
 
virtual void Dispose (bool disposing)
 IDispose helper function. More...
 

Properties

int ClassCount [get]
 The number of identifiable classes inside this training set. More...
 
InstanceInfoCollection Instances [get]
 The instances contained in this training set. More...
 
int InstancesTotal [get]
 Total number of instances currently trained in this training set.
 
ImageInfoCollection Images [get]
 The images contained in this training set. More...
 
ModelInfoCollection Models [get]
 The models contained in this training set. More...
 
string FileName [get]
 Name of the file from which this image list was loaded (string.Empty if this image list was neither loaded nor saved since its construction). More...
 
bool IsModified [get, set]
 Get or sets a flag that informs about unsaved modifications to the training set. Saving the training set will set this flag to false. More...
 
Rect Extent [get]
 Extent of the classes in the training set relative to the anchor point. More...
 
Rect LastFeatureWindow [get]
 Feature window of the last model that has been created for the training set. More...
 
unsafe string Comment [get, set]
 Comment assigned to the training set. More...
 
double ExpectationRadius [get, set]
 Expectation radius is the radius that is searched for the best occurrence of a sample when adding a new sample to the training set. More...
 
double CorrelationThreshold [get, set]
 Correlation threshold is the correlation value below which Minos will suggest the generation of a new model rather over the generation of a new instance of an existing model with which the new instance correlates poorly. More...
 
IntPtr Handle [get]
 Native Minos training set handle. More...
 
bool IsDisposed [get]
 Tests if the native handle has already been disposed.
 
- Properties inherited from INativeHandle
IntPtr Handle [get]
 The native handle of the object.
 
bool IsDisposed [get]
 Possibility to check whether the object has already been disposed of.
 

Events

EventHandler< ConsistencyCheckEventArgsConsistencyCheckProgress
 This event will be used for indicating progress of consistency checks triggered by a call to CheckConsistency.
 
EventHandler< ImageAddedEventArgsImageAdded
 Event that will be raised when a new image has been added to the training set.
 
EventHandler< ImageRemovedEventArgsImageRemoved
 Event that will be raised when an image has been removed from the training set. Note that removing an image usually also means that a number of instances (the instances that were marked on the removed image) have been removed as well, but the if the reason for the removal of these instances was the removal of an image, there will be no notification event for the implicitly removed instances. Likewise, the removal of an image may also trigger the removal of a model. Again, there will be no separate notification about this if the reason was the removal of an image. This means that to be on the safe side, it usually makes sense to update the model and instance views as well, if an image has been removed.
 
EventHandler< ModelAddedEventArgsModelAdded
 Event that will be raised when a new model has been added to the training set.
 
EventHandler< ModelRemovedEventArgsModelRemoved
 Event that will be raised when an image has been removed from the training set. Note that removing an image usually also means that a number of instances (the instances that were marked on the removed image) have been removed as well, but the if the reason for the removal of these instances was the removal of an image, there will be no notification event for the implicitly removed instances. Likewise, the removal of an image may also trigger the removal of a model. Again, there will be no separate notification about this if the reason was the removal of an image. This means that to be on the safe side, it usually makes sense to update the model and instance views as well, if an image has been removed.
 
EventHandler< InstanceAddedEventArgsInstanceAdded
 Event that will be raised when a new model has been added to the training set.
 
EventHandler< InstanceRemovedEventArgsInstanceRemoved
 Event that will be raised when an image has been removed from the training set. Note that removing an image usually also means that a number of instances (the instances that were marked on the removed image) have been removed as well, but the if the reason for the removal of these instances was the removal of an image, there will be no notification event for the implicitly removed instances. Likewise, the removal of an image may also trigger the removal of a model. Again, there will be no separate notification about this if the reason was the removal of an image. This means that to be on the safe side, it usually makes sense to update the model and instance views as well, if an image has been removed.
 
NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
More...
 
- Events inherited from INativeHandle
NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
More...
 

Detailed Description

A Minos Training Set from which a classifier can be generated.

Constructor & Destructor Documentation

◆ TrainingSet() [1/4]

Create an empty training set.

Exceptions
OutOfMemoryExceptionIf a new training set could not be allocated

◆ TrainingSet() [2/4]

TrainingSet ( string  fileName)

Load a saved training set from a file.

Parameters
fileNamename of the file to be loaded
Exceptions
FileNotFoundExceptionIf the training set file does not exist
FileLoadExceptionIf loading an existing training set file failed
ArgumentNullExceptionIf fileName is null

◆ TrainingSet() [3/4]

TrainingSet ( byte[]  buffer)

Recreate a serialized Minos Training Set from a byte array.

Parameters
bufferbyte array from which to create the training set.

◆ TrainingSet() [4/4]

TrainingSet ( byte[]  buffer,
int  offset,
int  size 
)

Recreate a serialized Minos training set from a byte array.

Parameters
bufferByte array from which to create the training set
offsetoffset at which to start
sizenumber of bytes to use
Exceptions
ArgumentNullExceptionIf buffer is null
ArgumentExceptionIf offset is less than zero or size is less than zero
ArgumentOutOfRangeExceptionIf offset and size have values that together exceed the length of buffer
InvalidDataExceptionIf buffer does not contain a deserializable Minos training set at the given offset.

Member Function Documentation

◆ CheckConsistency()

unsafe SearchResult[] CheckConsistency ( double  threshold,
double  density 
)

Test all images in the parent training set for instances of this model that might have been forgotten during the training process.

Parameters
thresholdcorrelation threshold to be used for the consistency check
densitydensity to be used for the consistency check
Returns
potentially forgotten positive samples that may be added to the training set
Exceptions
ObjectDisposedExceptionIf the training set has already been disposed
ArgumentOutOfRangeExceptionIf invalid values for threshold or density have been passed (both parameters must be within the range [0...1.0]
CvbExceptionIf the execution of the consistency check failed

◆ Dispose()

virtual void Dispose ( bool  disposing)
protectedvirtual

IDispose helper function.

Parameters
disposingtrue when called via IDisposable.Dispose, false when called by the finalizer.

◆ Equals()

override bool Equals ( object  obj)

Check two TrainingSet objects for equality.

Parameters
objother object to check
Returns
true if the objects are equal, false otherwise
Exceptions
ObjectDisposedExceptionIf this training set has already been disposed

◆ GetHashCode()

override int GetHashCode ( )

Retrieve a hash code for this object.

Returns
Hash code for this object

◆ OnImageAdded()

virtual void OnImageAdded ( ImageInfo  img)
protectedvirtual

Event router for the ImageAdded event.

Parameters
img

◆ OnImageRemoved()

virtual void OnImageRemoved ( ImageRemovedEventArgs  args)
protectedvirtual

Event router for the ImageRemoved event.

Parameters
args

◆ OnInstanceAdded()

virtual void OnInstanceAdded ( InstanceInfo  mdl)
protectedvirtual

Event router for the InstanceAdded event.

Parameters
mdl

◆ OnInstanceRemoved()

virtual void OnInstanceRemoved ( InstanceRemovedEventArgs  args)
protectedvirtual

Event router for the InstanceRemoved event.

Parameters
args

◆ OnModelAdded()

virtual void OnModelAdded ( ModelInfo  mdl)
protectedvirtual

Event router for the ModelAdded event.

Parameters
mdl

◆ OnModelRemoved()

virtual void OnModelRemoved ( ModelRemovedEventArgs  args)
protectedvirtual

Event router for the ModelRemoved event.

Parameters
args

◆ Save()

void Save ( string  fileName)

Write the training set to a file.

As a side effect this function sets the IsModified flag to false if the training set was saved successfully.

Parameters
fileName
Exceptions
ObjectDisposedExceptionIf the training set has already been disposed
ArgumentNullExceptionwhen fileName is null


◆ Transform()

TrainingSet Transform ( Matrix2D  transformation)

Generate a new training set by transforming this training set with a 2x2 transformation matrix.

Parameters
transformationmatrix with which to transform the geometry of this training set
Returns
transformed training set
Exceptions
ObjectDisposedExceptionIf the training set has already been disposed
DivideByZeroExceptionwhen providing a transformation matrix that is singular.

Property Documentation

◆ ClassCount

int ClassCount
get

The number of identifiable classes inside this training set.

The number of classes cannot be higher than the number of trained models (see property this.Models.Count). If two models have the same name, the classifier can no longer discriminate these two models, reducing the ClassCount property.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ Comment

unsafe string Comment
getset

Comment assigned to the training set.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ CorrelationThreshold

double CorrelationThreshold
getset

Correlation threshold is the correlation value below which Minos will suggest the generation of a new model rather over the generation of a new instance of an existing model with which the new instance correlates poorly.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed
ArgumentOutOfRangeExceptionwhen trying to set a correlation threshold less than 0 or greater than 1

◆ ExpectationRadius

double ExpectationRadius
getset

Expectation radius is the radius that is searched for the best occurrence of a sample when adding a new sample to the training set.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed
ArgumentOutOfRangeExceptionwhen trying to set an expectation radius less than 0

◆ Extent

Rect Extent
get

Extent of the classes in the training set relative to the anchor point.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ FileName

string FileName
get

Name of the file from which this image list was loaded (string.Empty if this image list was neither loaded nor saved since its construction).

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ Handle

IntPtr Handle
get

Native Minos training set handle.

It is normally not necessary to work with this handle in CVB.Net. Note that using this handle in connection with the legacy CVB managed wrappers may actually be disruptive to your application.

Implements INativeHandle.

◆ Images

ImageInfoCollection Images
get

The images contained in this training set.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ Instances

InstanceInfoCollection Instances
get

The instances contained in this training set.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ IsModified

bool IsModified
getset

Get or sets a flag that informs about unsaved modifications to the training set. Saving the training set will set this flag to false.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ LastFeatureWindow

Rect LastFeatureWindow
get

Feature window of the last model that has been created for the training set.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

◆ Models

ModelInfoCollection Models
get

The models contained in this training set.

Exceptions
ObjectDisposedExceptionIf the training set has already been disposed

Event Documentation

◆ ObjectDisposing

NativeHandleEventDelegate ObjectDisposing

Raised when this object is about to be disposed via the IDisposable.Dispose method.

This event is raised right before this object is disposed. The dispose itself cannot be canceled.