Object Recognition using Python (OpenCV)

Viewed 27

I am trying to implement a program where the user inputs RGB values and the program detects number of objects using OpenCV library. I was able to implement the functionality. However, it works with images made in MS Paint as the color is consistent. However, when I use real world images it doesn't work. How should I implement it using HSV and range of HSV?

I tried the approach on the below mentioned link: https://techvidvan.com/tutorials/detect-objects-of-similar-color-using-opencv-in-python/

# lower bound and upper bound for Green color
lower_bound = np.array([50, 20, 20])   
upper_bound = np.array([100, 255, 255])
# find the colors within the boundaries
mask = cv2.inRange(hsv, lower_bound, upper_bound)

In this case they are able to select a range for green and yellow color. How can I select the range based on the RGB values given by the user?

0 Answers
Related