Assignment 2

CS 585 HW 2
Shoumik Majumdar
Team-mate: Tushar Sharma
Feb 12, 2020

Problem Definition

Using Template Matching and other basic computer vision techiniques to build a program using OpenCV that can recongnize 4 different hand shapes in real-time.

Method and Implementation


  1. Using background subtraction to make the program invariant to background noise
  2. Detecting skin color by using a range of RGB values obtained through experiments
  3. Using thresholding to binarize the image for detected skin pixels
  4. Applied the same set of transformations to the template image
  5. A range of scaling factors is used to scale the set of template images and it's compared with the source frame
  6. The template with the highest NCC with the scene is reported
  7. Following OpenCV methods were used:


    These are the four different templates used:

    PalmPalm Template
    GunHole Template
    LPeace Template
    PeaceThumbUp Template


    Here are several recognition results of all four hand shapes:

    Hand Shape NameResult
    PalmRecongnition of a palm
    GunRecongnition of a hole-shaped hand
    LRecongnition of a V-shaped hand
    PeaceRecongnition of a thumb-up

    The following confusion matrix was obtained by changing the hand gestures

    Hand ShapePalmGunLPeace



    Based on the discussion, we concluded that background subtraction is a powerful technique for isolating hand-motion and when coupled with thresholding, it becomes a useful tool for recognising different hand-gestures.

    Credits and Bibliography