Posts Tagged hobby

JavaScript depth mesh renderer

Was playing around with some old code for generating depth maps and decided to create a demo that renders the depth maps in WebGL. The color video is stacked vertically on the depth texture so that the two will always be in sync. Looked into packing the depth into the 24-bit RGB channels, but as the video codec is using YUV there was significant loss and the depth looked horrible. A better approach would be to pack the data into the YUV channels, but I didn’t try. For this example, the depth is only 8-bit.

You can see the one video here:
http://js-depthmesh.appspot.com/

Stacked color and dpeth

Stacked color and depth

js-depthmesh

, , ,

4 Comments

Updated source files for the random shape generator

Updated some source files for the random shape generator:
http://www.neilbirkbeck.com/source/meldshape-0.1.zip
http://www.neilbirkbeck.com/source/tiling-0.1.zip
http://www.neilbirkbeck.com/source/rshape-0.2.zip

,

No Comments

A voice basis

Not too long ago, Leslie and I were wondering about pronunciations of names.   We had found a site that had some audio samples of the pronunciations, and we had started playing several of them over and over again.  It sounded pretty funny listening to them, and I thought it would be neat to hear a real audio track represented with a bunch of people just saying names.  Then you keep adding more people saying more different names until you get something that “sounds” like the input.

The set of audio samples of someone saying names, become a basis for your audio signal.  I hacked together a quick program and some scripts to use a set of voices to represent an audio track.  The algorithm simply tries to fit the audio samples to the input signal and keeps layering audio to fit the residual.  It’s a greedy approach, where the best fit from the database is chosen first.  Each layer positions as many database samples over the input signal (or residual signal) in a non-overlapping way (see the code for more details).  There are probably much faster ways to dot his, perhaps using spectral techniques, but I wanted something quick and dirty (e.g., a few hours of work).

The result doesn’t sound near as compelling as I had imagined.  To emphasize that it is just people speaking names that are used to produce the target audio track, I’ve broken the target audio track into 5 second segments.  In the beginning, 5*pow(2, i) speakers are used to represent the signal for the i-th segment, so that the signal gets better as you listen longer.

The input audio track is a 60s sample from “Am I a Good Man”.

In the last segment, 10240 speakers are used to represent the signal.  Results:

five_kmw.mp3:The best example as it has the most names and the most speakers (names that start with K, M, V)

five.mp3:uses fewer names (only those that start with K)

three.mp3. uses only 3*pow(2, i) voices at each segment, so the approximation is not as good.

 

Code (with scripts, in a zip file):audio_fit.zip

, , ,

1 Comment

Accordion Hero

Last weekend, I spent some time making a prototype Accordion Hero that uses live input from a microphone, does Fourier analysis to determine the keys, and uses this to control the video game. The beauty of this is that you can use your own instrument and try to learn while playing a game.

http://www.youtube.com/watch?v=dm4Kv_-Sen0

The version is just a prototype. While debugging the audio input, I used Audacity (which has a beautiful set of frequency analysis tools). These were helpful in determining if it was possible. I ended up using the tools for the spectral analysis from Audacity (they have an internal FFT that is pretty lightweight and saves linking to some other external library, e.g., fftw3). Also, the portaudio library is great for getting audio input across several platforms. I used it without a hitch for linux, mac, and cross-compiled windows. I’m a fan!

Common issues include a bit of lag, and some noticeable bugs where it says you played a note before you played it (this is actually a minor issue that is easy to resolve).

I spent some of today building the windows version:
AccordionHero.zip
the windows version has some problems (namely, it crashes on exit). Use the .bat script to run. It may be missing mingw.dll (should be easy to find on the web).

And a mac version:
AccordionHero-mac.zip
I am not sure I have packaged all of the dependencies. Again, run with the .sh file. You may have to use dylib-bundler (or the other mac tool to rename the libraries reference by the binary).

I didn’t spend much time tweaking for different systems. You will have to make sure that the audio level on your input is high enough. Use the ‘f’ key in the program to bring up the frequency spectrum. This should have a horizontal bar across it. This is the threshold, below which everything is ignored. Use the .bat/.sh script to adjust this file (the vertical scale is roughly -90 to 0, the default threshold is -65 DB).

I have only tested this with the Accordion, but it should work with other instruments. Use the ‘f’ key to find the frequencies of your instrument. Edit the notes.txt file (which serves as calibration).

Here are some screenshots of the very lame gameplay:
ahero-3ahero-2ahero-1

, , ,

No Comments

MeldShape

squares_final

MeldShape is another application for generating random shapes. Although, unlike JShape, which produces shapes in an algorithmic way, MeldShape takes an initial set of shapes and evolves them using differential equations.

Each shape has a measure of speed over the domain, and tries to fill in the entire domain without conflicting with other shapes. There is also a measure of how much a shape can vary from its original shape. The evolution is performed using an implicit level-set implementation. More technical details: meldshape

Below there are binaries for both windows and Mac. The Mac version will require you to download a recent version of the open source Qt libraries. Open up the application, and drag a set of seed shapes from JShape onto the window. Use the evolve button to start the evolution.

meldshape-screenshot

The concept for this project was initiated for Mat Bushell.

Some movies of evolution:

And an unedited (poor quality) movie of how to use MeldShape in combination with JShape: meldshape-usage

, , , ,

1 Comment

Qt UiLoader runtime erros when cross-compiling

I was recently trying to build a windows version of the level-set shape generation (initial results, which is really a derivative of JShape), which is now titled MeldShape. The Mac version has come through several revisions now, and I figured if I was going to put anything up here, it might as well include everything (a document, some binaries, as well as a post).

Anyhow, I usually use a cross-compiler to build windows applications, and in the past I haven’t had any trouble getting a working build. However, this time was different.

I have working binaries for most of the libraries that MeldShape depends on, so building MeldShape was just a matter of updating these libraries and fixing any non-portable aspects within MeldShape. There were a few of these little things, like usleep and drand48, and checking validity of a pthread with (pthread_t*) != null (win32 pthread_t is a struct with a pointer inside). These things are obviously straightforward, and wouldn’t have even been an issue had I been thinking of a portable application in the first place. The real problem came within the Qt components.

When cross-compiling on linux for win32 targets, it is relatively straightforward to setup Qt. You use wine to install the windows libraries of Qt (the mingw build) and use your linux qmake with the appropriate spec file. Typically once you get the program to link you are out of the woods. But with Meldshape, linking was fine but running was always giving a symbol error in the Qt dll’s. It didn’t work either in Wine or in windows XP.

This was super frustrating, as I don’t have a working setup in windows using MinGW to build Qt applications. And in my experience, building in MinGW is really slow compared to the cross-compiler, so I really didn’t want to have to setup my environment from scratch (building from source). So I suffered through this problem, trying to figure out why on execution windows was complaining about missing symbols in the Dll (mostly in QtCore4.dll). I have seen similar problems to these when trying to run the executable with mismatched Dll’s (especially between the mingw and msvc builds of Qt), so I figured it had to be something with the versions of the Dll’s. I was using the same version as I had built with, so that was out.

I then tried an older version of Qt (since I had been using an older version in the past), and again no luck. With no other option, I started to strip my app to a barebones sample application to see if even that would work. And sure enough it was working fine (although it wasn’t referencing much else other than QApplication). The problem seemed to be something to do with one of the other libraries I was using.

I struggled with this for a while, and finally came up with the hypotheses that this was maybe due to loading parts of the UI with QUiLoader (from UiTools). After commenting out the few parts that use forms, it actually starts to work ???? This was at the point when I was ready to say, “screw the windows build”. I mean, the application is pretty simple, and at this point it is not even worth the effort. Anyway, I’m sure I am using forms in my other applications, so I have no idea at this point why using forms are causing problems with the Qt in windows. I decide to try QFormBuilder from the QtDesigner components instead. Luckily the API is pretty much the same, so almost no code (except for the declaration of the loader) has to change. Strangely enough, QFormBuilder worked fine.

I have no idea why QUiLoader was causing problems and QFormBuilder was not. I’m happy I found the problem, but at the same time I think the only reason I found it was due to luck. In the end it took almost 6 hours to find the problem and port the rest of the code…something I figured would take maybe 2 hours.

In the next little bit, I will try and upload the binaries and the technical document (as well as create a new project page for it)…all of the things that could have been done in that time it took to track down a non-sense bug.

, , , ,

No Comments

Passive Walker

In the past week (late March 2009), I kept coming across the same paper (by Brubaker et al.) that used an anthropometric passive walker for a prior in people tracking.   I had read the paper in the past, but this time I couldn’t contain the urge to implement some of the ideas.  This is the result of that impulse.

The passive walker contains a spring in between the hips and has a parameter for the impulse recieved on collision.  From these two parameters you can generate different styles of walking; you end up with the ability to generate cyclic gaits for different speeds and stride lengths.  The walker only has two straight legs, but Brubaker suggests a method to map this to a kinematic structure.  The screenshot below shows several walkers attached to a kinematic structure and skinned mesh.anim

Screenshot of the simulation

 

It is better illustrated in the movie, in which I am controlling the speed/step size of the gait by the mouse movements:

The movies (passive.mp4, passive.flv)

 

I spent about an hour throwing together something that tried to pose the rest of a mesh using the walk cycle.  The idea was to use a training set of poses (from motion capture data), and pick poses for the upper body from the training sequence based on the orientation fo the lower joints.  I’m sure it could be done better.  Below are some examples: the left hand side shows some poor resutlts (due to overconstrained joint angles); the right side shows unposed upper body.  Some of these sequences are avaibale to use (anims) with the viewer on the wxshow page.

 

A walk cycle

 

A document containing some of my implementation details:passive.pdf

,

No Comments

Windows Jumble Solver

I used to play Jumble in the morning (you know, the word game?) with my Grandma. This was a while back, and at the time I was tired of getting stuck on some of the puzzles and decided to write some code to solve it for me. This was the result.

No Comments

Legacy

I finally got around to pulling out some old code for test apps that I had written some years ago.

Arkanoid

First one is arkanoid (break-out):

I miss living with my parents and working at a dead end job. It gave me motivation to work on little things like this. At the time I believe I was in my third year of my undergrad degree and it was either Christmas holidays or spring break. I had just finished spraining my thumb to the point where it had dislocated and the bone came through the skin. I started working on this gem and probably only spent maybe a day or two on it. Obviously never finished but it still may be fun to play. Download the windows binary (doesn’t work in wine) and try it out.

Bomberman

Next on the list is of course Bomberman. I still have some hidden obsession with bomberman. In this case, I totally ripped off the icons for the bomberman from the game, but I remember creating the textures for the fire (and most likely the board). This piece of work features randomly generated levels, partial multi-player support, mp3 player support (not sure how to use it anymore, using fmod sound). And of course some crappy AI. When I started this project (some time in the summer of 2002), I was interested in the AI for the game. The method I implemented used a strategy where the agent keeps track of the utility of places where a bomb will explode and ignores these positions while trying to break as many bricks. He is not much of an opponent as his primary goal is to destroy the bricks, but it was fun playing around with nonetheless. Thanks to Nathan Matthews for making a title screen:

See some of the screenshots below. If you try it out, make sure that you select player1 as keyboard1 and player2 as AI. Use ‘a’, ‘w’, ‘s’, and ‘d’ to move the player; ‘z’ to drop bombs, and ‘x’ to kick/detonate when you have a special.

Pacman

Not too much interesting with this one. Sounds real, I guess. The textures of the tiles are dependent on the underlying board, which is kind of neat I guess. The space key will chomp through the walls, so you can see what I mean. I can’t remember exactly when this project was concieved, but I would have to guess around christmas time.

,

No Comments

ngeotc

More to come.

, ,

No Comments

nsfs

More to come.

, ,

No Comments

nappear

More to come.

, ,

No Comments

Image-Based Face Tracking for VR

Not so much of a research topic as it was an attempt to duplicate some YouTube video that did Head Tracking for VR using a WiiMote (This wasn’t just some YouTube Video, but actually quite a popular one.)

There is a company seeingmachines that has a commercial version of a head tracker that they use for a similar purpose.

The non-pattern based one uses a 4DOF SSD tracker. I’m currently working on a port of the demo for the Mac.

,

No Comments

Bomerman 4k

Yep, looks pretty crappy. It isn’t that easy to make a game fit into 4096 bytes. I thought it was easier, but once you set up a region to draw and get your keyboard input you really don’t have much space to work with. Not to mention the overhead from extra files in the jar-file nor the extra space taken by having multiple classes.

There are some real contenders for these types of games up at Java unlimited, which hosts a 4k game contest.

Executable (bomb.jar)
Source Code

,

No Comments

nmath

Basic math and vector routines. Features:

  • Special classes for common vector/matrix sizes. General matrix class with interface to lapack for numerical routines.
  • Minpack for non-linear least squares.
  • Smart pointered data; all copies are shallow.
  • Python interface.

,

No Comments

nimage

Basic c++ image library. Features:

  • Templated image classes (integer, floating)
  • Smart-pointered; copies are all shallow.
  • Plugins for input/output (jpeg, png, movies)
  • Basic filtering operations (signed distance function).
  • Python wrappers.

,

No Comments

JShape

A little applet that will generate random shapes (and pack them into a rectangle). Try playing with the settings, and then you can drag the drawing from the canvas into your editor to edit the shapes. Update: Added a tiling of the plane, but you will have to use the webstart version (due to permissions). If the applet does not load, try the web launch .
The source code is now also freely available (for the front-end at least):  rshape-0.2.zip

,

No Comments

GT Racer

GT Racer demo, openGL.
I finally found the time to do some updates and get a windows binary available. The zip file is large (mostly due to uncompressed sound and models). There are lots of things that still need fixing:

  • Graphics
  • Multiplayer
  • A couple more little things to make single player complete
  • A lot of code fixing

Oh well. At least it is up here in case anyone wants to test it out.

The controls are ‘w’ for push (currently you can push as much as you want), middle button for controlling front ski, and flicks of the right button for backflips and spinning. There are some keys bound to the tricks (I think ‘e’ ‘f’, ‘z’ and ‘c’, or ‘q’ or something). ‘a’ and ‘d’ may be bound to dropping flags (my crappy level editor).

Oh yeah, the directory it unpacks to is a huge freakin’ mess, and the program crashes when you close the window. All in good time my friend…

,

No Comments

Gimp – Integrate Normals

This plugin is used to integrate normal maps into depth maps. As input the plugin takes an rgb description of a normal map, and outputs the corresponding depth map. There are two modes of operation.

More details and screenshots to come.

As an example, the program can be used to create normal maps from depth maps, or more importantly depth maps from normal maps.

To illustrate, consider the input depth map:

In some vision problems (e.g., shape from shading), you have a normal map and you want to recover the depth map. The plugin can be used to generate the depth map from the normal map(left). Running the plugin once more (with this typical input), we can recover the depth:


The interface has several modes for packing either the normals or the depth, but if you want to use them, you will need to look at the code. Requires the fast fourier transform library fftw3 to compile and run. Using a sparse linear least squares solver, lsqr, which is included in the source.

, ,

No Comments

tetris08

Back in 2004, Keith Yerex and I played a game of who can write tetris the fastest on a flight from Toronto to Edmonton.

I dont remember who won, and I dont have the source anymore, but it was a good way to kill time.

On a recent trip to Atlanta for a conference, I played a solitaire version of write tetris fast; this is the result. I spent some more time during the evenings on that trip adding some crude AI that takes the history into account.

Executables and source to come.

,

No Comments