Ask Your Question

Track foot contact on treadmill

asked 2015-12-08 15:25:34 -0500

MatthewSannes gravatar image

updated 2015-12-14 14:02:56 -0500

What is the best approach on tracking weather a person's left foot or right foot is currently in contact with a treadmill using a camera from behind the treadmill?

image description

Here is the approach I am taking after the helpful direction. The results are average and produce some false positives. Especially when the right foot gets over into the left side of the ROI. Any tips on improving my results would be greatly appreciated.

Camera feed is 640x480 at 15 FPS

  1. Convert image to grayscale
  2. Gaussian blur the gray image with a 3x3 kernel and sigma x of 1
  3. Focusing the procession on the ROI shown bellow
  4. Using BackgroundSubtractorMOG2 in order to detect motion within the ROI (Shadow Detection: false, Learning Rate: 0.05)
  5. Opening morphology 3x3 structure, center anchor, 2 iterations on ROI.
  6. Sum non zero pixels on the left half and sum non zero on right half of ROI to determine left foot or right foot.

image description

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-12-12 22:11:49 -0500

Tetragramm gravatar image

Since you don't have a sample image and didn't provide too much detail, I'm going to assume a couple of things, and point you to a way of solving it.

  • The treadmill belt is black.
  • The shoes are not.
  • The camera is always in the same place, directly behind the treadmill, and it's not low enough to see under the feet when they are lifted. But it is low enough that the front-back doesn't change the apparent height as much as the up-down.
  • The center of the belt runs down the center of the image.
  • You don't actually care about the precise moment it's lifted from the belt, just which foot is currently down.

So. You define your region of interest as the area of the image that is the belt. Ignore everything else.

Convert the image to binary. The person's feet are now white, the rest is black.

Split your ROI in two down the middle.

For each half, start at the bottom, and sum the row. If the sum is greater than (experimental value)*white, you've found the bottom of the foot.

Whichever half has the lower row that is above the threshold, is the side with the foot down.

Since that's probably not going to work perfectly, here is the likely cause, and a possible solution.

Probably, the foot that's in back but coming off the belt will still register as down even though it's not touching. You should keep track of how long each foot is down and calculate a stride time. Then, manually, you'll need to look at the video and apply an offset as a percentage of the stride time so that it switches feet sooner. Hopefully that percentage offset is the same for everyone, but no guarantees.

Add a Kalman filter to learn the stride time as they speed up and slow down if necessary, and it could be pretty accurate.

edit flag offensive delete link more


Ok, seeing your images, I would suggest that most of your false alarms can be post-processed out.

First, you can learn the "mid-point" of their stride by averaging the left-vs-right over a long time and splitting it in two. So if they are actually running off to one side, this will help that.

Second, A left foot follows a right foot and vice-versa. So if you had a clear detection as a "right", then the next clear detection is probably a "left", especially if it's close to the mid-line.

Tetragramm gravatar imageTetragramm ( 2015-12-14 18:02:47 -0500 )edit

answered 2015-12-14 12:20:50 -0500

pklab gravatar image

updated 2015-12-14 12:21:34 -0500

If you can install a led stripe in contact with a treadmill in front while the camera is behind (or reverse), you can observe

  • a continuous enlighten line with 2 foots up, or no person
  • an enlighten line with 1 interruption when 1 foot down
  • an enlighten line with 2 interruption or 1 big interruption when 2 foots are down
edit flag offensive delete link more


Any way to track left vs right? Sometimes people will step on the left side of the frame with their right foot.

MatthewSannes gravatar imageMatthewSannes ( 2015-12-14 13:47:54 -0500 )edit

Question Tools



Asked: 2015-12-08 15:25:34 -0500

Seen: 568 times

Last updated: Dec 14 '15