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.









