Friday, July 10, 2009

Python in the Android Emulator

I have recently started playing around with the Android platform; more specifically I have begun experimenting with Python development on Android through the Android Scripting Environment (or ASE, as its called).

In ASE you are able to run Python 2.6.2 scripts that, as far as I can tell so far, have full access to the underlying Python libraries. Furthermore, through the "android" module, you gain access to some Android specific things like location services, sensor data, sms messaging, and more.

One problem with ASE though is the fact that it is impossible to run a Python program within the Android Emulator. When you try to start a Python script all you get is a black screen. This is due to some sensor-thingy not being available in the emulator, and the suggested fix is to rebuild ASE with the sensor service disabled.

To spare others of the pain involved rebuilding ASE from source (it is really not that hard, just takes some valuable time away from coding in Python), I will share my build of ASE that actually works in the emulator. You can download it here: ASE Emulator build (do not use this on a real device!). This build is provided as is; I will not be held liable if it blows up your computer, burns down your house, or runs away with your wife ;-)

Tuesday, July 7, 2009

Scavenger demo application released!

I have just released the first Scavenger demo app: AugIM - the Augmented Image Manager. AugIM is an old demonstrator that I made a long time ago, and now I have ported it to use Scavenger for its cyber foraging tasks.


AugIM is an image browser/editor for Maemo (running on Nokia's N800/N810 devices) that allows you to do simple image manipulation tasks such as sharpening, resizing, adjusting color/contrast/brightness, rotating, flipping etc. It also allows you to share your images with the world through email or Google Picasa Web. The N800 and N810 devices are capable of performing these services on their own, but it takes a long time for them to do so and it consumes a very large amount of energy. Using Scavenger, AugIM makes sure that heavy processing is offloaded to larger surrogates whenever possible, which means that the image manipulation tasks are performed faster and using less energy on the mobile device.

Yet another Scavenger build...

I have just uploaded a new self-contained Scavenger daemon build to Scavengers Google Code page. This build is for Mac OS X 10.5 (Leopard) and it contains the same components as the Ubuntu Linux version I released yesterday.

From your Mac simply download the archive, unpack it, and start the start_daemon script from a terminal. Then a Scavenger daemon should be running on your machine, and you are ready to start playing with cyber foraging! :-)

Monday, July 6, 2009

Scavenger build available for Ubuntu 9.04

I have finally gotten around to creating a Scavenger build that you can use to easily experiment with Scavenger, without having to install Stackless Python and other dependencies (e.g., Presence).

The build, which is created and tested to run on Ubuntu 9.04, is available here. All you need to do is 1) download the archive, 2) unpack it, and 3) run the "start_daemon" script.

The "bundle" contains Stackless Python 2.6.2, the Presence python lib and daemon, PIL (Python Imaging Library), Google Data API, and the Scavenger daemon.

Tuesday, June 30, 2009

Timelapse photography using CHDK

I thought it could be fun to do some time-lapse photography now that I have a programmable camera. So I have quickly whipped up a small time-lapse script that works on my Ixus 750:
@title Timelapse
@param a Number of steps
@default a 30
@param b Period (seconds)
@default b 60

rem Sanity check.
if a<1 then let a=1
if b<5 then let b=5
let b=b*1000

rem Take the pictures!
for s=1 to a+1
rem Take a single picture.
print "Shoot", s, "of", a
press "shoot_half"
sleep 2500
press "shoot_full"
release "shoot_full"
release "shoot_half"
print "shot done"

rem Sleep until its time to take the next picture.
sleep b
next s

At the standard setting it takes thirty pictures in roughly 30 minutes.

CHDK oddities

The script I posted in my last post, the one that does exposure bracketing, used to work - I swear it did! But all of a sudden it decided to stop working, and I can't find an good explanation for that at all ;-)

But, instead of an explanation i offer you a fix. The following script _does_ work on my Ixus 750 camera (right now it does anyway):
@title EXP bracketing 
@param a Number of +/- steps
@default a 2
@param b Step size (1/3EV)
@default b 3

if a<1 then let a=2
if b<1 then let b=3

print "Preparing..."
for n=1 to a*b
click "left"
next n

for s=1 to a*2
print "Shoot", s, "of", a*2+1
press "shoot_half"
sleep 2500
press "shoot_full"
release "shoot_full"
release "shoot_half"
print "shot done"
sleep 5000
for n=1 to b
click "right"
next n
next s

print "Shoot", a*2+1, "of", a*2+1
press "shoot_half"
sleep 2500
press "shoot_full"
release "shoot_full"
release "shoot_half"
sleep 5000

print "Finalizing..."
for n=1 to a*b
click "left"
next n

Tuesday, June 9, 2009

CHDK on an Ixus 750

While on paternity leave I have been playing around with my Canon Ixus 750 digital camera. Primarily I have been doing macro (close-up) shots of insects etc., but I also wanted to experiment with other kinds of photography, e.g., High Dynamic Range images (HDR). In HDR you take pictures of the same scene at different exposure levels, and after that a computer program stacks these images to create the HDR image. When taking such pictures it is vital that you do not move the camera, which can be quite hard even if you have a stand for it. I was therefore looking for a software solution to HDR, that would automatically take 3 to 5 pictures at different exposure levels for me, so that Idid not need to touch the camera in between shots.

For that I installed CHDK on my Ixus 750 and I must say that I am impressed. Using the CHDK firmware extension a horde of new features are unlocked (for example the possibility to take RAW images instead of JPEGs). And most importantly CHDK is scriptable, so you may write your own scripts to control your camera.

Based on an example in the tutorial I quickly wrote an HDR script that works on an Ixus 750. When I activate this script my camera snaps five pictures at -2, 1, 0, +1, +2 exposure.
@title EXP bracketing 
@param a Number of +/- steps
@default a 2
@param b Step size (1/3EV)
@default b 3

if a<1 then let a=2
if b<1 then let b=3

sleep 1000

print "Preparing..."
rem click "erase"
for n=1 to a*b
click "left"
next n

click "shoot_half"
sleep 3000
for s=1 to a*2
print "Shoot", s, "of", a*2+1
click "shoot_full"
print "shot done"
sleep 5000
for n=1 to b
click "right"
next n
next s

print "Shoot", a*2+1, "of", a*2+1
click "shoot_full"
sleep 5000

print "Finalizing..."
for n=1 to a*b
click "left"
next n
rem click "erase"

end

In order to use this script the camera must be in manual mode and the exposure menu must be opened...