Anjum Shrimali
Anjum Shrimali

Reputation: 346

HSV range for open cv iOS

I am trying to detect skin in iOS through open cv. My Code is mentioned below.

cvCvtColor(&srcIplImage, &hsvIplImage, CV_BGR2HSV);

CvScalar lower = cvScalar(0, 58, 88);
CvScalar upper = cvScalar(25, 173, 229);

cvInRangeS(&hsvIplImage, lower, upper, &srcGrayIplImage);

cvCvtColor(&srcGrayIplImage, &dstIplImage, CV_GRAY2BGR);

In android, it works perfectly and detects skin properly. But in iOS I get very unexpected result. I think there are different ranges of HSV being used by open cv in iOS and Android. For android my lower and upper limits are ok, but the same is not for iOS.

If anyone as faced this kind of problem, please help me out for the solution.

Thanks in advance.

Upvotes: 1

Views: 1057

Answers (1)

Anjum Shrimali
Anjum Shrimali

Reputation: 346

I have sorted out the issue by hit and trial. Normal HSV range is as mentioned below.

Hue: 0 - 360. (Its' an angle) Saturation: 0 - 100 (Intensity of color) Value: 0 - 100 (Brightness)

in iOS it has the following range, Hue: 0 - 180. (Its' an angle) Saturation: 0 - 255 (Intensity of color) Value: 0 - 255 (Brightness)

in Android

Hue: 0 - 360. (Its' an angle) Saturation: 0 - 255 (Intensity of color) Value: 0 - 255 (Brightness)

Another you need to take care that the color scheme in iOS OpenCV is BGR not RGB. So the Hue section will cover Blue color in range of 0-60 degree instead of red. You will have to change the Hue value accordingly for iOS.

Hope this can be useful to someone else :)

Upvotes: 3

Related Questions