loading
 
VB Script Question
Ben Graham from United States  [17 posts]
12 year
STeven,

I am trying to create a program in VB Script that adds up the cumulative total of money that passes in front of a webcam. For example, a 5 dollar bill is passed in front of camera then the balance=5, 10 dollar bill is passed in front of the camera then the balance=15 etc.  

I have no problems with the object recognition and variable input but I can not figure out how to add the variable only once.  For example, I have a balance of 0 then when I put a 5 dollar bill in front of the camera, it adds 5 a zillion times, and the balance increases by about 20 a second as opposed to just increasing by 5.

Any help would be appreciated,

Ben
Anonymous 12 year
Ben,

That's a common issue in many recognition situaions. The issue is when a "new" object is seen. This is easy if the objects change but not as trivial when two similar objects are shown in sequence. What you are looking for is a timeout period. It goes like this:

if current_object <> nothing then
  if last_object <> current_object then
     add value to sum
     set last_object = current_object
  end if
else
  last_object = nothing
end if

which will basically stop the current object from being recognized until it is not seen for an instant. Once not seen showing the same object again will trigger the summation. Note that this can be an issue if the object disappears for even a one frame. Thus be sure to set the "absent after X frames" to something like 20 to ensure that when the object does disappear ... it is really gone and not just flickered. At 20 thats a bit less than 1 second given a 30fps camera.

Hope this helps...

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index