Showing posts with label Web Start. Show all posts
Showing posts with label Web Start. Show all posts

Friday, 20 August 2010

Broken Applications

So I've written my own fair share of bugs into software in the past but I hate it when I come up against bugs in software that I have absolutely no control over. Unfortunately these bugs might bite you as well as me.

I've released a number of bits of software through this blog that use Java Web Start to make it easier for you to download and install them. Unfortunately there appears to be a number of bugs which result in the installed shortcuts breaking and even causing the launch link on the web page to not work if you have previously run the application.

Well I upgraded PhotoGrid yesterday and everything broke. I'm assuming it may have broken for everyone else as well. It took me a while to figure out what went wrong and how to fix it so I thought I'd write it up here in case I've broken it for everyone else.

We can fix the problems using the Web Start cache viewer, which you can load by issuing the command javaws -viewer (on Windows you can enter this command into the Run... dialog box accessed from the Start Menu), and which should look like...


Now select the application that won't start and click the red cross button to uninstall it. Even though it will now have been uninstalled Web Start still remembers some details which can be a problem. So in the drop down box at the top left switch to viewing Deleted Applications. A similar list will appear and go through the same steps (select and the red cross) to fully delete the application. You should now be able to re-install without any problems.

The problem only seems to arise when I have to edit the JNLP file that is used to launch the applications. Updating the actual code works flawlessly. On the plus side it is quite rare for me to need to edit the JNLP files and so I'm hopeful that once the applications are working again they should continue to work for the foreseeable future.

Apologies for any inconvenience and I hope it doesn't put you off using the bits of software I write.

Friday, 16 July 2010

3DAssembler

Since the beginning of the year, and after reading A Village Lost and Found, I've been dabbling a little in 3D photography. From the results so far (first attempt, second attempt) I'm certainly no T. R. Williams, but it has opened up a range of interesting photography ideas that I'd never previously considered.

Taking good sequential stereo views (where you take the view for one eye and then move and take the second view) is difficult enough but combining them correctly to produce a good stereocard is as difficult, if not more so. You have to align the images both vertically and horizontally, and crop out sections that don't appear in both views. When you have two aligned views you still need to decided on which 3D format you want to display the images; parallel, cross-eyed, red-cyan, amber-blue ...

Of course, as with previous problems, the answer, as far as I'm concerned, is to write a piece of software to either 1) do the work for me or 2) make life as easy as possible. So without further ado let me show a screenshot of 3DAssembler.


This shows the side-by-side editing mode. There is also an overlayed editing mode as well as a preview mode to see the final 3D result. 3DAssembler currently supports four 3D formats; parallel and cross-eyed for freeviewing (i.e. without any special glasses) and two anaglyph formats, red-cyan and amber-blue. Lots of people have red-cyan glasses kicking around (I have four pairs from the Shrek +3D DVD, as well as a pair that came with the programme for The War of the Worlds live show) that you can use with 3DAssembler. The amber-blue anaglyphs can be viewed using ColorCode 3D glasses, which are becoming a popular way of presenting 3D content as they give better colour re-production than red-cyan (I have a pair of ColorCode 3D glasses I got free with a TV guide so I could watch a 3D episode of Chuck). Given that pictures are often easier to understand than words (certainly my words) here are examples of the four output formats for you to try viewing; parallel, cross-eyed, red-cyan and amber-blue respectively.

So if that has whetted your appetite for 3D photography you can download 3DAssembler and have a play around. If you haven't any photos to try it with then there are some example photos included in the download.

If you have any comments/suggestions about 3DAssembler or ideas for future versions then please leave a comment and I'll see what I can do.

v2.2.1 - 09/12/2014: Re-packaged so that there is an easy download available given that it is almost impossible to launch a Java programme from within a modern web browser.
v2.1.0 - 04/12/2010: You can now create portrait 3D views without having to use an external program to rotate the images. This release also includes a fix for a memory leak which should make the application more responsive.
v2.0.0 - 11/09/2010: You can now use zooming to help align the images properly, you can also now specify the exact values for the three alignment options using the advanced ribbon. The final image can also be cropped which helps to remove items that only appear in one view. There is also a custom anaglyph option where you can specify how the RGB channels should be produced. Added support for importing and exporting stereo versions of JPEG (*.jps) and PNG files (*.pns). There are also lots of performance enhancements and bug fixes.
v1.4.0 - 20/08/2010: Mostly bug fixes and a few bits of updated artwork. Also you should now find that 3da files are linked to the application so you can open a saved project easily.
v1.3.0 - 07/08/2010:You can now configure the auto layout feature based on the scene type and restrict the directions in which the images are aligned. There are also quite a few performance enhancements which should make the application work a lot faster. I've also opened up the source code -- you can get all the details from the Hudson project.
v1.2.0 - 22/07/2010: Quite a few bug fixes and error handling but the main improvement is that it is much easier to now move the images around using sliders instead of buttons.
v1.1.0 - 18/07/2010: A few bug fixes, but I've also added a green-magenta anaglyph format which should work with TrioScopics3D glasses (I've got four pairs that came with the Coraline DVD). I don't think this format is as good as either red-cyan or amber-blue but I've added it for completeness. Here is the same example as before in this new format:
v1.0.0 - 16/07/2010: First public release

Monday, 9 November 2009

The Trotternish Pumpkin

Question: What does the Trotternish peninsula of Skye and a pumpkin have in common?
Answer: The images in the two blog posts were assembled using PhotoGrid!

When I was writing the blog post about our trip around the Trotternish peninsula I looked high and low for software to easily create a grid of photos. I found a few options but they were either a) a feature in a huge piece of software or b) not able to create the kind of image I wanted. Of course this could mean only one thing... I'd have to write the software myself.

The image in the Trotternish blog post was from the first, very basic version of what I'm now calling PhotoGrid -- it arranged the photos in a grid with the only option being the number of rows. The software has advanced quite a bit since then as you can tell if you look at the image in the pumpkin post. Here is a screenshot of the latest version:
There are still lots of things that I would like the program to do that it doesn't but hopefully I'll find the time to add new features soon. For now at least the main features are:
  • Auto-arrange will attempt to separate images of a similar colour to produce a more appealing grid -- for example, if your photos are either mostly white or mostly black you will end up with a chequer board pattern.
  • The border colour is determined by working out the average colour of the photo as this is unlikely to clash with the photo.
Eventually I'll clean up the code and release it but for now you can and use the software to create your own grids.

If you have any comments/suggestions about PhotoGrid or ideas for future versions then please leave a comment and I'll see what I can do.
v1.0.0 - 19/08/2010:Lots of bug fixes and performance improvements. Some new artwork and better error handling. There were some changes to the way in which the application can be started from this page. If you have used the application before and now it won't start, sorry, but see this post for details on how to fix things.

v0.4.0 - 06/01/2010:Almost no code changes but this release coincides with the opening up of the source code.

v0.3.1 - 30/01/2010:Quite a few performance improvements and real feedback on progress of loading images or saved projects. You can also now choose auto to reset the border colour to the default.

v0.3.0 - 24/01/2010:You can now customize each tile (or a set of tiles) by right clicking on them. This allows you to set the border colour and specify a title and URL which can be used to produce a HTML image map. Also when saving the grid you now have some control over the size of the generated image.

v0.2.2 - 20/01/2010:Fixed a small bug in v0.2.1 and some serious refactoring that will make the new features easier t0 implement.

v0.2.1 - 18/01/2010:More code simplification, added an extra theme colour (the average colour across all photos), and added some code in preparation for new features I'm intending to add soon.

v0.2.0 - 12/11/2009: Simplified a lot of the code but more importantly removed the assumption that images were always 4:3. Each tile is now assumed to have the same aspect ratio as the first tile in the grid.

v0.1.1 - 10/11/2009: The only change in this release is to use all known JPEG file extensions (ignoring case) when filtering the file list whilst trying to add photos.

v0.1.0 - 09/11/2009: First public release of PhotoGrid.

Thursday, 16 October 2008

Compiled Code Compiles Code

Now and again I try and do something that stretches the limit of a programming language. This usually results in a very bad headache and days of frustration.

At work I have been developing a rule based document annotation system called Saxon. The rules are loaded into the system and converted to Java code which is then compiled, loaded into the running instance of Java and then used to annotate the documents. If you are already getting a headache I'd stop reading here as this post is only going to get more confusing!

For a long time there was no standard way of having a running Java program compile and then use new classes. The only way was to write the source files to disk, call the command line compiler and then create a new class loader to load the compiled classes into memory. Not a simple way of doing things.

With Java 6 Sun introduced a standard API for compiling that was supposed to make life easy. Once you know how the new API works it is in fact very easy to use. On the plus side you can now easily do in-memory compilation which is much faster than reading and writing to disk, but of course you are restricted to using Java 6 which not everyone has upgraded to yet.

Unfortunately there is a much more serious problem. Sun, in their infinite wisdom, decided that compiling code was something only developers would want to do and so only bundle a concrete implementation with the JDK and not the JRE which means that applets and Web Start applications don't have access to a compiler.

Fortunately Eclipse provide the JDT Core Batch Compiler which includes a Java 6 complient compiler. This works great in standalone apps, allowing me to run Saxon from a JRE and still have all the functionallity I need.

However, I was trying to make Saxon available as a Web Start application and ran into a bit of a problem. There is something very strange with the class loading in the Eclipse compiler. It works fine in a standalone application but under Web Start the compiler can only see core Java classes which means I can't reference my own API from the classes I'm trying to compile and everything fails and I end up back at square one.

Don't despair though as their is a solution. Throw away the Java 6 API and use the Eclipse compiler directly. This has the advantage of working under Web Start and under previous Java versions (at least version 5 which is more commonly installed than 6). I can't take all the credit for this solution but I thought it worth blogging about as I'm yet to see anything similar any where else on the web, although I did find lots of posts asking how to do this.

The following code is cobbled together from two main sources; Apache Tomcat and GATE. I actually used the GATE code, which is based on Tomcat code, as my starting point and then simplified it and added some generics support.

You can download the full compiler (a single Java source file and the JDT Batch Compiler) from here. And here is a simple example of how to use it (this is actually the main method of the class for easy testing).
EclipseCompiler compiler = new EclipseCompiler();

String HELLO_WORLD_CLASS_NAME = "HelloWorldTest";
String HELLO_WORLD_SOURCE = "import org.eclipse.jdt.internal.compiler.Compiler;\n\n" +
"public class "+HELLO_WORLD_CLASS_NAME+"{\n" +
" public static void main(String[] args) {\n" +
" System.out.println(\"Hello world\");\n" +
" }\n" +
"}";

Class compiledClass = compiler.compile(HELLO_WORLD_CLASS_NAME, HELLO_WORLD_SOURCE);

if (compiledClass==null)
{
System.out.println("Unable to compile file");
return;
}

Method m = compiledClass.getMethod("main",String[].class);
m.invoke(null, new Object[]{null});
The interesting thing to note is that the small test case imports a class not from the core Java APIs and this works in standalone applications and when run under Web Start.

Sunday, 12 October 2008

TagME: A Tutorial

While I think TagME is easy to use I'm guessing that for everyone else a simple tutorial introducing the main concepts would be quite useful, so here goes.

Start by downloading and unzipping the sample GPS track and photos and then TagME.

Now follow these five simple steps to geotag and display the photos:
  1. First we need to load the GPS track file. Click on to bring up a file open dialog and open the track1.gpx file you downloaded. The track details should then appear in the left hand list.
  2. By default the time zone is set to your current location. To properly locate the photos on a map the time zone must be set to the time zone in which the pictures were taken. For the sample images the time zone should be set to "Europe/London". The time zone will default to your local time zone but if this isn't correct then click the button to select the correct time zone.
  3. Now we need to load in the sample photos. Click on the to bring up a directory chooser and select the directory in which you unzipped the sample photos. Once the photos have loaded they should appear in the left hand list.
  4. With the sample images you will notice that the last image in the list is labelled as not appearing within the GPS track. This is because the clock on my camera and the GPS clock are about 2 minutes different to each other. To fix this and shift all the photos to the correct time (and hence position) click on the and then adjust the time to -2 minutes and choose to adjust the time for all the photos then click OK.
  5. That is it you have now worked out where each photo was taken. If you just want to add GPS coordinates to the photos then you can do this by clicking on . More likely though, you want to see on a map where the photos were taken. If you are on Windows and have Google Earth installed then you can click on to preview the output in Google Earth. If not then you can click on to export to a KMZ file which you can then load manually.
That is how simple TagME is to use. Of course you can customize the output further. Clicking on either of the buttons will allow you to edit details of the selected track or photo -- giving them names and/or descriptions. You can also save your project so that you can come back and continue editing it at a later date.

Saturday, 11 October 2008

TagME

Well it took me a little longer than I originally planed but here is the first version of my new software project, TagME.

TagME is designed to solve all the geotagging problems I was having with the software that came with the GPS recorder I blogged about last month.

The main issue with the software that came with the GPS recorder was that when geotagging photos the output only worked in Google Earth and not with Google Maps. This first version of TagME fixes that problem by exporting to a KMZ file which can be displayed in either Google Earth or Maps (the ME in TagME stands for Maps and Earth -- clever don't you think!). I've also added support for setting the timezone (the GPS times are always in UTC, which is the same as GMT) which while possible in the bundled software was not very straightforward.

I will, however, be the first to admit that TagME is far from perfect. To start with there is as yet very little error checking going on so I expect you could quite easily crash the programme -- this will be my first priority for the next version. The main glaring omission is that there is no visualisation or ability to edit the GPS track data. Currently you can click a button to show the data in Google Earth (if you have it installed and are running Windows) but this takes a while and isn't ideal. Some form of track editor is definitely high on the list of features that need implementing as well as the ability to customize the photo bubbles as the current formatting is very boring.

I still think it is easier to use and produces better results than the bundled software so altogether not too bad for a fortnights work. Given the shocking state of the code at the moment I'm just making the executable version available which you should be able to run simply by clicking the shiny orange launch button.
You can also download a sample GPS track file and some photos to play with (note that I reckon the time offset for the photos should be -2 minutes).

Sunday, 7 October 2007

Convert4Frame

Although I was probably the last person I know to move from film to digital photography I have now fully embraced the new format. In fact I haven't really used my film camera at all since I bought my first digital camera.

The one downside to a digital camera is that I print far fewer photos than before and so the photos I take tend to sit neglected on my computer. To try and solve this problem and to allow me to appreciate the photos I have been taking I went and bought a digital photo frame. Not knowing how much I would use it I opted for the cheapest one Amazon had to offer at the time and ended up with a 7" frame from ATMT (model number 7TFTDPF). For the price I paid it is an excellent frame and has been great for showing off the photos I take.

The only problem with the frame is converting the photos to fit the screen size. The frame is widescreen and requires the photos to be both cropped and resized before it will show them correctly and make full use of the visible area of the frame. Now you can do the resizing and cropping in any image editor but it becomes tedious if you want to convert a number of photos at once.

So given that I'm a software engineer I set about solving the problem by developing a small program to do the tedious work for me! The result was the aptly titled Convert4Frame application. In essence this application allows you to easily define the part of a photo you wish to display in the frame and then resizes and crops the original for you. To use the application simply it direct from this page.

Currently it is designed to work with the 7" frames from ATMT, but it should correctly resize your photos for any digital frame with a native resolution of 480x342 (or any multiple of). Let me know in the comments if it works with your frame, or if you have a frame which requires different resizing/cropping let me know the details and I'll add support for it.

Update (06/02/2010): I've moved the code into a publicly accessiable SVN repository, see here for details.

Update (30/12/2007): I've made a number of small changes which should deal with the few cases in which the image wasn't correctly filling the display area (basically the image is now scaled down to the frame size).