Image Processing Prototyper (IPPrototyper)
The IPPrototyper is a tool, which was designed with the aim of allowing to prototype image processing
and computer vision algorithms easier and faster, so developers could concentrate on the algorithm itself,
but not spending time on creating some user interface used for testing of the algorithm.
In many cases a computer vision algorithm consists of multiple image processing steps and result of each
step may be of interest to developer during development/debugging phase. At the same time most computer vision
algorithms must be tested on a database of images and application should provide a way to navigate through
the images and see results of computer vision algorithm's work. So the aim of IPPrototyper was to provide
generic user interface, which would allow developers to test their computer vision algorithms on a set
of images and inspect each step of the algorithm. Using this tool developers don't need to develop any type
of user interface at all, but just concentrate on developing computer vision algorithm, which is implemented
as a plug-in to IPPrototyper.
Application features:
- Allows opening a folder containing images and displaying their list. Navigating through the list of images
shows result of applying computer vision algorithm to the selected image.
- Shows a list of computer vision algorithm's steps. Navigating through the list of steps shows result of
computer vision algorithm on the selected step.
- Provides log window, so computer vision algorithms may output some information related to algorithm's work.
- Saves list of recently used folders and allows opening last used folder on application start. Also saves/loads
some UI settings, so user can concentrate on testing computer vision algorithm right after application's start.
- Plug-in system. All computer vision algorithms are implemented in separate libraries, which are found by
IPPrototyper automatically on application start. Each plug-in is aimed to do image processing only, but not
any user interface.
|
Although the tool looks to be small and simple, the IPPrototyper allows to avoid doing quite a lot of annoying work
on creating kind of "Hello world" application for testing computer vision algorithms. The tool provides most of the basic
infrastructure and frees developer from reinventing the wheel every time when it is required to prototype new computer
vision algorithm.
Here is a quick sample application demonstrating the IPPrototyper tool
(source code can be obtained with AForge.NET framework's installation package or from SVN repository).
Developing IPPrototyper plug-in
Below listed steps describe how to create and debug IPPrototyper plug-in containing computer vision algorithm's prototype.
- Create empty Class Library project in VS.NET (Professional or Express Edition).
- Add reference to AForge.Imaging.IPPrototyper.dll assembly, which is provided with AForge.NET framework. Also add references to
other assemblies, which you may need for developing computer vision algorithm (like AForge.Imaging.dll, etc. if you plan
using AForge.NET framework).
- Add IPPrototyper.exe executable to your project (you can add it as link - see "Add" button in "Add Existing Item"
dialog of VS.NET). Set "Build Action" option for the file to "None" and "Copy to Output Directory" option to "Copy if newer".
Note: you can skip this step, but in this case you need to copy the IPPrototyper.exe file to output folder manually.
- Create a public class implementing AForge.Imaging.IPPrototyper.IImageProcessingRoutine (see sample bellow).
- Change project settings, so IPrototyper.exe will run on start of debugging:
- In the case if VS.NET Professional Edition is used, use "Start external program" option on "Debug" page
of project's properties.
- In the case if C# Express Edition 2008 is used, you will need to edit project's csproj.user file and
make sure it contains following configuration:
Program
bin\Debug\IPPrototyper.exe
Program
bin\Release\IPPrototyper.exe
- Start debugging of computer vision algorithm ("F5") - IPPrototyper should start and load your module.
- Use "File->Open Folder" menu item of IPPrototyper to open a folder containing images to process. Navigate
through the list of loaded images to see result of your computer vision algorithm's work.
Note: single plug-in assembly may contain multiple classes implementing IImageProcessingRoutine interface.
In this case all of them will be loaded by IPPrototyper and user will be able to switch computer vision algorithms to test.
Sample implementation of IPProtytoper plug-in
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using AForge;
using AForge.Math.Geometry;
using AForge.Imaging;
using AForge.Imaging.Filters;
using AForge.Imaging.IPPrototyper;
namespace IPPrototyperSample
{
public class CoinsFinder : IImageProcessingRoutine
{
// Image processing routine's name
public string Name
{
get { return "IPPrototyper Sample"; }
}
// Process specified image trying to recognize counter's image
public void Process( Bitmap image, IImageProcessingLog log )
{
log.AddMessage( "Image size: " + image.Width +
" x " + image.Height );
// 1- grayscale image
Bitmap grayImage =
Grayscale.CommonAlgorithms.BT709.Apply( image );
log.AddImage( "Grayscale", grayImage );
// 2 - Otsu thresholding
OtsuThreshold threshold = new OtsuThreshold( );
Bitmap binaryImage = threshold.Apply( grayImage );
log.AddImage( "Binary", binaryImage );
log.AddMessage( "Otsu threshold: " + threshold.ThresholdValue );
// 3 - Blob counting
BlobCounter blobCounter = new BlobCounter( );
blobCounter.FilterBlobs = true;
blobCounter.MinWidth = 24;
blobCounter.MinWidth = 24;
blobCounter.ProcessImage( binaryImage );
Blob[] blobs = blobCounter.GetObjectsInformation( );
log.AddMessage( "Found blobs (min width/height = 24): " +
blobs.Length );
...
}
}
}
(full code is available in AForge.NET framework's samples collection)
From the above code fragment we see, that prototyping of computer vision algorithm is done in more or
less same way like it is usually done - different image processing routines follow one after another. But
the difference now is that user is not bothered with UI and infrastructure work, but just uses two methods
defined by IImageProcessingLog interface: AddImage() to add image into log providing intermediate result
of computer vision algorithm and AddMessage() to output some information about algorithm's work.
|