OpenCV Backprojection inaccurate [closed]

asked 2017-01-24 16:04:37 -0600

ginister gravatar image

updated 2018-01-07 17:05:33 -0600

I'm following the official openCV tutorial (can't post link or image, newbie!) to identify a hand in the scene however my code is giving very poor results. Does anyone know why I'm identifying the background more than finger tips, which are relatively similar values of H & S? My code so far is:

Mat imageHSV, roi;
int bins = 25;
cvtColor(image, imageHSV, CV_BGR2HSV);
roi = imageHSV(cv::Rect((image.cols/2)-10, (image.rows/2)-10, 20, 20));
//Process our input (some code adapted from OpenCV backprojection article
hue.create(imageHSV.size(), imageHSV.depth());
int channels[] = {0,0};
mixChannels(&imageHSV, 1, &hue, 1, channels, 1);
MatND backproj;
int histSize = MAX(bins,2);
float hue_range[] = {0,180};
const float* ranges = {hue_range};
calcHist(&hue, 1, 0, Mat(), roi, 1, &histSize, &ranges, true, false);
normalize(roi, roi, 0, 255, NORM_MINMAX, -1, Mat());
calcBackProject(&hue, 1, 0, roi, backproj, &ranges, 1, true);
image = backproj;

Here is an example screenshot:

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:39.945621

Comments

https://i.stack.imgur.com/GkOuq.png (Result)

ginister gravatar imageginister ( 2017-01-24 16:09:36 -0600 )edit