Porting a Windows Forms C# Application to Mac OS X and Linux (Source ::: CodeGuru.com)

August 10, 2010 § 1 Comment

Porting a Windows Forms C# Application to Mac OS X and Linux


In the previous article we looked at the options for developing cross-platform applications in C# programming. The technology that makes this possible is Mono from Novell. In this article we’ll take an existing Windows C# application
and run it on both Mac OS X and Linux. Before we dive into the details
it’s important to take a quick look at what Mono is and where it came
from to help you understand what’s happening behind the scenes.

The Mono project has been around for almost nine years and started
out as an effort to implement an open-source version of the
ECMA-standard (ECMA-334) C# programming language and
the companion Common Language Infrastructure or CLI (defined in
ECMA-335). These standards correspond with Microsoft’s products commonly
known as the .NET framework platform. Programs written
with Mono run on different platforms through the use of native
run-times. If fact, you can run the exact same .EXE file on any
supported platform with the Mono runtime installed.

Version 2.0 of the Mono runtime was the first release to provide
robust support for native Windows Forms applications. That basically
means that Novell implemented all of the System.Windows.Forms namespace. Under the cover, Mono uses the System.Drawing
library along with drivers for X11, Win32 and OS X to do the heavy
lifting. While Windows Forms applications will run on any supported
platform, you’ll still have to use Microsoft Visual Studio
for the actual design and coding if you want to use a visual designer.
We’ll discuss the Mono Visual Studio add-in a little later.

Porting Considerations

While Mono makes it possible to run Windows Forms-based apps on
virtually any OS, it doesn’t mean they will look great on another
platform. In many cases the look and feel will be adequate, but there
may be some cases where the differences are significant. The Mono team has put together a guide on their website that walks you through the process of porting an application using the Mono Migration Analyzer (MoMA) to determine potential issues.

To test out MoMA we downloaded a number of Windows Forms samples from the windowsclient.net website. The RegexTest sample
illustrates an issue that tends to pop up between platforms. When you
run the MoMA tool against the RegexTest.exe file, it gives the following

Form.set_AutoScaleBaseSize (Size)

Setting this is probably unintentional and can cause Forms to be improperly sized. See http://www.mono-project.com/FAQ:_Winforms#My_forms_are_sized_improperly for details.

The result when you run the application on Linux is a chopped off
window that doesn’t fully show the buttons at the bottom of the form.
Figure 1 shows what it looks like on Windows, and figure 2 shows the
same application running on Linux.

(Full Size Image)
Figure 1 RegexTest application running on Windows

(Full Size Image)
Figure 2 RegexTest application on Linux

The fix is a simple one in this case. All of the visual components of
this application are built in code, and the line that sets the size
looks like this:

this.ClientSize = new System.Drawing.Size(536, 503);

Changing it to the following fixes the problem:

this.ClientSize = new System.Drawing.Size(536, 536);

(Full Size Image)
Figure 3 Updated RegexTest app running on Linux.

Things to Watch For

One of the things that can cause problems when porting apps between
operating systems stems from subtle differences like file naming
conventions. Windows filenames are case insensitive while both Mac OS X
and Linux are case sensitive. This can lead to issues if you have
filenames for things like resources or images referenced either in code
or in a configuration file that aren’t consistent. You must also deal
with the different usage of the "\" versus the "/" in path names. Mono
does offer a feature they call IOMap to specifically help with the path issue.

If you happen to be a Ubuntu, user you’ll find the latest version of
Mono available through the normal update channels is 2.4.4. While that
shouldn’t be a big issue, you could run into some problems if you’re
using any of the Language Integrated Query (LINQ) features. The latest
version of Mono also begins to implement some of the C# 4.0 features
along with ParallelFX, although you’ll have to wait for at least 2.8 to
get started with those.

One option for getting Mono 2.6 up and running on Ubuntu 10.4 is to build it from source. There are instructions on the Mono site on how to do it, but the process is not for a beginner. A quick Google search turned up a blog post
about installing Mono 2.6.x in parallel on Ubuntu 9.10. You’ll need to
have subversion installed along with libtool to get the script to work

Wrapping Up

One of the things we didn’t cover in these two articles is the
ability to write C# code using Mono for Apple’s iPhone, iPod Touch and
iPad. While you won’t be able to take your Windows Forms apps to those
platforms, you will be able to code in C#. It requires you to do all the
coding on a Mac and use the Apple SDK. Building the actual interface
can be done either programmatically or by using Apple’s Interface
Builder. Future versions of this same tool are planned for Google’s
Android platform as well.

Novell’s Mono product is essentially the only game in town if you
want to take an existing Windows Forms app and run it natively on Linux
or Mac. It’s also the primary force behind a number of popular open
source apps like the Banshee media player and F-Spot photo manager. Mono
is definitely worth a look if you have a need for cross-platform apps.

A framework in C# for fingerprint verification (Source : Code Project)

August 4, 2010 § 6 Comments

A framework in C# for fingerprint verification

In this
article we introduce a framework in C# for fingerprint verification, we
briefly explain how to perform fingerprint verification experiments and
how to integrate your algorithms to the framework.

Download FingerprintRecognition.zip – 225.88 KB

Download Help.zip – 1.5 MB


Fingerprint recognition [1] is an active research area nowadays. An
important component in fingerprint recognition systems is the
fingerprint matching algorithm. According to the problem domain,
fingerprint matching algorithms are classified in two categories:
fingerprint verification algorithms and fingerprint identification
algorithms. The aim of fingerprint verification algorithms is to
determine whether two fingerprints come from the same finger or not. On
the other hand, the fingerprint identification algorithms search a query
fingerprint in a database looking for the fingerprints coming from the
same finger.

There are hundreds of papers concerning to fingerprint verification
but, as far as we know, there is not any framework for fingerprint
verification available on the web. So, you must implement your own tools
in order to test the performance of your fingerprint verification
algorithms. Moreover, you must spend a lot of time implementing
algorithms of other authors to compare with your algorithms. This was
our motivation to put our fingerprint verification framework available
for everyone.

The most closely related work to our framework is the FVC-onGoing web system. This system has the following limitations:

  • You do not have access to any algorithm but yours.
  • It is not a framework; so, you cannot reuse any software component.
  • It cannot be used with educational purpose because students cannot see how the algorithms work.
  • After performing an experiment using a database (standard or hard)
    you must wait 30 days to perform another experiment using the same
  • You do not have control over the fingerprint databases. Thus, you
    cannot use your own databases neither modify the existing ones.
  • You do not have access to the fingerprints that your algorithm fails
    matching. Hence, you cannot analyze why the algorithm fails in order to
    fix your code.
  • You cannot create an experiment with a custom protocol for performance evaluation.


If any of the above mentioned limitations constitute a problem for you, then you should use our framework.

Our framework is implemented in C# with .Net Framework for two main
reasons. First, C# has become one of the most popular programming
languages. Second, the technologies, tools and class libraries available
on .Net Framework save us a lot of time of coding.

Our framework allows performing fingerprint verification experiments
for databases B of FVC2000, FVC2002 and FVC2004; and databases A of
FVC2004. In this experiments, we use the performance indicators of the
Fingerprint Verification Competitions [2] (EER(%), FMR100(%),
FMR1000(%), ZeroFMR(%), Time(ms) and ROC curves). Additionally, you can
include experiments with a custom evaluation protocol or different

We implemented the fingerprint verification algorithms proposed by
Tico and Kuosmanen [3], Jiang and Yau [4], Medina-Pérez et al. [5] and
Qi et al. [6]. It is important to highlight that, despite the algorithm
of Qi et al. is a combination of a minutiae matching algorithm with an
orientation based algorithm, we implemented only the minutiae matching
algorithm. This framework allows you to include new fingerprint matching
algorithms as well as new feature extraction algorithms with minimum
effort and without recompiling the framework.

One of the goals that we kept in mind while developing this framework
was to achieve class interfaces as simple as possible. This way, adding
new algorithms is pretty straightforward.

We hope this work motivates you and more people to collaborate with us in order to implement more algorithms.

In this article we briefly explain how:

  • to perform fingerprint verification experiments,
  • to see the matching minutiae after performing an experiment with a minutiae based algorithm,
  • to compute and display features from certain fingerprint,
  • to integrate your algorithms to the framework.


Before using the framework

With this article, we provide the following files:


Before doing anything else, download the binary files containing the features of the fingerprints at http://rapidshare.com/files/409648016/FingerprintFeatures.rar. Then, extract the file FingerprintFeatures.rar and populate the directories with the image of fingerprints available at:


Running a fingerprint verification experiment

Extract the file “FingerprintRecognition.zip” and build the solution.
Then you can debug the project “FR.FVCExperimenter” or you can execute
“FR.FVCExperimenter.exe” in the directory containing the generated
assemblies. The following window will open:

In the “Resources” text box, specify the path of the database that
you are going to use, for example: “D:\PR

Select the proper experiment type in the combo box with label
“Experiment”. Select value “FVCDB_B” if you are going to perform an
experiment with any of the databases DB1_B, DB2_B, DB3_B or DB4_B.
Select value “FVC2004DB_A” if you are going to perform an experiment
with any of the databases DB1_A, DB2_A, DB3_A or DB4_A of FVC2004.

Use the combo boxes “Minutia Extractor”, “Orientation Image
Extractor” and “Skeleton Image Extractor“ to select the algorithms that
will be used to compute the basic features (minutiae, orientation image
and skeleton image). Sadly, we are not specialists in digital image
processing. That is why we only implemented the algorithm proposed by
Ratha et al. [7] to extract orientation images. The minutiae and
skeleton images were computed by a collaborator which gave us these
features saved in binary files. We hope this work motivates you and more
people to collaborate with us in order to implement other feature
extraction algorithms as well as matching algorithms.

Use the combo box with label “Matcher” to select a fingerprint
verification algorithm, and the combo box with label “Feature Provider”
to select the algorithm that will be used to store and retrieve the
features for the selected matcher. Despite that we implemented only one
feature provider for each matcher, there are possible scenarios where
you may have multiple feature providers for each matcher.

The grid with label “Properties” allows changing the parameters of any selected algorithm.

Click on “Execute Experiment” button to run the experiment. This
experiment uses the evaluation protocol of the Fingerprint Verification
Competitions [2]. The performance indicators computed in this
experiments are: EER(%), FMR100(%), FMR1000(%), ZeroFMR(%), Time(ms) and
ROC curves. These indicators are saved in a file which name is formed
by the name of the matching algorithm concatenated with “.Summary.csv”.
This file is saved in a folder by the name of “Results” in the same
folder where the fingerprints are stored. Two more files are saved, one
file containing the false matching fingerprints and the other containing
the false non matching fingerprints.

If you want to match two fingerprints and verify the coincident
minutiae, then click the “Visual Match” button which will open the
“Visual Fingerprint Matching” form. Load the fingerprints that you want
to compare and click the “Match” button. The feature extractors and
matcher selected in the “FVC Experimenter” are also used here to perform
the fingerprint matching. The following is an example of matching two

Visualizing features

If you want to visualize features for certain fingerprint then you
can use “FR.FeatureDisplay” project. In “Fingerprint Feature Display”
form, you can change the feature extractor and feature display. In the
framework, we include classes to visualize minutiae, orientation image
and skeleton image.

The following is an example visualizing the orientation image of a fingerprint:

Adding new algorithms to the framework

The first thing that you need to know is that you do not need to
modify the applications of the framework in order to recognize your
algorithms because we use Reflection to load all algorithms dynamically
at execution time.

You may create as many assemblies as you want in the directory
containing the framework. For each new assembly go to the properties and
set the output path with value “..\bin\Release\”.

In order to add a new feature extractor, you must inherit from the generic class FeatureExtractor<T> and implement the method ExtractFeatures(Bitmap image). For example, suppose that you want to create an extractor for features of type MyFeature, then you could implement a class like the following:

public class MyFeatureExtractor : FeatureExtractor<MyFeature>{	public override MyFeature ExtractFeatures(Bitmap image)	{		// Place here your code to extract features	}       }

In case that your new features are built upon some existing features then you can do like follows:

public class MyFeatureExtractor : FeatureExtractor<MyFeature>{         public FeatureExtractor<List<Minutia>> MtiaExtractor { set; get; }

    public FeatureExtractor<OrientationImage> OrImgExtractor { set; get; }

    public override MyFeature ExtractFeatures(Bitmap image)    {	try        {             var mtiae = MtiaExtractor.ExtractFeatures(image);             var orImg = OrImgExtractor.ExtractFeatures(image);             return ExtractFeatures(mtiae, orImg);        }        catch (Exception)        {             if (MtiaExtractor == null)                throw new InvalidOperationException("Cannot extract MyFeature: Unassigned minutia list extractor!");             if (OrImgExtractor == null)                throw new InvalidOperationException("Cannot extract MyFeature: Unassigned orientation image extractor!");             throw;        }    }

    public MyFeature ExtractFeatures(List<Minutia> mtiae, OrientationImage orImg)    {        // Place here your code to extract features    }       }

For each feature extractor you must create a resource provider.
Resource providers allow saving (retrieving) to (from) file the
resources associated to fingerprints. The framework includes resource
providers for extractors of minutiae (MinutiaListProvider), orientation image (OrientationImageProvider) and skeleton image (SkeletonImageProvider). The following is an example of a resource provider for the feature extractor defined above.

public class MyFeatureProvider : ResourceProvider<MyFeature>{    public MinutiaListProvider MtiaListProvider { get; set; }

    public OrientationImageProvider OrImgProvider { get; set; }

    public override string GetSignature()    {        return "myf";


    public override bool IsResourcePersistent()    {        return true;    }

    protected override MyFeature Extract(string fingerprint, ResourceRepository repository)    {        try        {            var mtiae = MtiaListProvider.GetResource(fingerprint, repository);            var orImg = OrImgProvider.GetResource(fingerprint, repository);            return featureExtractor.ExtractFeatures(mtiae, orImg);        }        catch (Exception)        {            if (MtiaListProvider == null)                throw new InvalidOperationException("Unable to extract MyFeature: Unassigned minutia list provider!");            if (OrImgProvider == null)                throw new InvalidOperationException("Unable to extract MyFeature: Unassigned orientation image provider!");            throw;        }    }

    private MyFeatureExtractor featureExtractor = new MyFeatureExtractor();}

Now, it is time to create a new fingerprint matching algorithm. Suppose that you want to match features of type MyFeature, then you must create a matcher like this:

public class MyMatcher : Matcher<MyFeature>{            public override double Match(MyFeature query, MyFeature template)    {        // Place here your code to match fingerprints    }}

In case that you are implementing a minutia matching algorithm then you should modify the above code as follows:

public class MyMatcher : Matcher<MyFeature>, IMinutiaMatcher{            public override double Match(MyFeature query, MyFeature template)    {        List<MinutiaPair> matchingMtiae;        return Match(query, template, out matchingMtiae);    }

    public double Match(object query, object template, out List<MinutiaPair> matchingMtiae)    {        // Place here your code to match fingerprints    }}


In this article we introduce a framework in C# for fingerprint
verification. We briefly explain how to perform fingerprint verification
experiments and how to integrate your algorithms to the framework. We
provide several matching algorithms that you can use not only for
experimental purpose, but also to create your own applications. We
provide the source code of all the algorithms so the user can reuse any
part of the code as well as any software component.

Where Am I?

You are currently viewing the archives for August, 2010 at Naik Vinay.