Just had an idea. You might be doing it this way already - in any case here goes :-
My idea relates to FAST motion detection. Say you are using a screen size of 800x600. Now, you don't need to test *every* pixel for movement but instead have 1 pixel per 'zone'. With the 800x600 example, if you wanted 100 zones, you'd test pixel 80,60 / 160,60 / 240,60 etc. (simply put, one pixel in every box on an invisible grid).
Then, you test each of your pixels to see if there has been a change in colour. Now, bearing in mind that on live video you're always going to get some artefacts and small colour variation, you'll need to build in a 'tolerance' setting so that zones aren't triggered accidentally (analog sources generally have that 'creep' thing as well).
Now, the clever part. You can then decide what direction something is moving by comparing currently active zones with previously active zones. For example if the zone at 0,80 is active now, and the zone at 0,0 was active before, then you can deduce that the movement is *probably* heading from left -> right. You could remember as many 'previous poses' as you needed to get a good result. You could also gain accuracy by remembering the different colours moving through different zones, and vector math / probability tables (any human figure is always going to move in similar ways).
The great thing about this method is that it does NOT require a uniform background colour, provided the camera never moves (background pixels will be fixed, hence they will never trigger movement).
Hope that's of some help :)
My idea relates to FAST motion detection. Say you are using a screen size of 800x600. Now, you don't need to test *every* pixel for movement but instead have 1 pixel per 'zone'. With the 800x600 example, if you wanted 100 zones, you'd test pixel 80,60 / 160,60 / 240,60 etc. (simply put, one pixel in every box on an invisible grid).
Then, you test each of your pixels to see if there has been a change in colour. Now, bearing in mind that on live video you're always going to get some artefacts and small colour variation, you'll need to build in a 'tolerance' setting so that zones aren't triggered accidentally (analog sources generally have that 'creep' thing as well).
Now, the clever part. You can then decide what direction something is moving by comparing currently active zones with previously active zones. For example if the zone at 0,80 is active now, and the zone at 0,0 was active before, then you can deduce that the movement is *probably* heading from left -> right. You could remember as many 'previous poses' as you needed to get a good result. You could also gain accuracy by remembering the different colours moving through different zones, and vector math / probability tables (any human figure is always going to move in similar ways).
The great thing about this method is that it does NOT require a uniform background colour, provided the camera never moves (background pixels will be fixed, hence they will never trigger movement).
Hope that's of some help :)