Back Projection and Shadows/Lighting [closed]

asked 2017-02-01 14:21:48 -0600

ginister gravatar image

updated 2017-02-01 14:28:17 -0600

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

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-09-26 14:56:57.203960