IoT_Color Detection - nomrand/thai GitHub Wiki

Making Color Range

hsv = cv2.cvtColor(cvimage, cv2.COLOR_BGR2HSV)

hsv_min = np.array([0, 100, 0])
hsv_max = np.array([30, 255, 255])
range1 = cv2.inRange(hsv, hsv_min, hsv_max)

hsv_min = np.array([150, 100, 0])
hsv_max = np.array([179, 255, 255])
range2 = cv2.inRange(hsv, hsv_min, hsv_max)

Detect Color Areas

contours, _ = cv2.findContours(cvimage, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

Show borders

cvimage = cv2.drawContours(orgimage, contours, -1, (0, 255, 0), 1)