Sunday, 15 July 2012

opencv - finding the skin tone percentage of a person from an image (not a web cam feed ) ignoring the background -



opencv - finding the skin tone percentage of a person from an image (not a web cam feed ) ignoring the background -

i need find percentage of skintone of person in given image.

i have been able count pixels skin colour far having problem ignoring background of person can count number of pixels percentage.

backgroundsubtractormog2 bg; bg.nmixtures =3; bg.bshadowdetection=false; bg.operator ()(img,fore); bg.getbackgroundimage(back);

img image. trying separate , fore mat objects, above code snippet back , fore take same value img. nil happening.

can point me in right direction changes have create right?

i able run similar code found here:

http://mateuszstankiewicz.eu/?p=189

i had alter couple of things, ended working (back , fore not same img when displayed:

int main(int argc, char *argv[]) { mat frame, back, fore; videocapture cap(0); backgroundsubtractormog2 bg; vector<std::vector<point> > contours; namedwindow("frame"); namedwindow("background"); namedwindow("foreground"); for(;;) { cap >> frame; bg.operator ()(frame, fore); bg.getbackgroundimage(back); erode(fore, fore, mat()); dilate(fore, fore, mat()); findcontours(fore, contours, cv_retr_external, cv_chain_approx_none); drawcontours(frame, contours, -1, scalar(0, 0, 255), 2); imshow("frame", frame); imshow("background", back); imshow("foreground", fore); if(waitkey(1) == 27) break; } homecoming 0; }

image opencv detection

No comments:

Post a Comment