Open StreetMap and pgRouting on OS X

Add APIDB Schema Support to your database (osm)

/usr/local/pgsql/bin/psql --user osm -d osm -f script/contrib/apidb_0.6.sql

Download the .osm file from cloudmade or openstreetmap.org

Finally, import the file into postgres using the osmosis tool

bin/osmosis --read-xml file=../australia.osm \
--write-apidb host="localhost" database="osm" user="osm"

Which will produce the following output … and it will take a LONG time… it takes a 2-3 gb .osm file (for Australia at least) and loads it into Postgres – resulting in a 100Gb+ database file containing all the nodes, and roads etc.

Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version 0.39
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis run
<div id="_mcePaste">INFO: Pipeline complete.</div>
<div id="_mcePaste">Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis run</div>
<div id="_mcePaste">INFO: Total execution time: 1822346 milliseconds.</div>
Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis runINFO: Pipeline complete.Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis runINFO: Total execution time: 1822346 milliseconds.

Next install pgRouting and load support for the osm database and enable postgis support also


createlang plpgsql osm

psql -U osm -d osm -f postgis-1.5/postgis.sql

psql -U osm -d osm -f postgis-1.5/spatial_ref_sys.sql

psql -U osm -d osm -f routing_core.sql

psql -U osm -d osm -f routing_core_wrappers.sql

osm2pgrouting -file map.osm -conf mapconfig.xml -dbname osm -user osm -clean

SELECT assign_vertex_id('ways', 0.00001, 'the_geom', 'gid');

SELECT gid, AsText(the_geom) AS the_geom
FROM dijkstra_sp('ways', 10, 20);
read more

ASP.NET MVC 3 and DevExpress XPO Integration

The use of MVC 3 and Razor engine has made web apps so much easier to build that previously (in my opinion).  With a couple of custom ModelBinders it’s possible to use strongly-typed XPO with MVC.

I will document this process further here soon.

read more

Project Andromeda

For the last few months I have been working on a UAV project with three other guys – the project is called “Project Andromeda” and the goal is to design and manufacture a small UAV suitable for low-cost civilian aerial operations such as search and rescue, mapping and aerial survey.  The project has been underway for 2-3 years now, and it is nearing the stage of commercialization.

My contribution to the project will be primarily in the software area, writing ground station software and integrating the visionics system.  So far I have taken the existing ground station software to the next level by adding offline mapping through the use of the MapsUI library (mapsui.codeplex.com).  This week I also started working seriously on the visionics, allowing streaming of mpeg video from an mpeg encoder card onboard the aircraft.  This was implemented using a connectionless UDP transfer protocol and is displayed on the pre-existing DirectShow video display.

read more

EmguCV Blob Detection

I wanted to work out an easy way to find possible areas for flying model aircraft.  The minimum area required is around 200m x 200m and by looking at google maps it’s quite simple to see the fields which could service a model plane.  I used OpenCV and the emguCV C# wrappers for it to write a bit of code that will take a google earth map and draw a box around potential locations.  This is v1, and it will no doubt be enhanced with a bit of work – I don’t know that the filters I’m applying are particularly effective, but it works.

Before:

After:

using System;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using System.Drawing;
using Emgu.CV.CvEnum;

namespace EmguThing
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            Image modelImage = new Image(@"c:\Jobs\FindFlightFields\image2.jpg");
            Image grayImage = modelImage.Convert();
            Image laplaceImage = grayImage.Laplace(3);
            Image erodeImage = laplaceImage.Erode(2);
            Image byteImage = erodeImage.Convert();
            Image thresholdImage = byteImage.ThresholdToZero(new Gray(240));
            Image erodeImage2 = thresholdImage.Erode(3);

            MemStorage stor = new MemStorage();
            Contour contours = erodeImage2.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, RETR_TYPE.CV_RETR_TREE, stor);

            Bgr bgrRed = new Bgr(Color.Red);
            while (contours != null)
            {
                Console.WriteLine("Contour # " + contours.BoundingRectangle.Width + " " + contours.BoundingRectangle.Height);

                if (contours.BoundingRectangle.Width > 20 && contours.BoundingRectangle.Height > 20)
                {
                    Rectangle rect = contours.BoundingRectangle;
                    rect.X = rect.X - 10;
                    rect.Y = rect.Y - 10;
                    rect.Height = (rect.Height + 20);
                    rect.Width = (rect.Width + 20);

                    modelImage.Draw(rect, bgrRed, 2 );
                }

                contours = contours.HNext;
            }

            ImageViewer.Show(modelImage);
        }
    }
}
read more

Arduino Cellular Shield + Netduino Support

I encountered a couple of minor issues (aka learning curve) with this shield. 

The documentation doesn’t clearly state the poewr requirements (not that I could see anyway) so I hit a small snag due to low power.  However, once I resolved that issue everything started working instantly.

  1. The cellular shield will draw MORE current than can be provided by USB alone.  You MUST plug the Netduino into a power supply, otherwise the Cellular Shield won’t work, and you’ll waste hours trying to get it to do so.
  2. The version of the Shield I received seemed to differ from the Schematic I downloaded.  It did not have any jumpers.
  3. The version of the Shield I received was hard-wired to use D2 and D3 for serial comms at 9600 baud – some people have reported their modules were configured for 115200, so beware!
read more

Arduino MicroSD Shield + Netduino Support

Currently (November 2010) the Netduino only supports access to this shield through the use of the Alpha version of the firmware.  This will hopefully be updated soon… 

The Shield uses the Arduino / Netduino “standard” SPI pins for data, which are:

D11 – MOSI (master output / slave input)
D12 – MISO (master input / slave output)
D13 – SPCK (serial clock)

There is also a Slave Select – which is hard-coded to D10 on the Alpha firmware, and in the case of the MicroSD shield it is wired to use D08.  A quick workaround for this is to just jumper D8 to D10 and make sure you don’t use either of these pins for other purposes in the time being.

The following code should then mount the SD card successfully:

try
{
        StorageDevice.MountSD("SD1", SPI_Devices.SPI1, Pins.GPIO_PIN_D8);
        mounted = true;
        LED.Write(mounted);
}
catch (Exception Ex)
{
        // Just trying out the exception handling
        Debug.Print(Ex.ToString());
}
read more

Netduinos and Micro Framework

I have a couple of ideas for projects that could be done on the Netduino.  I initially heard about these devices through Scott Hansleman’s podcast a few months ago.  More recently I came up with a few ideas that could leverage the small form factor, with the wireless Xbee networking options.

Having now actually SEEN a Netduino device, I realise they are HEAPS smaller than I imagined.  The possibilities are endless, and I’ve started formulating a plan of action to develop these things into something useful.

Some ideas I have for open source libraries in .NET:

  • Generic GPS library that will handle the various low-level interfaces to the various GPS chips
  • Generic GPRS / SMS library for comms
  • OData provider / consumer for Micro Framework
  • XBee libraries 
  • Hardware driver modules for any shields
The first thing I have noticed is that the Netduino does not have the ICSP pins wired in.  It turns out that the XBee shield requires these for power, so if you want to use these devices with the Netduino, you’re going to have to solder the 6 pin header onto the netduino board.
The hardware devices I have looked at so far are:
  1. Arduino XBee Shield Empty
  2. Cellular Shield with SM5100B
  3. SUP500F 10Hz GPS Receiver
  4. microSD Shield
I think that with these shields I can prototype a huge range of location-aware ideas.

 

read more

DevExpress XpoImport

I have just published my first OpenSource library into CodePlex.  This is a tool for importing data into an XPO data model using class and property attributes on the target object model.  It’s very beta at this stage, but perhaps other people will be able to use the code and help build it into a more useful tool.

The project is hosted at CodePlex http://xpoimport.codeplex.com/

Any feedback would be welcome of course.

read more

SerenityOne Dance Scoring Software

A few months ago I noticed that there was a need for a better way to score and coordinate the scoring of salsa competitions.  I wrote SerenityOne Dance to solve this problem.  I’ve now used SerenityOne at 3 national competitions and 1 state level competition with great feedback from both competitors and judges.

The SerenityOne Dance system is a system for the management and scoring of Dance Competitions. Initially developed to streamline the score calculation for Salsa competitions but has since grown to handle competitor regirstration, scoring, results publication and much more…

The system runs on Microsoft Windows and can be used on a single system, or scaled up to work in a multi-user environment to allow scores to be entered by several operators concurrently.

The use of barcode scanning technology streamlines the entry of scores, which is historically the area of competition scoring that is both time-consuming and error prone.

So far the system has been used at the following events:

 

  • 2010 Australian Salsa Open – calculations only, scoresheets were handled separately.
  • 2010 Australian Salsa Solo Competition
  • 2010 Australian Salsa Classic NSW State Titles
  • 2010 Australian Salsa Classic 

 

I’ve put together a website for the product: http://www.serenityone.com.au/ – Below is a quick demo I put together to show to one event organiser.

A YouTube video of the system in operation…

read more

Binding PictureEdit

The following line of code was causing an unhandled FormatException which Visual Studio was kindly ignoring and was resulting in hours of painful debugging. 

logoEdit.DataBindings.Add("Image", this.competition, "Logo");

I managed to fix the problem by simply changing the code to the following:

logoEdit.DataBindings.Add("Image", this.competition, "Logo", true);

The ‘true’ value is specifying to use formatting for the value.  Not sure why exactly this fixed the problem and I don’t care to spend time on it right now, but hopefully google will pick this up and someone else might find a solution a bit quicker than I did.

 

read more

Open StreetMap and pgRouting on OS X

Add APIDB Schema Support to your database (osm)

/usr/local/pgsql/bin/psql --user osm -d osm -f script/contrib/apidb_0.6.sql

Download the .osm file from cloudmade or openstreetmap.org

Finally, import the file into postgres using the osmosis tool

bin/osmosis --read-xml file=../australia.osm \
--write-apidb host="localhost" database="osm" user="osm"

Which will produce the following output … and it will take a LONG time… it takes a 2-3 gb .osm file (for Australia at least) and loads it into Postgres – resulting in a 100Gb+ database file containing all the nodes, and roads etc.

Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version 0.39
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis run
<div id="_mcePaste">INFO: Pipeline complete.</div>
<div id="_mcePaste">Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis run</div>
<div id="_mcePaste">INFO: Total execution time: 1822346 milliseconds.</div>
Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis runINFO: Pipeline complete.Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis runINFO: Total execution time: 1822346 milliseconds.

Next install pgRouting and load support for the osm database and enable postgis support also


createlang plpgsql osm

psql -U osm -d osm -f postgis-1.5/postgis.sql

psql -U osm -d osm -f postgis-1.5/spatial_ref_sys.sql

psql -U osm -d osm -f routing_core.sql

psql -U osm -d osm -f routing_core_wrappers.sql

osm2pgrouting -file map.osm -conf mapconfig.xml -dbname osm -user osm -clean

SELECT assign_vertex_id('ways', 0.00001, 'the_geom', 'gid');

SELECT gid, AsText(the_geom) AS the_geom
FROM dijkstra_sp('ways', 10, 20);
read more

ASP.NET MVC 3 and DevExpress XPO Integration

The use of MVC 3 and Razor engine has made web apps so much easier to build that previously (in my opinion).  With a couple of custom ModelBinders it’s possible to use strongly-typed XPO with MVC.

I will document this process further here soon.

read more

Project Andromeda

For the last few months I have been working on a UAV project with three other guys – the project is called “Project Andromeda” and the goal is to design and manufacture a small UAV suitable for low-cost civilian aerial operations such as search and rescue, mapping and aerial survey.  The project has been underway for 2-3 years now, and it is nearing the stage of commercialization.

My contribution to the project will be primarily in the software area, writing ground station software and integrating the visionics system.  So far I have taken the existing ground station software to the next level by adding offline mapping through the use of the MapsUI library (mapsui.codeplex.com).  This week I also started working seriously on the visionics, allowing streaming of mpeg video from an mpeg encoder card onboard the aircraft.  This was implemented using a connectionless UDP transfer protocol and is displayed on the pre-existing DirectShow video display.

read more

EmguCV Blob Detection

I wanted to work out an easy way to find possible areas for flying model aircraft.  The minimum area required is around 200m x 200m and by looking at google maps it’s quite simple to see the fields which could service a model plane.  I used OpenCV and the emguCV C# wrappers for it to write a bit of code that will take a google earth map and draw a box around potential locations.  This is v1, and it will no doubt be enhanced with a bit of work – I don’t know that the filters I’m applying are particularly effective, but it works.

Before:

After:

using System;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using System.Drawing;
using Emgu.CV.CvEnum;

namespace EmguThing
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            Image modelImage = new Image(@"c:\Jobs\FindFlightFields\image2.jpg");
            Image grayImage = modelImage.Convert();
            Image laplaceImage = grayImage.Laplace(3);
            Image erodeImage = laplaceImage.Erode(2);
            Image byteImage = erodeImage.Convert();
            Image thresholdImage = byteImage.ThresholdToZero(new Gray(240));
            Image erodeImage2 = thresholdImage.Erode(3);

            MemStorage stor = new MemStorage();
            Contour contours = erodeImage2.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, RETR_TYPE.CV_RETR_TREE, stor);

            Bgr bgrRed = new Bgr(Color.Red);
            while (contours != null)
            {
                Console.WriteLine("Contour # " + contours.BoundingRectangle.Width + " " + contours.BoundingRectangle.Height);

                if (contours.BoundingRectangle.Width > 20 && contours.BoundingRectangle.Height > 20)
                {
                    Rectangle rect = contours.BoundingRectangle;
                    rect.X = rect.X - 10;
                    rect.Y = rect.Y - 10;
                    rect.Height = (rect.Height + 20);
                    rect.Width = (rect.Width + 20);

                    modelImage.Draw(rect, bgrRed, 2 );
                }

                contours = contours.HNext;
            }

            ImageViewer.Show(modelImage);
        }
    }
}
read more

Arduino Cellular Shield + Netduino Support

I encountered a couple of minor issues (aka learning curve) with this shield. 

The documentation doesn’t clearly state the poewr requirements (not that I could see anyway) so I hit a small snag due to low power.  However, once I resolved that issue everything started working instantly.

  1. The cellular shield will draw MORE current than can be provided by USB alone.  You MUST plug the Netduino into a power supply, otherwise the Cellular Shield won’t work, and you’ll waste hours trying to get it to do so.
  2. The version of the Shield I received seemed to differ from the Schematic I downloaded.  It did not have any jumpers.
  3. The version of the Shield I received was hard-wired to use D2 and D3 for serial comms at 9600 baud – some people have reported their modules were configured for 115200, so beware!
read more

Arduino MicroSD Shield + Netduino Support

Currently (November 2010) the Netduino only supports access to this shield through the use of the Alpha version of the firmware.  This will hopefully be updated soon… 

The Shield uses the Arduino / Netduino “standard” SPI pins for data, which are:

D11 – MOSI (master output / slave input)
D12 – MISO (master input / slave output)
D13 – SPCK (serial clock)

There is also a Slave Select – which is hard-coded to D10 on the Alpha firmware, and in the case of the MicroSD shield it is wired to use D08.  A quick workaround for this is to just jumper D8 to D10 and make sure you don’t use either of these pins for other purposes in the time being.

The following code should then mount the SD card successfully:

try
{
        StorageDevice.MountSD("SD1", SPI_Devices.SPI1, Pins.GPIO_PIN_D8);
        mounted = true;
        LED.Write(mounted);
}
catch (Exception Ex)
{
        // Just trying out the exception handling
        Debug.Print(Ex.ToString());
}
read more

Netduinos and Micro Framework

I have a couple of ideas for projects that could be done on the Netduino.  I initially heard about these devices through Scott Hansleman’s podcast a few months ago.  More recently I came up with a few ideas that could leverage the small form factor, with the wireless Xbee networking options.

Having now actually SEEN a Netduino device, I realise they are HEAPS smaller than I imagined.  The possibilities are endless, and I’ve started formulating a plan of action to develop these things into something useful.

Some ideas I have for open source libraries in .NET:

  • Generic GPS library that will handle the various low-level interfaces to the various GPS chips
  • Generic GPRS / SMS library for comms
  • OData provider / consumer for Micro Framework
  • XBee libraries 
  • Hardware driver modules for any shields
The first thing I have noticed is that the Netduino does not have the ICSP pins wired in.  It turns out that the XBee shield requires these for power, so if you want to use these devices with the Netduino, you’re going to have to solder the 6 pin header onto the netduino board.
The hardware devices I have looked at so far are:
  1. Arduino XBee Shield Empty
  2. Cellular Shield with SM5100B
  3. SUP500F 10Hz GPS Receiver
  4. microSD Shield
I think that with these shields I can prototype a huge range of location-aware ideas.

 

read more

DevExpress XpoImport

I have just published my first OpenSource library into CodePlex.  This is a tool for importing data into an XPO data model using class and property attributes on the target object model.  It’s very beta at this stage, but perhaps other people will be able to use the code and help build it into a more useful tool.

The project is hosted at CodePlex http://xpoimport.codeplex.com/

Any feedback would be welcome of course.

read more

SerenityOne Dance Scoring Software

A few months ago I noticed that there was a need for a better way to score and coordinate the scoring of salsa competitions.  I wrote SerenityOne Dance to solve this problem.  I’ve now used SerenityOne at 3 national competitions and 1 state level competition with great feedback from both competitors and judges.

The SerenityOne Dance system is a system for the management and scoring of Dance Competitions. Initially developed to streamline the score calculation for Salsa competitions but has since grown to handle competitor regirstration, scoring, results publication and much more…

The system runs on Microsoft Windows and can be used on a single system, or scaled up to work in a multi-user environment to allow scores to be entered by several operators concurrently.

The use of barcode scanning technology streamlines the entry of scores, which is historically the area of competition scoring that is both time-consuming and error prone.

So far the system has been used at the following events:

 

  • 2010 Australian Salsa Open – calculations only, scoresheets were handled separately.
  • 2010 Australian Salsa Solo Competition
  • 2010 Australian Salsa Classic NSW State Titles
  • 2010 Australian Salsa Classic 

 

I’ve put together a website for the product: http://www.serenityone.com.au/ – Below is a quick demo I put together to show to one event organiser.

A YouTube video of the system in operation…

read more

Binding PictureEdit

The following line of code was causing an unhandled FormatException which Visual Studio was kindly ignoring and was resulting in hours of painful debugging. 

logoEdit.DataBindings.Add("Image", this.competition, "Logo");

I managed to fix the problem by simply changing the code to the following:

logoEdit.DataBindings.Add("Image", this.competition, "Logo", true);

The ‘true’ value is specifying to use formatting for the value.  Not sure why exactly this fixed the problem and I don’t care to spend time on it right now, but hopefully google will pick this up and someone else might find a solution a bit quicker than I did.

 

read more

Open StreetMap and pgRouting on OS X

Add APIDB Schema Support to your database (osm)

/usr/local/pgsql/bin/psql --user osm -d osm -f script/contrib/apidb_0.6.sql

Download the .osm file from cloudmade or openstreetmap.org

Finally, import the file into postgres using the osmosis tool

bin/osmosis --read-xml file=../australia.osm \
--write-apidb host="localhost" database="osm" user="osm"

Which will produce the following output … and it will take a LONG time… it takes a 2-3 gb .osm file (for Australia at least) and loads it into Postgres – resulting in a 100Gb+ database file containing all the nodes, and roads etc.

Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Osmosis Version 0.39
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Preparing pipeline.
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Launching pipeline execution.
Apr 29, 2011 7:29:28 PM org.openstreetmap.osmosis.core.Osmosis run
INFO: Pipeline executing, waiting for completion.
Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis run
<div id="_mcePaste">INFO: Pipeline complete.</div>
<div id="_mcePaste">Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis run</div>
<div id="_mcePaste">INFO: Total execution time: 1822346 milliseconds.</div>
Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis runINFO: Pipeline complete.Apr 29, 2011 8:55:11 PM org.openstreetmap.osmosis.core.Osmosis runINFO: Total execution time: 1822346 milliseconds.

Next install pgRouting and load support for the osm database and enable postgis support also


createlang plpgsql osm

psql -U osm -d osm -f postgis-1.5/postgis.sql

psql -U osm -d osm -f postgis-1.5/spatial_ref_sys.sql

psql -U osm -d osm -f routing_core.sql

psql -U osm -d osm -f routing_core_wrappers.sql

osm2pgrouting -file map.osm -conf mapconfig.xml -dbname osm -user osm -clean

SELECT assign_vertex_id('ways', 0.00001, 'the_geom', 'gid');

SELECT gid, AsText(the_geom) AS the_geom
FROM dijkstra_sp('ways', 10, 20);
read more

ASP.NET MVC 3 and DevExpress XPO Integration

The use of MVC 3 and Razor engine has made web apps so much easier to build that previously (in my opinion).  With a couple of custom ModelBinders it’s possible to use strongly-typed XPO with MVC.

I will document this process further here soon.

read more

Project Andromeda

For the last few months I have been working on a UAV project with three other guys – the project is called “Project Andromeda” and the goal is to design and manufacture a small UAV suitable for low-cost civilian aerial operations such as search and rescue, mapping and aerial survey.  The project has been underway for 2-3 years now, and it is nearing the stage of commercialization.

My contribution to the project will be primarily in the software area, writing ground station software and integrating the visionics system.  So far I have taken the existing ground station software to the next level by adding offline mapping through the use of the MapsUI library (mapsui.codeplex.com).  This week I also started working seriously on the visionics, allowing streaming of mpeg video from an mpeg encoder card onboard the aircraft.  This was implemented using a connectionless UDP transfer protocol and is displayed on the pre-existing DirectShow video display.

read more

EmguCV Blob Detection

I wanted to work out an easy way to find possible areas for flying model aircraft.  The minimum area required is around 200m x 200m and by looking at google maps it’s quite simple to see the fields which could service a model plane.  I used OpenCV and the emguCV C# wrappers for it to write a bit of code that will take a google earth map and draw a box around potential locations.  This is v1, and it will no doubt be enhanced with a bit of work – I don’t know that the filters I’m applying are particularly effective, but it works.

Before:

After:

using System;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using System.Drawing;
using Emgu.CV.CvEnum;

namespace EmguThing
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            Image modelImage = new Image(@"c:\Jobs\FindFlightFields\image2.jpg");
            Image grayImage = modelImage.Convert();
            Image laplaceImage = grayImage.Laplace(3);
            Image erodeImage = laplaceImage.Erode(2);
            Image byteImage = erodeImage.Convert();
            Image thresholdImage = byteImage.ThresholdToZero(new Gray(240));
            Image erodeImage2 = thresholdImage.Erode(3);

            MemStorage stor = new MemStorage();
            Contour contours = erodeImage2.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, RETR_TYPE.CV_RETR_TREE, stor);

            Bgr bgrRed = new Bgr(Color.Red);
            while (contours != null)
            {
                Console.WriteLine("Contour # " + contours.BoundingRectangle.Width + " " + contours.BoundingRectangle.Height);

                if (contours.BoundingRectangle.Width > 20 && contours.BoundingRectangle.Height > 20)
                {
                    Rectangle rect = contours.BoundingRectangle;
                    rect.X = rect.X - 10;
                    rect.Y = rect.Y - 10;
                    rect.Height = (rect.Height + 20);
                    rect.Width = (rect.Width + 20);

                    modelImage.Draw(rect, bgrRed, 2 );
                }

                contours = contours.HNext;
            }

            ImageViewer.Show(modelImage);
        }
    }
}
read more

Arduino Cellular Shield + Netduino Support

I encountered a couple of minor issues (aka learning curve) with this shield. 

The documentation doesn’t clearly state the poewr requirements (not that I could see anyway) so I hit a small snag due to low power.  However, once I resolved that issue everything started working instantly.

  1. The cellular shield will draw MORE current than can be provided by USB alone.  You MUST plug the Netduino into a power supply, otherwise the Cellular Shield won’t work, and you’ll waste hours trying to get it to do so.
  2. The version of the Shield I received seemed to differ from the Schematic I downloaded.  It did not have any jumpers.
  3. The version of the Shield I received was hard-wired to use D2 and D3 for serial comms at 9600 baud – some people have reported their modules were configured for 115200, so beware!
read more

Arduino MicroSD Shield + Netduino Support

Currently (November 2010) the Netduino only supports access to this shield through the use of the Alpha version of the firmware.  This will hopefully be updated soon… 

The Shield uses the Arduino / Netduino “standard” SPI pins for data, which are:

D11 – MOSI (master output / slave input)
D12 – MISO (master input / slave output)
D13 – SPCK (serial clock)

There is also a Slave Select – which is hard-coded to D10 on the Alpha firmware, and in the case of the MicroSD shield it is wired to use D08.  A quick workaround for this is to just jumper D8 to D10 and make sure you don’t use either of these pins for other purposes in the time being.

The following code should then mount the SD card successfully:

try
{
        StorageDevice.MountSD("SD1", SPI_Devices.SPI1, Pins.GPIO_PIN_D8);
        mounted = true;
        LED.Write(mounted);
}
catch (Exception Ex)
{
        // Just trying out the exception handling
        Debug.Print(Ex.ToString());
}
read more

Netduinos and Micro Framework

I have a couple of ideas for projects that could be done on the Netduino.  I initially heard about these devices through Scott Hansleman’s podcast a few months ago.  More recently I came up with a few ideas that could leverage the small form factor, with the wireless Xbee networking options.

Having now actually SEEN a Netduino device, I realise they are HEAPS smaller than I imagined.  The possibilities are endless, and I’ve started formulating a plan of action to develop these things into something useful.

Some ideas I have for open source libraries in .NET:

  • Generic GPS library that will handle the various low-level interfaces to the various GPS chips
  • Generic GPRS / SMS library for comms
  • OData provider / consumer for Micro Framework
  • XBee libraries 
  • Hardware driver modules for any shields
The first thing I have noticed is that the Netduino does not have the ICSP pins wired in.  It turns out that the XBee shield requires these for power, so if you want to use these devices with the Netduino, you’re going to have to solder the 6 pin header onto the netduino board.
The hardware devices I have looked at so far are:
  1. Arduino XBee Shield Empty
  2. Cellular Shield with SM5100B
  3. SUP500F 10Hz GPS Receiver
  4. microSD Shield
I think that with these shields I can prototype a huge range of location-aware ideas.

 

read more

DevExpress XpoImport

I have just published my first OpenSource library into CodePlex.  This is a tool for importing data into an XPO data model using class and property attributes on the target object model.  It’s very beta at this stage, but perhaps other people will be able to use the code and help build it into a more useful tool.

The project is hosted at CodePlex http://xpoimport.codeplex.com/

Any feedback would be welcome of course.

read more

SerenityOne Dance Scoring Software

A few months ago I noticed that there was a need for a better way to score and coordinate the scoring of salsa competitions.  I wrote SerenityOne Dance to solve this problem.  I’ve now used SerenityOne at 3 national competitions and 1 state level competition with great feedback from both competitors and judges.

The SerenityOne Dance system is a system for the management and scoring of Dance Competitions. Initially developed to streamline the score calculation for Salsa competitions but has since grown to handle competitor regirstration, scoring, results publication and much more…

The system runs on Microsoft Windows and can be used on a single system, or scaled up to work in a multi-user environment to allow scores to be entered by several operators concurrently.

The use of barcode scanning technology streamlines the entry of scores, which is historically the area of competition scoring that is both time-consuming and error prone.

So far the system has been used at the following events:

 

  • 2010 Australian Salsa Open – calculations only, scoresheets were handled separately.
  • 2010 Australian Salsa Solo Competition
  • 2010 Australian Salsa Classic NSW State Titles
  • 2010 Australian Salsa Classic 

 

I’ve put together a website for the product: http://www.serenityone.com.au/ – Below is a quick demo I put together to show to one event organiser.

A YouTube video of the system in operation…

read more

Binding PictureEdit

The following line of code was causing an unhandled FormatException which Visual Studio was kindly ignoring and was resulting in hours of painful debugging. 

logoEdit.DataBindings.Add("Image", this.competition, "Logo");

I managed to fix the problem by simply changing the code to the following:

logoEdit.DataBindings.Add("Image", this.competition, "Logo", true);

The ‘true’ value is specifying to use formatting for the value.  Not sure why exactly this fixed the problem and I don’t care to spend time on it right now, but hopefully google will pick this up and someone else might find a solution a bit quicker than I did.

 

read more