teaching machines

Custom Activity in Unity

Goal: I want to trigger Android activity-level code in my Unity 3D application. Here’s a minimal example of doing so: Create a new Android project in Eclipse. We won’t be using many of the ADT plugin features. We mostly leverage the compiler and editor. Override UnityPlayerActivity with a custom activity: Add C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\androidplayer\bin\classes.jar to the […]

Capturing snapshots of a text file in Vim

To make a movie of textual development, I need a way to capture edits to a text file. Capturing needs to be done automatically and transparently; the developer shouldn’t have to trigger them. Otherwise, he’d forget. My initial thoughts were to intercept every keystroke and record the changes elsewhere on disk. I didn’t really like […]

Making a jQuery slider do something

Getting a slider to display was the first step. The end goal is to make the slider scrub through a series of snapshots of a text file. In between, let’s just figure out how to map the tick to a timestep. jQuery sliders are discrete; they can only be scrubbed to integral positions. Since the […]

Loading a remote file in JavaScript

Next up on my list of things I don’t know how to do is load a file in JavaScript. For now, let’s assume the file is hosted on the same server as the script. I understand that reading local files requires HTML5 and reading files from other servers can be troublesome. jQuery has several ways […]

Adding a slider into WordPress

How can I get a slider in HTML? Actually, how can I get a slider in WordPress, which is slightly harder? jQuery UI provides a slider, but the jQuery that ships with WordPress was not appearing for me. I tried using the jQuery provided by Google’s CDN instead: There are probably later versions I could […]

Plotting samples with GNU Octave

Suppose we have a plain text file of samples named samples.txt, with each intensity on its own line: We can visualize these results in GNU Octave with: If we write this code in a script named plot_samples.m, we can simply run plot_samples at the Octave command-line.

Levenshtein distance

We’re looking at methods for comparing the distance between two sequences of text. A fairly simple one is Levenshtein distance, which calculates how many edits it takes to go from one string to another. I wrote a little calculator to demonstrate its results. Enter two words and calculate their distance. Cell (i, j) reports the minimum […]

Timing Android voice recognition

I was curious whether the EXTRA_MAX_RESULTS value affected the time it takes to get voice recognition results back to an Android device, so I ran a couple of quick tests. In the first, I spoke the phrase “Binky the ball bounced away” a few times each for different EXTRA_MAX_RESULTS settings. I tried 1, 5, 20, […]

Voice recognition sans dialog box

Android provides a nice speech recognition system. Many examples show how you can push out an ACTION_RECOGNIZE_SPEECH intent to trigger an Activity that shows the listening status on a big dialog box. I wanted speech recognition without the dialog box and was able to do so with the following code: The XML layout defines a […]

Installing OpenCV on Linux

I was able to get OpenCV installed without too much trouble on my Ubuntu Linux machine. A simple did the trick. I tested the installation by writing a short C program to pop up an image: To test video playback and webcam capturing, I wrote another little program to play a video frame-by-frame: I compiled […]

1 43 44 45 46