Master thesis: Motivation speech. What do you think of it?
I’m starting with my master thesis on “Skin and Object detection” right now. The idea is to detect skin in video sequences, similar to the one that you find on YouTube or MSN Video (former Soapbox).
I have already done some pre-work during an exercise on image detection and processing at university. Some of the results are found here, here and here.

The motivation speech, the kick off event, will be held in approximately one week and I have already prepared the presentation. During the speech I have 15 minutes to present my ideas. After that there is going to be a short discussion where the people from the institute give me some input for my master thesis.
You can download the current draft of the presentation from here.
I’m wondering what you think about my presentation and motivation speech? Any feedback is welcome! ![]()
Published on Feb 29th, 2008 —
Tags: Master thesis, University
Comments (3)
digg it!
kick it
Writing data to an XML file in Visual Basic 9 (Part 3)
Over at Channel 8, Alex Mills asked another question:
As you know my program is built and expanded from the code you wrote, very much appreciated. You designed that when you click edit it opens the XML in a new window. Is it possible that when the listview selected index changes, it automatically loads a couple of nodes of the xml to text boxes on the main form. With one click to be used as a quick reference feature, but I still want to have the seperate editor as I dont want have all the text boxes on the main form. Is this possible?
Everything is possible
As far as I have understood he needs something that looks like this:

To make this possible we first need to put some controls on the form.
Next, we need to register (actually, we registered it already in the second example, but I didn’t mentioned it explicitely) the SelectedIndexChanged event of the ListView.
This event is always fired when the ListView’s selected item has changed. That applies also if the selection has been changed to no item being selected anymore. That comes in very handy because we want to clear the textboxes when no item has been selected and fill the textboxes when an item has been selected:
‘ enable or disable the buttons whether an item has been selected.
Button1.Enabled = (ListView1.SelectedItems.Count > 0)
Button3.Enabled = (ListView1.SelectedItems.Count > 0)
‘ check if an item has been selected
If ListView1.SelectedItems.Count > 0 Then
‘ get the item from the list view.
Dim path = CType(ListView1.SelectedItems.Item(0).Tag, FileInfo)
‘ load the preview data.
LoadPreview(path.FullName)
Else
‘ clear the preview text boxes.
ClearPreview()
End If
End Sub
The first two lines in the method are already here from the second sample. They only enable or disable the “Edit” and “Delete” buttons depending on whether an item has been selected or not. The if statement then checks whether an item has been selected. If one has been selected the selected item’s tag is read (remember, from sample two, the tag contains our file information object) and feed into a new method that is called LoadPreview. LoadPreview is for the most part only a copy of the code that is used in the constructor of the edit form and looks like this:
‘ make sure that a path has been given
If path = Nothing Then
Throw New ArgumentNullException(“path”)
End If
‘ load the xml document from the given path
Dim xml = New XmlDocument()
xml.Load(path)
‘ get the different nodes from the xml file and put them in the text boxes.
‘ ATTENTION: here should also added a check for the values being Nothing.
Dim firstName = xml.SelectSingleNode(“//firstname”)
TextBox1.Text = firstName.InnerText
Dim lastName = xml.SelectSingleNode(“//lastname”)
TextBox2.Text = lastName.InnerText
Dim location = xml.SelectSingleNode(“//location”)
TextBox3.Text = location.InnerText
End Sub
We get the path as argument of the method and load the XML file. After that we use some XPath to get the values in the XML file and put them in the different textboxes.
The ClearPreview is very simple and looks like this:
‘ set all text boxes to an empty string.
TextBox1.Text = String.Empty
TextBox2.Text = String.Empty
TextBox3.Text = String.Empty
End Sub
The full source code of the sample can be downloaded from here.
Microsoft Research: World Wide Telescope
Zoom in, zoom out, scroll around, find a place, … That’s what you did so far with Live Maps or Google Maps. But what if you could do the same with our galaxy or other galaxies or even the universe? Zoom into that galaxy, browse around these stars, zoom into that moon, explore that nebula?

Microsoft Research is going to enable that with the World Wide Telescope.
What is it?
The official website says:
The WorldWide Telescope (WWT) is a rich visualization environment that functions as a virtual telescope, bringing together imagery from the best ground and space telescopes in the world for a seamless, guided exploration of the universe.
WorldWide Telescope, created with Microsoft’s high-performance Visual Experience Engineā¢, enables seamless panning and zooming across the night sky blending terabytes of images, data, and stories from multiple sources over the Internet into a media-rich, immersive experience.
Keep an eye on the official website… not that you miss the launch in spring!
Edit: A demo of the World Wide Telescope is shown here.
Published on Feb 28th, 2008 —
Tags: Microsoft Research, World Wide Telescope
Comments (0)
digg it!
kick it
Castle Crashers has been previewed at GDC
A preview of Castle Crashers has been shown at the GDC.
In the preview, finally, some of the features that are going to come with the game are shown: you can level up your own character (a little bit or RPG), play it with up to 4 persons (locally or over Xbox Live), perform a lot of combo attacks and have one magic spell that’s different depending on the character. The comic style sprites look also really cool and (I find it amazing) the animations are all hand drawn!

The preview is only availabe from Gametrailers.com. Check it out by clicking here (or on the picture).
Published on Feb 27th, 2008 —
Tags: Arcade games, Xbox 360, Xbox Live Arcade
Comments (2)
digg it!
kick it
Channel 9 guys for the background!
Jamie from Channel 9 did an awesome image featuring an army of Nine Guys. This is so my new background! Great work, Jamie and thanks for sharing!

(click the image to get the a high resolution version of the picture)
Who listens where?
Ever needed a way to understand if an application is installed that listens to a certain port; and that in C#? Some people need such features. I don’t know why exactly but it could be useful to make sure that you don’t use a port that is already used by another application.
In C# there are two ways to understand if somebody already listens on a port: you could create a Socket and check for a SocketException (and there for a specific error code) to understand that something went wrong or you could use the IPGlobalProperties class.
I tend to like the second approach a lot more because exceptions shouldn’t be used to control the flow of an application and are also quite slow.
Now since we are in C# 3.0 we can spice the whole thing up by using a LINQ expression. The GetActiveTcpListeners method on the IPGlobalProperties class returns an array of all active TCP listeners. If you ever coded in C# 3.0 you will know that an array implements the IEnumerable interface and that we can use LINQ with all classes that implement that interface:
/// Returns whether the given port is open.
/// </summary>
/// <param name="port">The port that is checked for being open.</param>
/// <returns></returns>
public static bool IsPortOpen(int port)
{
// get all active listener and check if one of them has
// the given port.
var connection = (from c in IPGlobalProperties.GetIPGlobalProperties()
.GetActiveTcpListeners()
where c.Port == port
select c).FirstOrDefault();
// if we got null none has the open port.
return (connection != null);
}
QuickBASIC: remembering the old days!
How long is it ago that I have coded the last time in QuickBASIC. Seems like ever but feels like yesterday. QuickBASIC was the first environment in which I have programmed an application… Oh, these memories!

One of our favourite things was to output sound on the beeper; in a loop where we increased the frequency until you couldn’t hear it anymore.
If you want to brush up your memories: here is a tutorial on how to develop in QuickBASIC.
PRINT “Enter your name: ”
INPUT name
PRINT “Hello ” & name & “! How are you?”
END
I still remember the switch to run a file directly without going into the IDE frist: qbasic /RUN myapp.bas
This switch was crucial; otherwise you always needed to open the menu and run the application from inside the IDE. Nobody wanted that when showing off own “creations”
I’m getting old… ![]()
Writing data to an XML file in Visual Basic 9 (Part 2)
Yesterday I have posted a blog post to answer a question that has been asked in the Channel 8 forums. The question was: “How can I save some values in text fields (on a form) as XML to the disk?”. After having written the blog post the guy asked me if he could also ask me further questions on the topic and I agreed.
So the next questions that came up in the forums are the following (summed up because the post is to long to be quoted):
- How can I write an XML file to the Windows’ User folder? How do I get this folder?
- How can I create an own folder with .NET?
- How can I load the XML file again?
- How can I show a list with all the files the folder holding my XML files?
Getting the Windows’ User folder is rather easy because the .NET Framework has a class called Environment. The class has a method called GetFolderPath that returns the locations of so called “special folders”. The Windows’ User folder is such a special folder.
Writing the XML file to that given path looks like this:
Dim path = New DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & “\Waterpoints\”)
‘ if the path doesn’t exist create it.
If Not path.Exists Then
path.Create()
End If
‘ create the file name from the path and the text box value.
Dim fileName = System.IO.Path.Combine(path.ToString(), firstNameTextBox.Text & “.xml”)
‘ compile the xml.
Dim xml = <?xml version=“1.0″ encoding=“utf-8″?>
<userrecord>
<firstname><%= firstNameTextBox.Text %></firstname>
<lastname><%= lastNameTextBox.Text %></lastname>
<location><%= locationTextBox.Text %></location>
</userrecord>
‘ write the xml to the file.
xml.Save(fileName)
This code snippet addresses also the second question. There is a line in the code that checks whether the path already exists. If that’s not the case the Create method on the path is executed to create the directory. .NET makes creating paths really easy
The next question was on how to load an XML file. The .NET BCL (Base Class Library) offers a class that’s called XmlDocument. That class allows loading XML files and to search within the loaded files. XmlDocument creates a so called DOM while loading the file. A DOM is a structure that allows navigating and searching.
Dim xml = New XmlDocument()
xml.Load(path)
‘ get the different nodes from the xml file and put them in the text boxes.
‘ ATTENTION: here should also added a check for the values being Nothing.
Dim firstName = xml.SelectSingleNode(“//firstname”)
firstNameTextBox.Text = firstName.InnerText
Dim lastName = xml.SelectSingleNode(“//lastname”)
lastNameTextBox.Text = lastName.InnerText
Dim location = xml.SelectSingleNode(“//location”)
locationTextBox.Text = location.InnerText
For the search part I’m using XPath. XPath is a handy query languages for XML files that searches within the DOM. The code doesn’t do any error handling. In the case of the XPath queries you sould always check if a result is returned. If the query doesn’t find an item this results in returning an object that is Nothing.
The last question was on how to show a list of XML files in a list view. For that I have created a new form: the MainForm. This form holds only a ListView and 3 buttons: one to create a new XML file, one to edit and one to delete an XML file.
The code to load the list looks like this:
‘ remove all items in the list view.
ListView1.Items.Clear()
‘ get the directory. if it does exist get the files from there.
Dim directory = New DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & “\Waterpoints”)
If directory.Exists Then
‘ get all xml files in the given directory.
Dim files = directory.GetFiles(“*.xml”)
‘ loop over the files and add them to the list view.
For Each file In files
Dim listItem = New ListViewItem(Path.GetFileName(file.FullName))
listItem.SubItems.Add(file.FullName)
listItem.Tag = file
ListView1.Items.Add(listItem)
Next
End If
End Sub
This code is a little bit more complex. The complex part is how to fill the ListView with data. The ListView expects a ListViewItem. I set the Text property on that item (via the constructor) to the name of the file (without directories; the Path class offers useful methods to extract different parts of a path) and the first sub item to the FullName of the file (the FullName includes also the directories).
I have also set the file as “tag” of the ListViewItem. That’s handy because later when one of the items is selected I can retrieve the original file object from the tag. You can see the tag as a pocket where you can put one additional object in.

I have also added more code (found in the sample sources) that enables and disabled the edit and delete button depending on whether an item has been selected in the list view.
The full source code of the sample can be downloaded here.
Side note: The example contains no error handling. I haven’t added that because the code gets a lot longer when doing error handling. Error handling should be added to the final application to make it more robust. For an introduction on how to do error handling in VB.NET click here.





