Toom

To content | To menu | To search

Saturday 5 May 2012

Cryptography basis

Cryptography is the study of secured communications. In a sens cryptography could be considered as a branch of mathematics where we focus on algorithm strength and complexity. To do so we are using Number Theory, which gives us the basis (prime numbers, big numbers, Euler's totient, Fermat's theorem...) in order to create strong mechanisms that are fast to encode data and fast to decode them. During my last year of studies I had to develop a Java (GUI) application to increase my knowledge of Cryptography. The aim was first to implement the part of the Number Theory that is used in Cryptography. In a second time I had to attack some weak securities to learn what a programmer should and should not do when implementing a security service.The GUI is very simple and look like the following:

crypto5.png

Part of this GUI is multi-threaded because some attacks could take a huge time. This software is of course not a hacking software because security weakness are hard-coded in the sources. For example the next picture is the result of an attack of a Cipher text encoded with a patterned key.

crypto6.png

As usual the sources are available. And I would like to thank Tom Dowling (teacher) for this great introduction to Cryptography.

Saturday 28 April 2012

Bounce with GLUT

GLUT (OpenGL Utility Toolkit) is a library which allows programmers to develop OpenGL programs more easily. The idea is to create some loops:

  • one to update the model
  • one to update the graphics
  • and the others to catch events (keyboard, resizing, mouse...)

Thanks to these useful loops it's possible to create simple graphic programs. In my case I developed an interactive bouncing ball program based on Josh Nimoy "BallDroppings". The aim was to use Euler's method to create a gravitational system with differential equations. The bounce direction (angle of reflection) is calculated using the vector representation of the contacted line and the direction (angle of incidence) of the ball. On the image below you can see the model with a representation of the ball's "path".

ballSpring.png

And of course, all sources are free.

Friday 20 April 2012

Let's play XNA

XNA is a framework developed by Microsoft to allow developers to design games more easily. The bright side of this framework is that it's working on all Microsoft platforms (PC, Phones, XBOX 360...). During my last year at the NUI Maynooth I had to develop two programs using XNA and VisualStudio (C#). One XNA project was to develop a small 2D game and the other was to render and move around a 3D world using Quaternions. For the second one I decided to create a very simple environment (using Google Sketchup) where you can drive a very simple remote control car (see picture below).

carGame1.png

3D game sources are available as usual.

For the 2D game I decided do to something more complex and more interesting. This game is using the concept "destroy-n-build". You are in an environment composed of blocks and you have to mine them and to build thanks to them to reach the bottle. You can play up to 5 players on one computer; 4 players will use XBOX 360 gamepads and the last player will use the keyboard and the mouse. Another great thing is the possibility to create your own worlds and levels with a simple text editor. The picture below shows a party with 2 players in a "big" level.

itsmine.png

The UML of this program is clear, strong and allow upgrades. Moreover the architecture can be re-used to create another 2D game. It was generated thanks to yUML and my yUML file is available here.

yUML.jpg

And here are the 2D game sources :)

Thursday 19 April 2012

Database Creator

The Database Creator is a part of my Final Year Project at the NUI Maynooth. I developed this software to simplify the creation of databases of images, which are used to train Boosted Cascade of Classifiers (BCC). This software is using OpenCV to open videos and to compute images, and Qt for the multi-threaded user interface. The software is divided in 3 tabs:

  • The database creator
  • The database browser
  • The BCC tester

The database creator:

creator1.png

This tab allows the user to open a video and to browse it image per image. The user can then select regions of interest (ROI) or discriminated areas in the image, and enter some parameters (position and orientation)). All previous information will be saved in an XML file if the user presses the "Generate positive" button, else ("Generate negative" button) a very simple XML file will be generated.

The database browser:

creator2.png

This tab allows the user to browse the database using XML files to retrieve information. It also allows the user to delete not relevant XML files. Finally this tab permits the user to generate images from videos and XML files. This process will also generate two txt files that the user will need to train a BCC using OpenCV.

The BCC tester:

creator3.png

This final tab allows the user to test a generated BCC on a video stream. The camera producing the stream has to be connected to the PC, then the user just have to open the XML file representing the BCC and it will be applied to the video stream.

And here are the sources of the DatabaseCreator.

Boosted Cascade of Classifiers

The BCC is a fast detection technique using Haar-like features to recognize shapes in an image. This technique is used in lot of devices, e.g. cameras to detect faces. The main advantage of this technique is the speed to execute the detection over an image. The BCC is based on the neural network called rejection cascade. The aim of this cascade is to reject non-shapes with an increasing accuracy at each stump (node/stage) of the cascade. The picture below synthesizes the process.

boosted.png

To train a cascade like this, the user will need a database of positive and negative images. The two pictures below represent typical positive (top) and negative (bottom) images for a robot detection BCC. Of course an image of a fish could be considered as a negative image in this case but keep in mind that positive and negative images should be in a common environment.

positive.png

negative.png

Then the trainer will compute Haar-like features (using Haar-like masks with different size, positions and orientations) that are common between positive images and not found in negative images. Finally it will create different stumps (small neural networks) with different accuracies and order them by accuracy (less accurate to most accurate) to create the BCC. Haar-like masks are simple binary masks (see picture below), the main advantage of these masks is the possibility to apply them to an image using Fourier transform and then to speed up the process.

haar.png

With a well-trained cascade (database of 1000 positives/1000 negatives, and 20 stumps) approximately 70% of non-shapes are rejected by the three first nodes. The fact that less accurate stumps are at the beginning of the cascade is the key of the speed of execution.

The main downside is the time to train the cascade: from one hour to a month depending on the database size. Another downside is that all images in the training set (database of images) have to be clear (no blurred images) because Haar-like features are detecting sharp differences between two areas in the image.

Even though new techniques were discovered after the Viola & Jones paper, the BCC is still one of the most powerful technique to detect shapes. That's why I developed a software to simplify the creation of databases of images, and that's why I used this technique to detect NAOs on a field for the RoboCup SPL.

- page 1 of 3