Work In Progress

Just a quick post to show off something I’m working on at the moment. More details to come soon.


Introducing undleBundle!

Tired of looking up the commands to compress/uncompress files via the command line in Ubuntu? Don’t know your -zcvf’s from your -zxvf’s? Then undleBundle may be just your cup of tea!
undleBundle is a python script which wraps a bunch of command line compression/decompressions tools together in simple interface with sensible defaults. Want to make a tar.gz? simple, just run:

bundle filename.txt

want to uncompress your file?

undle filename.tar.gz

want to select a specific compression type to use? (assuming you have the correct tools installed it currently supports tar.gz, rar, zip, tar and 7z, but adding new types is a breeze) Use the -t switch (only used in bundle, undle will automatically determine filetype for decompression)

bundle -t zip filename.txt

want to also select a new filename for the created file? Also simple!(see, a pattern is emerging) use the -f switch:

bundle -t zip -f filename.txt

And that’s it, that’s all there is to undleBundle.

Cannon SX200-IS “Lens Error, Restart Camera” Fix

Note: This worked for my camera, It may or may not work for yours, do at your own risk. Also, apologies for the photo quality…my camera wasn’t working.

Just as I was about to take some photo’s to document a new blog post I turned on my camera and “Oh-Noes!! The lens has become fully extended and won’t go back in! and the camera is saying ‘Lens Error, Restart Camera’ Golly!”. According to various reports this is pretty much the death knell for the camera.

Broken SX200IS

Now, I’m not in the habit of keeping receipts, and I think the shop I bought it from has gone out of business anyway. So I did the only sensible thing and decided to take a screwdriver to it.

Disassembled Cannon SX200IS 1Disassembled Cannon SX200IS 2

Unfortunately I wasn’t expecting to actually fix the thing so I didn’t keep a record of the order of screw removal, but you basically have to keep unscrewing things until the side opposite the USB socket is visible as seen in the following picture.

Side Removed

You should now be able to see the large capacitor used for the camera flash, and next to it the side of an electric motor used for extending the lens when zooming. Just visible in the space between the top of the motor and a circuit board should be the two solder tabs at the top of the motor casing.

Next fire up a 5 volt power supply and attach some crocodile leads with small wires attached to the other side (I used the cut off legs from some resistors).

5 Volt Supply

Crocodile Leads

Next take the two leads and poke them on to the solder pads at the top of the motor. The lens zoom motor should start to turn. If your lucky the lens should start to retract, if not switch the wires around and try again.

When the lens is retracted back in reassemble the camera and try turning it on. If your lucky, everything should be working fine now!

Working Camera!

If you’re like me you’ll probably end up with a few spares….I like to think of it as streamlining the camera…

New Project – 8Bit Sequencer

Been meaning to post an update in a while, have a few new longer posts nearly written. In the meantime here’a a new project I’ve started after learning VHDL and FPGA related awesomeness.
Recently purchased a papilio Spartan 3E development board and I’m having a hell of a lot of fun relearning VHDL. To help apply some of the new stuff I’m learning I’ve decided to start a new FPGA project, the 8Bit Sequencer.

So far I’ve implemented 4 voices (sine, square, saw, triangle) with an octave, phase, and level control for each one, and also 2 modulator controls connected to an attack-decay-sustain-release (ADSR) generator, and a low frequency sine wave generator.

Below is a picture of the 8Bit output from the FPGA development board measured on an OpenBench logic analyzer. (The ADSR modulator is not connected, only the low frequency sine modulator)

Python – OpenCV IplImage To PyQt QImage

This is a quick post which will hopefully save someone some time. I spent far too long trying to figure this out.
If you’re using Qt and OpenCV with python and want to show an opencv iplimage within a Qt Widget here’s a quick hack to convert the iplimage to a qimage.

class IplQImage(QtGui.QImage):
"""A class for converting iplimages to qimages"""

     def __init__(self,iplimage):
         #Rough-n-ready but it works dammit
         alpha = cv.CreateMat(iplimage.height,iplimage.width, cv.CV_8UC1)
         rgba = cv.CreateMat(iplimage.height,iplimage.width, cv.CV_8UC4)
         cv.Set(rgba, (1,2,3,4))
         cv.MixChannels([iplimage, alpha],[rgba], [
         (0, 0), # rgba[0] -> bgr[2]
         (1, 1), # rgba[1] -> bgr[1]
         (2, 2), # rgba[2] -> bgr[0]
         (3, 3) # rgba[3] -> alpha[0]
         self.__imagedata = rgba.tostring()
         super(IplQImage,self).__init__(self.__imagedata, iplimage.width,iplimage.height, QtGui.QImage.Format_RGB32)

All in all it’s fairly straight forward, an example case is something like the following:

#Create a 3 channel RGB iplimage (could be from a webcam ect.)
iplimage = cv.CreateMat(iplimage.height,iplimage.width, cv.CV_8UC3)
#Turn it into a qimage
qimage = IplQImage(iplimage)

It works by sub-classing QImage and overloading the constructor with a new one that accepts an IplImage, this then has an extra alapha channel added (to make it compatible with the QImage pixel packing) and finally the __init__ method of the superclass (QImage) is called with the data from the iplimage passed into it as a string.

The important part is:

self.__imagedata = rgba.tostring()

This keeps a reference to the image data so it doesn’t go out of scope when the __init__ returns. (the QImage constructor that accepts image data doesn’t keep a local reference to the data, so you have to make sure it isn’t lost.[at least i think that’s right])

Open3DScanner – ***Insert pun about cutting (final cut?, making the cut?,something mustard related?)***

Spent the weekend in St Neots visiting my friend Pete where we drank heavily and sellotaped mobile phones to kites (A blog post on that later). Took the day off on Monday and we both travelled down to London and did some laser cutting on a machine rented at blueprint model shop. Here are some photos of the cut parts:

Unassembled parts

Push Fit Assembled

Ps3 Eye Mounting

As kind of expected a bunch of stuff is slightly wrong with the parts, but nothing that can’t be easily fixed.

It’s bloody awesome seeing something I’ve spent so long designing on a computer in actual-real life. Alas there’s plenty of work left to do on the software and electronics side of things, but it’s nice to have made this milestone.

3D Scanner Mk 3 – Lasering Time!

The 3D scanner hasn’t made much progress in the past month or so, due mainly to me putting off doing the last bit of boring work to get it ready for laser cutting. After drinking a load of Tesco own brand energy drink last night I decided to get all the fiddly bits done, and so here is the final 3D model and the layout of the parts for cutting:

3D Scanner Model & Parts

The parts have now flown through the intertubes over to cutlasercut to get a quote for the cutting, and hopefully, if it doesn’t bankrupt me, I’ll be getting all the parts cut soon! wooo!

On a side note, after getting some good feedback on the introduction to markov chains I wrote I’m hoping to do another one that covers another interesting area of artificial intelligence in the near future.