I am trying to use inrange function in opencv to get the square(green part) but it doesn't seems to work. Here is my image
Here is my code:
cv::inRange(src, cv::Scalar(35, 20, 20), cv::Scalar(85, 255, 200), src);
And here is the output for my code:
How can i get all the green part using correct hsv values....
Look at the HSV color wheel and pick the right range. Be aware that HSV has fit into 3 8 bit- channels, but the H channel does not, so you have to divide this value by 2. The range for H is 0-180 in OpenCV. See this question for reference.
With this configuration ( I tested the values with ImageJ not OpenCV)
cv::inRange(src, cv::Scalar(35, 60, 200), cv::Scalar(60, 255, 255), src);
i got this result:
With
cv::findContours
you can easily detect all contours and filter just the square by shape and size or by their hierarchy.