AForge.NET is a C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence - image processing, neural networks, genetic algorithms, machine learning, etc.
At this point the framework is comprised of 5 main and some additional libraries:
- AForge.Imaging – a library for image processing routines and filers;
- AForge.Neuro – neural networks computation library;
- AForge.Genetic – evolution programming library;
- AForge.Vision – computer vision library;
- AForge.Machine Learning – machine learning library.
The work on the framework's improvement is in constants progress, what means that new feature and namespaces are coming constantly. To get knowledge about its progress you may track source repository's log or visit project discussion group to get the latest information about it.
The framework is provided with not only different libraries and their sources, but with many sample applications, which demonstrate the use of this framework, and with documentation help files, which are provided in HTML Help format.
In the case you found an issue in any component of the framework or you would like to request for a new feature, you may feel free to submit the issue/request on the “Issues” page.
In case you are interested in the project and would like to learn about it more or in case you would like to contribute it, you are more than welcome to participate in the project’s discussion group.
AForge.NET 1.7.0 Release
New corners detector is introduce - SUSAN corner detector, which is described by S.M. Smith in: S.M. Smith, "SUSAN - a new approach to low level image processing", Internal Technical Report TR95SMS1, Defense Research Agency, Chobham Lane, Chertsey, Surrey, UK, 1995.
// create corner detector's instance
SusanCornersDetector scd = new SusanCornersDetector( );
// process image searching for corners
Point[] corners = scd.ProcessImage( image );
// process points
foreach ( Point corner in corners )
{
// ...
}
An interface for template matching algorithms is provided, which search for the given template in specified image. As a first implementation of it the ExhaustiveTemplateMatching is provided:
// create template matching algorithm's instance
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching( 0.92f );
// find all matchings with specified above similarity
TemplateMatch[] matchings = tm.ProcessImage( sourceImage, templateImage );
// highlight found matchings
BitmapData data = sourceImage.LockBits(
new Rectangle( 0, 0, sourceImage.Width, sourceImage.Height ),
ImageLockMode.ReadWrite, sourceImage.PixelFormat );
foreach ( TemplateMatch m in matchings )
{
Drawing.Rectangle( data, m.Rectangle, Color.White );
// do something else with matching
}
sourceImage.UnlockBits( data );The class also can be used to get similarity level between two image of the same size, which can be useful to get information about how different/similar are images:
// create template matching algorithm's instance
// use zero similarity to make sure algorithm will provide anything
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching( 0 );
// compare two images
TemplateMatch[] matchings = tm.ProcessImage( image1, image2 );
// check similarity level
if ( matchings[0].Similarity > 0.95 )
{
// do something with quite similar images
}
An interface for block matching algorithms is provided and a first implementation of it - exhaustive block matching. Block matching algorithms work with two images - source and search image - and a set of reference points. For each provided reference point, the algorithm takes a block from source image (reference point is a coordinate of block's center) and finds the best match for it in search image providing its coordinate (search is done within search window of specified size). In other words, block matching algorithm tries to find new coordinates in search image of specified reference points from source image.
The above sample image demonstrates result of processing of two images with the code below - yellow rectangle shows the reference point in the source image and the red line shows the displacement of this point in the search image.
// collect reference points using corners detector (for example)
SusanCornersDetector scd = new SusanCornersDetector( 30, 18 );
Point[] points = scd.ProcessImage( sourceImage );
// create block matching algorithm's instance
ExhaustiveBlockMatching bm = new ExhaustiveBlockMatching( 8, 12 );
// process images searching for block matchings
Point[] newPoints = bm.ProcessImage( sourceImage, points, searchImage, false );
// draw displacement vectors
BitmapData data = sourceImage.LockBits(
new Rectangle( 0, 0, sourceImage.Width, sourceImage.Height ),
ImageLockMode.ReadWrite, sourceImage.PixelFormat );
foreach ( BlockMatch match in matches )
{
// highlight the original point in source image
Drawing.FillRectangle( data,
new Rectangle( match.SourcePoint.X - 1, match.SourcePoint.Y - 1, 3, 3 ),
Color.Yellow );
// draw line to the point in search image
Drawing.Line( data, match.SourcePoint, match.MatchPoint, Color.Red );
// check similarity
if ( match.Similarity > 0.98f )
{
// process block with high similarity somehow special
}
}
sourceImage.UnlockBits( data );
This release introduces new AForge.Robotics.Lego.RCXBrick class, which provides functionality to perform some manipulations with Lego RCX Minstorm robotics kit. Nowadays the robotics kit is getting old, but still could be used by hobbies and enthusiasts to build and expire with their robots. Keep an eye on the AForge.NET project and soon you will see more interesting stuff about playing with Lego robotics kits.
// create an instance of RCX brick
RCXBrick rcx = new RCXBrick( );
// connect to the device
if ( rcx.Connect( ) )
{
// set forward direction of motor A
rcx.SetMotorDirection( RCXBrick.Motor.A, true );
// set power of motor
rcx.SetMotorPower( RCXBrick.Motor.A, 1 );
// turm motor on
rcx.SetMotorOn( RCXBrick.Motor.A, true );
// ...
// turn off motors A, B and C
rcx.SetMotorOn( RCXBrick.Motor.ABC, false );
// get first sensor's value
short value;
if ( rcx.GetSensorValue( RCXBrick.Sensor.First, out value ) )
{
// ...
}
// ...
}Note: AForge.Robotics.Lego.NXTBrick is refactored a bit, so has more in common with the new RCXBrick class.
