Feb 22, 2010

Google Earth 5 on Fedora 12: GLIBCXX_3.4.9 not found

After upgrading to Fedora 12 I decided to upgrade Google Earth to version 5 as well. Now google-earth doesn't want to start, saying the following:

./libstdc++.so.6: version `GLIBCXX_3.4.9' not found 

Note the path to libstdc++.so.6. It is not using the system one provided by the libstdc++-4.4.3-4.fc12.i686 package, instead it used one that came with Google Earth 4 and was not cleaned up during GE 5 install. The problem was really that GE 4 wasn't cleaned up at all and GE 5 was installed over it. Can't wait for Google to start shipping it as a real package. The solution is to uninstall GE 4 first by running the command below, then install GE 5.

~/.loki/installed/bin/Linux/x86/uninstall google-earth

Note: this applies to the user-installed version, although I am sure there is a similar uninstall tool when installed system-wide.

Feb 1, 2010

Hugin and autopano-sift-c

Hugin is an awesome panorama photo stitcher. It can optionally use a helper program - autopano-sift-C - to pre-align the photos into a panorama automatically. Autopano searches for common elements (called control points) between all the images and feeds them back to Hugin to put the puzzle together. Hugin works fine without it, but in that case control points need to be created manually, which can be a laborious task.

The autopano-sift-C program is not shipped with Fedora because it is patent-encumbered in the US (the SIFT algorithm it uses is patented by the University of British Columbia). It can be found, however, as an RPM package in the RPM Fusion repository.

At this time Hugin has a problem loading more than 124 images at a time when autopano-sift-C is in use. You get the following error message:

Could not execute command: autopano-sift-c

If you look in the X session errors there's this:
$ tail -2 ~/.xsession-errors
...AutoCtrlPointCreator.cpp:1a7) automatch(): Too many arguments for call to wxExecute()
...AutoCtrlPointCreator.cpp:1a8) automatch(): Try using the %s parameter in preferences
The problem is that autopano-sift-c takes the image names separately on the command line and Hugin can't pass more than 127 parameters to it (this being a limitation of the toolkit it uses). The quick and dirty solution is to use an external script to convert a file containing image filenames to parameters:
#!/bin/bash
# Change Hugin Preferences -> Autopano as follows:
# Autopano-SIFT: path to this script
# Arguments: --maxmatches %p %o %namefile
dos2unix $4
exec autopano-sift-c --align $1 $2 $3 `cat $4`

And voila! Hugin can now load and prealign very large image sets. If you have spaces in filenames then you might need to massage that last part a bit to quote each name, but otherwise this should work just fine.

Oct 25, 2009

Running GIMP Python plugins in batch mode

In the previous entry I wrote about creating GIMP plugins in Python. This follows up on that by showing the bit of magic for running one of these plugins in batch mode from the command line. You need to provide values for each positional parameter defined for the plugin. It helps if the plugin has been designed with batch mode in mind.
gimp -ib '(python-fu-mylogo-batch RUN-NONINTERACTIVE "in.jpg" "out.jpg" "Made by me" 50 "Sans" 24)(gimp-quit 1)'
The language used is TinyScheme, I don't know how to use Python in this mode, but it matters very little. Any function defined in the PDB can be called including of course Python functions. Add --verbose to the command line to see the execution flow. As a side note, you can use the following command to start the PDB browser directly without going through the GIMP UI:
gimp -ib '(plug-in-dbbrowser RUN-INTERACTIVE)(gimp-quit 1)'

To make a batch mode function, add a function that opens the image, calls the main plugin function and then saves the result. Register this function also, probably under "<Image>/Tools" this time.
def mylogo_batch(infile, outfile, text, opacity, fontname, fontsize):
img = pdb.gimp_file_load(infile, infile)
pdb.python_fu_mylogo(img, text, opacity, fontname, fontsize)
pdb.gimp_image_flatten(img)
drawable = pdb.gimp_image_get_active_layer(img)
pdb.gimp_file_save(img, drawable, outfile, outfile)
pdb.gimp_image_delete(img)

The batch plugin can be invoked from the UI also, a file selection dialog will prompt the user to choose the input and output and so on.