Assignment 2

CS 585 HW 2
Shubhangi Jain
Team-mate: Rajat Tripathi
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. To make image invariant to background noise, used subtraction making first frame as background and subsequently subtracting next incoming frames
  2. Converted image in gray scale and after that ran experiments on different range values to detect the pixel value of skin color
  3. Used thresholding to binarize the image for detected skin pixels
  4. Same sets of transformations are incorporated to the template image as well
  5. Scaled the template image through a range of scaling factors and compared it 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