Home > Archive > Visual Basic > January 2006 > Motion Sensing using VB
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Motion Sensing using VB
|
|
| Roshan 2006-01-22, 3:55 am |
| I have made a small application in VB which detects motion captured by
a webcam. The app. just two consecutive images and XORs the pixel
colours and then accordingly detects the region of maximum
movement...The rest is fine...Now there is one problem. I am gettin the
coordinates of the point of maximum movement (which a traced by a small
circle on the picture box). I am trying to store it into an array after
every frame change. Now I want a small function which could help we
tell if the point has moved left, right, up or down. In the sense, that
I should be able to determine the direction of movement of say my hand
with respect to say the starting point. Here is the problem. I ain't
good at maths and have not been able to determine correctly when the
person moves his hand say in front of the camera. Could someone please
code this much part for me...Also the point moves around a lot. Its not
very constant. If someone could contact me personally on my mail so
that I can get help. The direction thing is a major problem. Also I
tried analysing the motion after every 0.5 second...But the person
could have moved his hand left,right,up and down in that 0.5 second..So
finally it only registers down motion...Please help...
| |
| Mike D Sutton 2006-01-22, 7:55 am |
| > I have made a small application in VB which detects motion captured by
> a webcam. The app. just two consecutive images and XORs the pixel
> colours and then accordingly detects the region of maximum
> movement...The rest is fine...Now there is one problem. I am gettin the
> coordinates of the point of maximum movement (which a traced by a small
> circle on the picture box). I am trying to store it into an array after
> every frame change. Now I want a small function which could help we
> tell if the point has moved left, right, up or down. In the sense, that
> I should be able to determine the direction of movement of say my hand
> with respect to say the starting point. Here is the problem. I ain't
> good at maths and have not been able to determine correctly when the
> person moves his hand say in front of the camera. Could someone please
> code this much part for me...Also the point moves around a lot. Its not
> very constant. If someone could contact me personally on my mail so
> that I can get help. The direction thing is a major problem. Also I
> tried analysing the motion after every 0.5 second...But the person
> could have moved his hand left,right,up and down in that 0.5 second..So
> finally it only registers down motion...Please help...
Using XOr to calculate the difference between two pixels is not really the
best technique since this is highly prone to noise and looses a lot of data
since it will only tell you whether two pixels have changed, not by how much
they have changed. A more accurate way of calculating the amount changed
would be to subtract one from the other and take the absolute value, it's
more computationally expensive but gives you a much better result. You then
want to look for large areas of change, noise will generate low frequency
change all over the image however motion will be seen as a large change
(multiple pixels) in one area. A simple threshold operation will filter out
all the low frequency stuff and min/max rank filters will get rid of odd
pixels but leave the large areas of data untouched.
Finally search for the largest areas of high frequency noise and you've got
an movement area. Finding it's direction is often not such a simple problem
since there could be multiple movement areas (a common one is an object and
it's shadow for instance) and trying to predict which area in the previous
frame corresponds to those in the current frame can be quite tricky. You
could for instance look for areas of high contrast to track features,
alternatively you could simply perform a mean filter on the movement area to
track overall colour, there are many different techniques depending on the
data you're working with.
In a simple case assuming you have only one movement area then take the
bounding box round the area of movement and work out the distance travelled
between the centre of the previous frames bounding box and this one (simply
subtract the coordinates of one from the other.)
You can more than likely find plenty of articles online about this kind of
thing though which will give you more information about how to accomplish
what you're after.
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
|
|
|
|
|