Tuesday, 15 December 2009

Animation

Laura and I have been experimenting with stop-motion animation - set up a camera on a tripod with a remote shutter release, then position a scene in front of it, and change it by a very small amount between shooting frames.
10 frames per second seems to work ok for what we are doing (and you get more video for your money, so it is a bit more rewarding!).
I am using mencoder to turn the jpeg images from the camera into a mpeg4 video using the following:

mencoder mf://*.JPG -mf fps=10 -o leaves.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800 -vf scale=640:480

This produces an mpeg4 encoded .avi file, scaled to 640x480 pixels.
You can then run mencoder again to add a mp3 audio stream.
The results can be seen at http://flickr.com/jones139.

Sunday, 29 November 2009

Town Guide (again)

Progress with the Town Guide program stalled a bit when I went on holiday, then was rather busy at work for a while. I am back to thinking about it now.
The current version has two output modes, HTML and PDF - both are quite crude, but work.
The PDF output uses LaTeX, which seemed like a good idea at the time, but I am struggling because LaTeX thinks it knows better than me what the output is supposed to look like - it keeps putting the tables etc. at the end, rather than where I ask for them.
This means I have two options - either do battle with LaTeX to sort it out, or abandon it and go for a more 'direct' PDF production.
I think that as the output I am producing is short and simple, I may as well go for 'direct' production. I am going to have a try with ReportLab's python library (http://www.reportlab.org/oss/rl-toolkit/guide/).
I'll go and read the instructions and see how it goes....

Sunday, 4 October 2009

Free Town Guide

For ages I have been intending to write a program to produce a nice guide to a town or area based on OpenStreetMap data.
I finally decided that I knew enough about postgresql and python to have a go.
The result is a program called townguide.py. The idea is that you load the openstreetmap data into a postgresql database (like you do if you want to render it using Mapnik), then produce an xml file to tell townguide.py what you want rendering. It then goes and produces the nice output for you.
Version 0.1 is working and is on SVN. At the moment it only produces html output (because that is easy), and it is not very pretty.
The next stage is to make it produce postscript to give nice printable output on a defined paper size.
An example of the html output is at http://hartlepoolmap.webhop.net.

Having looked at the output it looks like it will be quite useful from a mapping point of view - if you know the area you can review the features that are summarised and look for missing banks, supermarkets etc.

Saturday, 19 September 2009

Using a Graphics Tablet in Ubuntu 9.04

I have a cheap Trust graphics tablet that I used to use for drawing in Inkscape or Gimp.
It stopped working at some point (Can't remember which Ubuntu version), but I decided I needed to use it again, because drawing with a touchpad on a laptop is a pain in the thumb...
It was surprising that it didn't just work when you plug it in, because I'm sure a previous version of Ubuntu behaved like this.
I found the instructions at https://help.ubuntu.com/community/AiptekTablet.
You basically have to install the Aiptek xorg driver and put a configuration file in a directory under /etc/hal. I wondered where the X11 configuration was now that Xorg.conf is so small....

Anyway, it works now...

Sunday, 6 September 2009

Progress with IP Camera Viewer

The Edimax IP Camera seems to work fairly well, but the video stream seems to get interrupted every now and again, which makes the player crash - vlc just hangs, and mplayer exits.
I decided that exiting was better so I have written a simple pyGTK front end for mplayer to play the screen. It also includes a wireless network link quality monitor to help understand why it is not working - it is here as 'bentv'.

Note that bentv uses a library that I have started work on (named ntpylib for want of a better name) - so far it only contains one class, 'prefs', which deals with saving and loading of simple key/value data from XML files. It includes a dialog box that GUI programs (such as bentv.py) can use to allow the user to edit the data. prefs.py and prefs.glade need copying or linking into the bentv directory to make it work - there is no clever installer!

Sunday, 23 August 2009

Embedded Linux Firmware Binary Files

I have always struggled to understand the format of the binary files that store the firmware upgrades.
They tend to be a mixture of some simple text labels, a kernel image and one or more mountable filesystems.
I have written a little script that goes through a file in a brute force (one byte at a time) way and attempts to mount it as various filesystem types (script stored here).
I used the information found by this script, and the source code provided by Edimax to work out some information about the internals of the IC-3010WG IP Camera - it is written up here.

Saturday, 22 August 2009

Practical Experience using the Edimax IP Camera

We were away on holiday last week so I got to try using the Edimax IP camera 'for real' as a monitor to keep an eye on our disabled son - known as 'BenTV-ng' (next generation) to distinguish it from 'BenTV' which was the old analogue system I used to use.

I gave up on using ad-hoc networking and instead took my wireless access point with me. This had the added advantage of improving the range of transmission because I could arrange for the access point to be between the camera and the computer. The computer I used was a Toshiba netbook running Ubuntu Linux.

The first thing I noticed was that when I powered everything up, nothing happened. At first I thought it was because the access point needed to see a wired connection as well as a wireless one, because when I connected the computer to it using a wire things started to work. I soon realised that the range was awful - it stopped working as soon as you were outside of his room. This turned out to be my fault because I had also switched on the analogue camera, which transmitted on the same frequency as the wireless network, so the noise level was huge. Things got better when I switched off the analogue camera.

At first everything appeared to work - vlc rtsp://admin:1234@bentv/ipcam.sdp played the video stream with sound.
I soon noticed that if the network got interrupted vlc froze, giving an apparently good picture, but no movement, which was no use to me. Instead I changed to mplayer - at least if that got into trouble it crashed and closed the video playback window so you knew something was wrong.

I set up a simple shell script that loops indefinitely starting mplayer then when mplayer exits it re-boots the ip camera, waits for 30 seconds and starts mplayer again.
This approach worked pretty well - the 30 second interruptions during the re-boot were not usually too troublesome.

We did find some problems when the video stream only worked for a few seconds before mplayer exited and the re-boot sequence started again, which was no good at all. The only way I found to cure this was to power off the camera all together - a software re-boot via the web interface did not cure it. I'll set up a little test at home now to see how long it takes to get into this state, and whether it makes a difference if you use wireless or wired networking.

The code to achieve this is stored at http://code.google.com/p/ntmisc/source/browse/bentv/.

The most up to date information I have on using this camera with linux can be found at http://ic-3010wg.webhop.net.

Friday, 24 July 2009

Ad-Hoc Wireless Network Troubles

Now that I have the Edimax IP Camera working I want it to connect to my Toshiba NB100 netbook computer as simply as possible - the idea is to use it when we are away on holiday so I don't want to have to set up a whole network with an access point etc. Instead I just want to set up an ad-hoc network between the computer and the IP Camera.
According to the instructions this should be easy - I tell the IP Camera to connect to an ad-hoc network called 'bentv', and then use NetworkManager in the Ubuntu desktop of the netbook to create the ad-hoc network.
This works fine on my main laptop, but fails on the netbook.
It turns out that NetworkManager is not capable of putting the wireless card into ad-hoc mode.
The work around was to have the script to start the VLC viewer shutdown network manager and set up the network manually as follows:

#!/bin/sh
/etc/init.d/NetworkManager stop
ifconfig ath1 down
wlanconfig ath1 destroy
wlanconfig ath1 create wlandev wifi0 wlanmode adhoc
iwconfig ath1 essid bentv
iwconfig ath1 channel 1
iwconfig ath1 192.168.1.35
iwconfig ath1 netmask 255.255.255.0
ifconfig ath1 up

vlc --fullscreen rtsp://192.168.1.17/ipcam.sdp

/etc/init.d/NetworkManager start

This is based on information I found here.
This seems to work, but the wireless networking is a bit iffy after the script exits - I might have to do the wlanconfig destroy bit again to put it into infrastructure mode.

Sunday, 12 July 2009

More on Edimax IP Camera

I think we're getting somewhere. Searching around for references to IP cameras and mplayer yielded this thread which suggested the following:

mkfifo fifo.mpeg4
wget -q http://admin:1234@192.168.1.117:4322 -Ofifo.mpeg4 &
mplayer -V -demuxer 35 fifo.mpeg4
This seems to work ok - there is a bit of a delay in the video, but probably ~0.1 sec, which is acceptable.
Progress!
Just need to get sound working now....

Well, I did a bit more hunting around in the camera web set-up and realised I had missed a section about RTSP. The default was for RTSP to be enabled on port 554 with a rtsp path of ipcam.sdp.
When I tried

mplayer rtsp://192.168.1.117:554/ipcam.sdp

I got pictures AND sound!
I had tried rtsp before, but had missed the ipcam.sdp bit. Mplayer complains that my little netbook is too slow to play the stream, so there is a bit more work to do, but it looks promising. I'll try VLC now.

The most up to date information I have on using this camera with linux can be found at http://ic-3010wg.webhop.net.

Saturday, 11 July 2009

Edimax IC-3010Wg yet again

Still struggling with my IP Camera. Although mplayer can sort of play the mp4 stream, it does not seem reliable and takes a long time to start to play, so I do not think it is working correctly. I think I'll try the Edimax support, but have upgraded from version 1.20 to 1.25 of the firmware first, because they are bound to ask if I am using the latest software....

Thursday, 9 July 2009

Edimax IC-3010Wg again

I have made a bit more progress getting my Edimax IP Camera working, and detailed what I have learned at http://ic-3010wg.webhop.net.

The main problems are still that although I can download an MPEG4 stream using wget, neither mplayer nor vlc will play it directly, which is no good.
The other issue is that sound still does not work.....

Tuesday, 7 July 2009

Edimax IC-3010Wg IP Camera and Linux

I have just got an Edimax IC-3010Wg IP Camera. I intend to use it as a replacement for the analogue video system we use to keep an eye on our disabled son.
I was rather disappointed to find that it does not work with Firefox - you need an Internet Explorer ActiveX control to view the video images. This means it will not work on my Linux computers as supplied by the manufacturer.

What works:
  1. The camera gets its network configuration by DHCP (despite what the quick start guide says) so by checking the DHCP deamon log you can find its IP address.
  2. You can access its configuration screen with a web browser (default username admin, password 1234)
  3. Receive a snapshot picture using http:///snapshot.jpg
  4. Download a mjpeg video stream using wget http://admin:1234@192.168.1.117/mjpg/video.mjpg. (I don't know how to display this in real time though - mplayer doesn't seem to work).
  5. Some other things are detailed here.
  6. Someone has written a tcl application that works with a similar camera, but not this one (see here).
I think I am going to end up writing something based on the tcl application shown above to display live video with sound, which is what I need. If anyone knows an off-the shelf one, please let me know!

The most up to date information I have on using this camera with linux can be found at http://ic-3010wg.webhop.net.

Re-Programming MusicPal

I have not made any progress with the MusicPal since Christmas, but someone else has been busy and made a good start on some alternative software to run on it, which he has published here http://musicpal.v3v.de/.
Well done Marco - you have got much further than I have!
Giles also made progress with sound output and left his code in a comment to one of my earlier posts here.
Maybe it would be worth starting a project on Google Code or somewhere so other people can help develop it?

Sunday, 28 June 2009

A General Purpose Network Solver?

I often get frustrated if I want to solve a simple fluid flow or thermal problem that is in the form of a network with branches, parallel paths etc. These tend to be a bit to difficult for a "back of the envelope" solution, which is always my preferred approach, so you end up writing code to iterate to find solution.

The easy way would be to use a commercial package like Aspen Hysis, SINDA or ESATAN, but these are very expensive for the once a year or thereabouts that I need to solve something like this. It would be nice to have a simple, low cost solver available.

I thought there would be plenty of open source ones available, but I have not been able to find a simple network solver, so I am going to resort to writing it myself. I did do one once before, but I seem to have lost the source code....It never got finished properly anyway.

I have started the project at http://code.google.com/p/openproc. There is no code worth talking of there yet, but the Wiki describes the sort of design I am thinking of. Any offers of help greatly appreciated!

Tuesday, 9 June 2009

More Ubuntu 9.04 Sound Problems

I 'accidentally' wrecked my gnome desktop (no menus, toolabrs etc.) - I had been doing a bit of tidying up and must have uninstalled something important. I could not decide what, so re-installed the whole ubuntu-desktop package.
This came with pulseaudio again, so sound stopped working like last time.
Decided to invest an hour in sorting it. No real success searching on the web, but I did find this article - http://ubuntuforums.org/showthread.php?t=962695. The author provided a little script to update the ALSA drivers automatically, and quite a few people reported that this cured the sound for them.

I am always wary about running unknown programs as root, but the script looked safe enough - just an automated way of downloading the ALSA source packages and running 'make install' etc. so I trusted it.
It ran and it installed ALSA 1.0.20, compared to version 1.0.18 in the Ubuntu package.
To my surprise, when I re-booted the computer, sound is back!

Monday, 11 May 2009

Ubuntu 9.04 Sound Problems

I upgraded my Fujitsu-Siemens laptop to Ubuntu 9.04 from 8.10 a few days ago.
Everything worked fine except for sound. Sound went from working perfectly in 8.10 to being quiet, and awfully crackly in 9.04.
If I updated the gnome settings to use OSS rather than ALSA it worked ok, except flash movies still made crackly noises (I don't think flash can use OSS).
I messed about with the gnome mixer without luck, except I did notice that changing the PCM volume did nothing (which is wrong), but changing the 'beep' volume did alter the sound volume (Along with crackles).
I don't know why the beep and PCM are the wrong way around, and don't have time to work out how sound works properly, so I went for brute force and ignorance - I had heard a suggestion that Pulseaudio might be the problem, so I replaced pulseaudio with esound, and it all seems to work now...
Therefore, I don't know what the problem was, but it was cured by getting rid of pulseaudio...

Wednesday, 15 April 2009

What has been happening?

I've been forgetting to update this with what has been happening.

WherewasI now has a Python/GTK front end that allows you to plot your GPX traces on a OpenStreetMap map to see where you were, as well as altitude profiles etc. It could still do with a few more features, but it does most of what I want at the moment.

I have decided to make a concerted effort to finish off mapping Hartlepool for OpenStreetMap. The main problem is that am better at cycling around collecting GPX traces than I am at recording the street names. This means I end up with lots of roads with no names - no use if anyone wants to search for an address....To do this I decided to use audio mapping by recording audio clips with my mobile phone. The clips are GeoTagged using data from a little bluetooth GPS receiver. I use GPSMid on the mobile phone. Unfortunately it does not produce the GPX file, or the audio clips in the correct format for the JOSM OpenStreetMap Editor. I wrote a little python script to do the conversion so you can see the positions of the audio clips in the JOSM Editor (See the OSM GPSMid Page for details.

Sunday, 22 February 2009

GPX Track Analyser

I have realised why I never finish anything - it is far too easy to get distracted by another little job.
This time my daughter asked me how far we had climbed after a very hilly bike ride on our holidays.
I was a bit disappointed that I could not give an instant answer, as I had a track log from my Garmin Etrex GPS device, which includes elevation data.
Therefore that evening I wrote a little program in Python to analyse GPX files and provide some basic statistics on the route - this can be found at http://code.google.com/p/wherewasi.

Tuesday, 27 January 2009

Integrating Windows XP and Ubuntu Linux

There are not many things that you can not do on Linux that you could on Windows, but there are a few, in particular there are some software packages that I can not manage to get running under Linux using Wine. These are:
  1. Microsoft Office (I know OpenOffice is a good alternative, but it is different to Excel and Word that I use all the time at Work, and switching is difficult. This is especially a problem for the rest of the family that are not as used to switching between operating systems as I am).
  2. Family Tree Maker (My Mam is used to this program, and the Open Source equivalent (can't remember its name) just wasn't as good as far as she is concerned.
  3. Microsoft Home Publishing (My daughter uses this to make cards etc. Although you can use Inkscape or Scribus to do the same under linux, it is not as simple - maybe someone else knows an Open Source equivalent?).
When I heard about VirtualBox I thought it was too good to be true - you are supposed to be able to run Ubuntu Linux as your main system (Host), but run Windows XP as a 'Guest' in an emulator - as far as Windows is concerned it is running on its own stand-alone machine, but VirtualBox is emulating a real computer in software. This sounds like an awful job to do, and I expected everything to grind very slowly, but as my computers now have lots of memory (2GB and 4GB for my Laptop and the Kids desktop respectively), I thought it might be possible.

Installing virtualbox in Ubuntu is easy:
sudo apt-get install virtualbox-ose
Note that Ubuntu has another package "vboxgtk" which is an alternative front end to virtualbox. I struggled this - the windows installer crashed when you used the keyboard, so I just stuck to the normal virtualbox program.

You then start it by running virtualbox as a normal user. You then create a new virtual hard disk on which to install windows, which is actually a normal file in your home directory.

You create a new 'virtual machine' by associating the virtual hard disk with it, and giving it access to your host system cdrom. I put the Windows CD in the host computer CD drive, and selected 'run' to start the new virtual machine. It booted off the CD and windows installed in the new virtual hard disk.

Then the problems started. The main one was that when I tried to boot windows off the new virtual hard disk it hung when it loaded a module called agp440.sys. This was odd because it was the recovery disk for the version of WIndows XP that runs nicely on the real computer. It turned out that the problem was that the recovery disk assumes the hardware configuration for the computer - in particular the graphics card (AGP), and the VirtualBox virtual computer has a different graphics card, which caused the crash. I could not work out how to get around this, but I found another Windows XP CD, and this did a normal windows installation, where it picked the drivers for the particular hardware concerned. This then booted nicely and you get a window, which contains the WinXP desktop.

Using windows was a bit of a pain in this configuration - the desktop was very small, so it was difficult to fit application windows on it. Also windows kept grabbing the mouse and keyboard, and you have to press a secret key (the right Ctrl key) to release it back to the host operating system.

When I read a bit more about VirtualBox I found that it should work 'seamlessly' so you do not have a separate windows desktop - the Windows XP windows sit on the same desktop as the Ubunto Gnome ones. To do this you have to use the web browser in Ubuntu (the host operating system) to download the guest additions package as an iso disk image, and put it in /usr/share/virtualbox with the filename "VBoxGuestAdditions.iso". You can then install the guest additions package using the menu at the top of the windows desktop window.
Once you have installed the Guest Additions package you can set the system into seamless mode using a menu, or pressing -L. This gives you a windows start menu bar at the bottom of the screen, in addition to the usual Ubuntu ones.

There are menu options to give the guest operating system internet access - selecting the 'NAT' option seems to work, and to give it audio access (I selected the 'ALSA' option, which seems OK.

You can share files between the guest operating system and the host one by selecting a 'shared folder' on the host system - this appears as a network share in Windows.

Things appear to work now - MS Office installs and runs. Haven't tried other things yet, and need to work out how printing works, but it looks very promising.

Sunday, 25 January 2009

MusicPal USB Socket

Other people have reported that it is easy to add a USB socket to the MusicPal. As its internal memory is very limited I think this will be useful for software development, so decided to give it a try.
Sure enough, you can open the case easily by removing three screws and pulling the knobs off the front panel. There are clips on the right hand side of the front panel, so you have to start to open the case from the left (speaker) side and pull the front panel to the left a bit to release the clips. I think it would have been possible to remove the front panel without removing the warranty seal on the screws behind the speaker - just removing the middle screw is probably enough to get the front panel off.
I bought a USB socket from RS Components and it soldered easily onto the circuit board, then just had to cut the back panel blank out and it went together nicely. Now if you plug a USB memory stick into it, an extra menu item appears on the Freecom Nashville application menu, and you can play music off it. I haven't tried to disable writing to the memory stick as they did here because I think I will want to write to it from the musicpal. We'll see....
Haven't tried running software off it yet though.

Monday, 19 January 2009

Nearly Broke It

I'm trying to get back into fiddling with the MusicPal internet radio after I got distracted by a few other things instead over Christmas.
The first thing I noticed was that I had broken the manufacturers' software - it appeared to boot up ok, and I could play files of my server, but internet radio didn't work, and neither did the clock on the device.
I tried fiddling around with the settings via the MusicPal's menu, but couldn't find anything wrong.
It turned out that I had filled up the filesystem on the device, so it did not have enough storage space to create /etc/resolve.conf or similar, so the internet DNS resolution did not work. Once I deleted my experimental files, it all started to work again....

This got me thinking that to do any serious development on this, I will need more storage space - deleting the manufacturers' software altogether is a bit of a big step given the rate I work on these things. The simplest would be to persuade it to boot over the network, just like the MediaMVP - this means I can easily change the root filesystem image, and if it doesn't work it is trivial to put hte original back. The trouble with this is that I will have to update the uboot configuration - this would be easy if I had a serial console for the device, but I don't. I think there is a real possibility of turning it into a brick if I get this wrong.....
The less intrusive alternative would be to compile a kernel with NFS support and have it nfs mount a filesystem with my software on it. This is less drastic, but I will have to make sure I can do the emergency re-flash of the firmware in case I mess it up. A job for later.
The simplest would be to put my files on a USB memory stick and use that - people seem to have added USB support to the musicpal quite easily, so I had a look inside. Sure enough, there is space for a solder connection USB socket, and a punch out panel in the back of the case. I think I will get a USB socket and try this first to see how it goes - I can't find one in anything I can dismantle at the moment, so will have to buy one.