Reputation: 4275
I am a bit confused right now, i can't find the correct value for this green square. Here is the image
The hsv values that i choose are:-
cv::inRange(src, Scalar(25, 20, 20), Scalar(85, 255, 200), src);
Here is the output from this:-
What is the correct value for hsv that i should choose?
Upvotes: 0
Views: 1933
Reputation: 41775
These ranges should work good enough:
inRange(hsv, Scalar(35, 20, 20), Scalar(85, 255, 255), mask);
Remember that OpenCV stores images as BGR, and not RGB. So when you convert to HSV be sure to use COLOR_BGR2HSV
, and not COLOR_RGB2HSV
.
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
Mat3b img = imread("path_to_image");
Mat3b hsv;
cvtColor(img, hsv, COLOR_BGR2HSV);
Mat1b mask;
inRange(hsv, Scalar(35, 20, 20), Scalar(85, 255, 255), mask);
imshow("Mask", mask);
waitKey();
return 0;
}
You can find additional details on HSV ranges here and here
Upvotes: 1