Sunday, 23 January 2011

Post 2 - Bounding Box

Draw a bounding box around the figure. This is useful because it encapsulates data about the x and y movement.

As a side note, I also fixed the background subtraction. Until now I had to run an old version of the project to get that part to work properly. Why? It turns out you can't create an array, then populate the array with an enhanced for-loop. Taken me 2 weeks to find this problem!

Do this:
        int cells = size * size;
        float[] matrix = new float[cells];

        for (int i = 0; i < cells; i++) {
            matrix[i] = 1.0f / (float) cells;
        }
Not this:
        int cells = size * size;
        float[] matrix = new float[cells];

        for (float i : matrix) {
            i = 1.0f / (float) cells;
        }
Not quite sure why the latter doesn't work, possibly something to do with it not being initialised? Any ideas?

Edit (24/1/2011):  As pointed out to me by my friend:
It doesn't work because floats are primitive, so assigning them is not changing what is stored in the array.

Post 1

Dump a video into .png images using ffmpeg command line tool. 1min video = ~1500 images.









Generate a background image by taking a temporal median. Can be created either from frames of the background, or from a sample of the frames with the person in them.

Extract the person using background subtraction and thresholding.





Next time: Create a bounding box around the figure.