Wednesday, September 02, 2009

Genetic Conway's Game of Life

Full details and source code on devrand.org


Genetic algorithm on starting patterns of Conway automata.
Total number of spaces occupied is used to determine what carries on.

Tuesday, August 11, 2009

Trackmate Software With PS3 Eye and Processing on Windows

Copy and pasted from devrand

Overview

A very quick tutorial for the entire round trip of setting up the PS3Eye getting the Trackmate Tracker working and using it with Processing. It's mainly a collection of links to avoid googling everything :p

Downloads

  • Java Runtime Environment -- Install the latest JRE, it is needed for running standalone Processing apps

  • PS3Eye Driver -- Install the software. You have to scroll way down on the page to find the link.

  • Trackmate Tracker and Tagger -- Download both and unpack them. No installation required, but it is handy to make shortcuts to the executables.

  • Processing -- Download and extract. Again, no installation needed.

  • LusidOSC -- Download the simulator and Processing bundle. Just extract the files, no need to install anything.

Setting Up

  • Start up Processing. You can immediately close it, but you need to verify it works and let it register filetype handles.

  • Open up the LusidOSC simulator, and then open any of the PDE files provided by the LusidOSC bundle. You should be able to move the pieces in the simulator and have them work with the sample applications. Close the simulator when you're ready to proceed.


  • Go into a DOS prompt (Start Menu->run, type cmd and hit enter) and then navigate to where the PS3Eye test application was installed (For me it's: cd C:\"Program Files"\AlexP) Run the following command: regsvr32 PS3Eye.ax

  • Open up Trackmate Tracker and verify that you can see video (Assuming the PS3 eye is connected). Try hitting s if you have multiple cameras and it's not working, or v to change views.

  • To setup the Tracker follow the guide

  • Now toggle the view(Press v) till it says it's in "Fast Mode", and rerun one of the sample apps in the LusidOSC Processing bundle. And you're done.


Conclusion

This was easy, but took me a while to figure out where to download everything (Especially the PS3Eye stuff :p). The hardware has been much more of a pain, and I will include a write-up of it when I get it working 100%.

Saturday, August 01, 2009

Haskell Cipher Saber

Cipher Saber is an easily implementable form of strong encryption. It makes it so that if encryption programs are ever banned, people can simply write their own and use that. I decided to implement the algorithm in Haskell for practice.

Full description and source at devrand.org

Saturday, June 06, 2009

Simple Perl SDL Music Keyboard

Available at: devrand

Dynamic Web Displayed Images: Python and PHP

Ripped from: devrand

Overview



Dynamic images on the web can be a tad tricky. The general procedure is to write out an image header as opposed to the standard html one. Following that is the raw binary for the image. Below are examples of doing this in Python and PHP.



Python using the PIL library




#!/path/to/python
from PIL import Image, ImageDraw

import sys
im = Image.new("P", (200, 200))

draw = ImageDraw.Draw(im)
draw.rectangle((0, 0) + im.size, fill="blue")

# Any manipulation of the image
print "Content-Type: image/png\r\n"
im.save(sys.stdout, "PNG")




Python Debugging


This is incredibly fragile. I originally tried a solution I found on a mailing list and had to make tons of modification to get it running.


  • Wrong content type: The image/type must match with the output

  • Not including the python executable path: If the top line is not setup correctly(#!/path/to/python) or is missing, it may run correctly in the command line but fail on the web

  • Wrong newline setup: I found I had to have exactly the number of newlines I did, most people show an additional "\r\n", but this broke mine

  • sys.stdout.write: This didn't work for me. It shows up fine on the command line, but doesn't work on the Apache webserver I was using. Use print instead.

  • PIL not installed: The machine it is running on needs the Python Imaging Library



The bad thing about most of these bugs is that they look just fine on the command line, and only fail when run on a web server.



PHP using the GD library



<?php
$my_img = imagecreate( 200, 200 );
imagecolorallocate( $my_img, 0, 0, 255 );
# Any manipulations of the image
header( "Content-type: image/png" );
imagepng( $my_img );
imagedestroy( $my_img );
?>



PHP Debugging


The only problem I've had with this is GD not being installed properly. Other than that if you can run PHP scripts you shouldn't have issues.



Conclusion


This is a usefull technique but was very hard to find relevant information online, especially for Python. This is a much better solution than saving off pictures and then pushing that to the user like I've seen alot of online.

Quilting and Embroidery Stand

More at: devrand