I want to detect a white/grey object in OpenCV and therefore I need to convert #B4BAB8
into a OpenCV HSV value. I tried so many things, but I don know how to calculate the lowerb and upperb of this color.. #B4BAB8 is the color of the object.
What values should I use in cv::inRange(frmHsv, cv::Scalar([WHAT VALUE?]), cv::Scalar([WHAT VALUE?]), rangeRes);
?
cv::Mat frmHsv;
cv::cvtColor(blur, frmHsv, CV_BGR2HSV);
// <<<<< HSV conversion
// >>>>> Color Thresholding
// Note: change parameters for different colors
cv::Mat rangeRes = cv::Mat::zeros(rgbmat.size(), CV_8UC1);
cv::inRange(frmHsv, cv::Scalar([WHAT VALUE?]), cv::Scalar([WHAT VALUE?]), rangeRes);
I ran into this when I was working with color spaces in OpenCV. As @Andrey Smorodov mentioned in the comment, the value #b4bab8 is a hex and can be interpreted in any color space. If you have the RGB value as you mention 180,186,184, follow this for the conversion OpenCV uses when using Imgproc.cvtcolor(). The conversion is different from ones on this and hence this would work for RGB to BGR but not for BGR2HSV. Also, make sure the conversion which you make corresponds to the correct Type of your Matrix.
For example, for a matrix of type CV_32FC3, RGB (245,172,127) would be LUV(2.55*76.3, 255*(134+53.3)/358.0, 255 * (39.5 +140) / 262.0). You can simply make an empty "RGB" image with color (180,186,184) of whatever type you want and use cvtcolor to change BGR2HSV (Note: OpenCV loads all RGB images as BGR) and check what the value in HSV color space is. Let me know if it helps!