SkinColorDetection-master

所属分类:图形图像处理
开发工具:C++
文件大小:15KB
下载次数:4
上传日期:2017-02-24 16:16:15
上 传 者z_hao
说明:  皮肤检测算法源码,c++实现,采用四种不同策略提取皮肤部分。
(Skin detection algorithm source code, c++ implementation, using four different strategies to extract part of the skin.)

文件列表:
EllipseModel.cpp (1085, 2015-06-03)
EllipseModel.h (224, 2015-06-03)
QuadPoly.cpp (1942, 2015-06-03)
QuadPoly.h (256, 2015-06-03)
RGBColorSpace.cpp (1002, 2015-06-03)
RGBColorSpace.h (170, 2015-06-03)
SkinColor.cpp (774, 2015-06-03)
SkinColor.sln (941, 2015-06-03)
SkinColor.vcxproj (5326, 2015-06-03)
SkinColor.vcxproj.filters (2447, 2015-06-03)
SkinDetector_OPENCV.cpp (468, 2015-06-03)
SkinDetector_OPENCV.h (191, 2015-06-03)
Strategy.cpp (555, 2015-06-03)
Strategy.h (219, 2015-06-03)
YCbCrColorSpace.cpp (632, 2015-06-03)
YCbCrColorSpace.h (176, 2015-06-03)
opencv2410.props (1737, 2015-06-03)
opencv248.props (1702, 2015-06-03)
stdafx.cpp (288, 2015-06-03)
stdafx.h (591, 2015-06-03)
targetver.h (306, 2015-06-03)

# Skin Color Detection ## System Requirement - Visual Studio Community 2013 - OpenCV 2.4.10 ## Introduction This repository is used for detection skin color in the image. Different methods are incorporated into this repository to detect skin in different circumstance. Strategy pattern are used in this repository, so different method can be invoked simply by initial corresponding class name. ## Demo ``` Mat SrcImg = imread("G:/data/20150528173901.jpg"); resize(SrcImg, SrcImg, Size(384, 512)); Mat DstImg; // Select different methods //Strategy *Ptr2SkinDetector = new QuadPoly(SrcImg); //Strategy *Ptr2SkinDetector = new RGBColorSpace(SrcImg); //Strategy *Ptr2SkinDetector = new YCbCrColorSpace(SrcImg); //Strategy *Ptr2SkinDetector = new SkinDetector_OPENCV(SrcImg); Strategy *Ptr2SkinDetector = new EllipseModel(SrcImg); Ptr2SkinDetector->detectSkin(); Ptr2SkinDetector->getResult(DstImg); //imwrite("G:/data/SkinColor.jpg", DstImg); namedWindow("Src"); namedWindow("Dst"); imshow("Src", SrcImg); imshow("Dst", DstImg); cvWaitKey(0); return 0; ``` ## Interfaces ### Base class - `Strategy` The base class is an abstract class that converts the image to proper formation, so that the skin detection algorithm can process the images well. ``` class Strategy { public: Strategy(Mat FaceImg); virtual ~Strategy(); virtual void detectSkin() = 0; void getResult(Mat &Result); protected: Mat SrcImage, DstImage; void normalizeImage(Mat &Src); }; ``` - `Strategy(Mat FaceImg)` - construct the class with a image `FaceImg` - `~Strategy()` - destructor - `detectSkin()` - pure virtual function, used for detect skin color in derived class - `getResult(Mat &Result)` - get the result image - `normalizeImage(Mat &Src)` - normalize the image in the `V-channel` ### Skin Color Detector in OpenCV ``` class SkinDetector_OPENCV : public Strategy { public: SkinDetector_OPENCV(Mat InputImg); virtual ~SkinDetector_OPENCV(); virtual void detectSkin(); }; ``` ### Quad Poly ``` class QuadPoly : public Strategy { public: QuadPoly(Mat InputImage); virtual ~QuadPoly(); virtual void detectSkin(); private: void getNormalized(Mat &Normalized, Mat &Sum); void getMask(const Mat &Normalized); }; ``` ### RGB Color Space ``` class RGBColorSpace : public Strategy { public: RGBColorSpace(Mat Input); virtual ~RGBColorSpace(); virtual void detectSkin(); }; ``` ### YCbCr Color Space ``` class YCbCrColorSpace : public Strategy { public: YCbCrColorSpace(Mat Input); virtual ~YCbCrColorSpace(); virtual void detectSkin(); }; ``` ### Ellipse model ``` class EllipseModel : public Strategy { public: EllipseModel(Mat inputImg); virtual ~EllipseModel(); virtual void detectSkin(); private: Mat skinCrCbHist; void setSkinCrCbHist(); }; ```

近期下载者

相关文件


收藏者