Modify the adaptiveskindetector. cpp of opencv and remove the complicated command line parameter input. You only need a Network Camera to run it.
In terms of principles, I roughly looked at the usage of the color information in the HSV space.
The effect is good, but it seems that the detection effect is poor for white walls, especially milky white walls and wall panels.
This is the first small item published here. update it every week with the source code (C ++, vs2008)
Skin Detection
/************************************************************************/
/* adaptive skin detection
modified from opencv's adaptiveskindetector.cpp
opencv2.0 is required
welcome to visit my website: http://yangyangwenjia.appspot.com/
*/
/************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cvaux.h>
#include
int main(int argc, char** argv )
{
CvAdaptiveSkinDetector filter(1, CvAdaptiveSkinDetector::MORPHING_METHOD_ERODE_DILATE);
int camWidth = 640;
int camHeight = 480;
IplImage *maskImg = cvCreateImage( cvSize(camWidth, camHeight), IPL_DEPTH_8U, 1);
IplImage *skinImg = cvCreateImage( cvSize(camWidth, camHeight), IPL_DEPTH_8U, 3);
cvNamedWindow("skin", CV_WINDOW_AUTOSIZE);
cvNamedWindow("source", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCaptureFromCAM( 0 );
IplImage* frame = 0;
for(;;)
{
cvZero(skinImg);
frame = cvQueryFrame( capture );
if( !frame )
break;
filter.process(frame, maskImg); // process the frame
cvCopy(frame,skinImg,maskImg);
cvShowImage ("skin", skinImg);
cvShowImage ("source", frame);
if (cvWaitKey(1) == 27)
break;
}
cvReleaseImage(&skinImg);
cvReleaseImage(&maskImg);
cvReleaseCapture( &capture );
cvDestroyWindow("skin");
cvDestroyWindow("source");
return 0;
}
Hope you find it useful ~