我正在尝试让网络摄像头在BGR中拍摄某人的脸,将图片转换为HSV,然后分析这些将在皮肤检测算法中使用的HSV值.不幸的是,即使在我尝试使用cvtColor()转换它之后,图像似乎也在BGR中进行了分析.
我使用下面的代码来测试我是否使用了正确的色彩空间.请注意我尝试将饱和度和值设置为0的部分:
Mat faceROI = findFace(first); //basic Mat, region of interest for face (code not included)
Mat temp;
faceROI.convertTo(temp, CV_8UC3); //making sure this has right no. of channels and such
CvScalar s;
IplImage face_ipl = temp; //new header
IplImage* aNew = cvCreateImage(cvGetSize(&face_ipl), face_ipl.depth, 3);
cvCvtColor(&face_ipl, aNew, CV_BGR2HSV);
for(int x = 0; x < faceROI.cols; x++){
for (int y = 0; y < faceROI.rows; y++){
s = cvGet2D(aNew, x, y);
//vvvvvvvvvvv
s.val[1] = 0; //should be saturation
s.val[2] = 0; //should …Run Code Online (Sandbox Code Playgroud)