I am using Python3 and OpenCV to detect green dots in the following image:
Detected green dots via mask with OpenCV
The code for this is as follows:
import cv2
import numpy as np
img = cv2.imread("dot_test.png")
rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
lower_range = np.array([0, 250, 80])
upper_range = np.array([5, 255, 88])
mask = cv2.inRange(rgb, lower_range, upper_range)
cv2.imshow("Image", img)
cv2.imshow("Mask", mask)
cv2.waitKey(0)
cv2.destroyAllWindows()
Assuming the number of dots in dot_test.png is variable, I would like to store the coordinates of each dot in an array and iterate through them printing specific text. What would a good approach to accomplishing this be? I am a bit lost at this point.