Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Back Projection and Shadows/Lighting

Hi everyone,

I am currently back projecting in order to find my hands in a video feed however the current solution is too lighting dependent. I am currently converting to HSV and sampling an ROI ( I cover the camera with my hand at this point). Then I use this histogram to backproject as shown. If I pose my fingers down to create a shadow on my hand this loses accuracy, and as you can see the background has a lot of false positives. Can anyone give me some advice on how to improve this?

Thanks.

//0,1 means use H and S channels in backproj
  int channels[] {0, 1};
  //Bins are the number of bars in the histogram that a value can fall into
  int histSize[] = { h_bins, s_bins };
  float hue_range[] = {0, 180};
  float sat_range[] = {0, 255};
  const float* ranges[] = { hue_range, sat_range };

  if (sampleHand){
    //Uncomment to blur
    /*cv::Size *mySize = new cv::Size(15,15);
    GaussianBlur(hsv, hsv, *mySize, 5, 5);*/

    Mat roi;
    getRectSubPix(hsv, *new cv::Size(50,50), *new cv::Point(hsv.cols/2, hsv.rows/2), roi);
    calcHist(&roi, 1, channels, Mat(), skinShadeHist, 2, histSize, ranges, true, false);
    normalize(skinShadeHist, skinShadeHist, 0, 255, NORM_MINMAX, -1, Mat());
    samplesExist = true; sampleHand = false;
  } else if (samplesExist){

    MatND backproj;
    //Calculate the 'confidence' of a pixel being skin
    calcBackProject(&hsv, 1, channels, skinShadeHist, backproj, ranges, 1, true);
    return backproj;
  }

Back Projection and Shadows/Lighting

Hi everyone,

I am currently back projecting in order to find my hands in a video feed however the current solution is too lighting dependent. I am currently converting to HSV and sampling an ROI ( I cover the camera with my hand at this point). Then I use this histogram to backproject as shown. If I pose my fingers down to create a shadow on my hand this loses accuracy, and as you can see the background has a lot of false positives. Can anyone give me some advice on how to improve this?

Thanks.

//0,1 means use H and S channels in backproj
  int channels[] {0, 1};
  //Bins are the number of bars in the histogram that a value can fall into
  int histSize[] = { h_bins, s_bins };
  float hue_range[] = {0, 180};
  float sat_range[] = {0, 255};
  const float* ranges[] = { hue_range, sat_range };

  if (sampleHand){
    //Uncomment to blur
    /*cv::Size *mySize = new cv::Size(15,15);
    GaussianBlur(hsv, hsv, *mySize, 5, 5);*/

    Mat roi;
    getRectSubPix(hsv, *new cv::Size(50,50), *new cv::Point(hsv.cols/2, hsv.rows/2), roi);
    calcHist(&roi, 1, channels, Mat(), skinShadeHist, 2, histSize, ranges, true, false);
    normalize(skinShadeHist, skinShadeHist, 0, 255, NORM_MINMAX, -1, Mat());
    samplesExist = true; sampleHand = false;
  } else if (samplesExist){

    MatND backproj;
    //Calculate the 'confidence' of a pixel being skin
    calcBackProject(&hsv, 1, channels, skinShadeHist, backproj, ranges, 1, true);
    return backproj;
  }

Current output