This is the project for Machine Vision classes at Faculty of Mechatronics, Warsaw University of Technology.
The aim was to write a program which would detect and track a hand.
The program works pretty well provided that following conditions are met:
- The background is relatively static (dynamic background messes everything)
- Works best with bright stray light (for high contrast)
- Only one hand is visible
- All fingers of the hand are visible
- Generally program works better if the face isn't in the image
- First 500 frames are used to create a good BackgroundSubstractor model
- Binary Threshold
- Morphological open
- Finding contours with
findContours()function - Finding the contour with greatest area
- Finding the hulls and defects of the contour
- Count the
rough_palm_centeras a mean of defect points, also count standard deviation - Remove all defect points which are father than 1,41*std_deviation from
rough_palm_center - Go back to step 7 until
std_dev > Min_rough_center_std_dev - Make vector of distances of defects to
rough_palm_center - Sort the vector
- Take the three closest defects and count the center and radius of a circle containing them
- Check if the center didn't move too far away and whether the radius isn't too big
- If it's ok, count the mean of 10 last palm centers
- Resulting circle is the center of palm and size of the hand.
Piotr Pokorski