22 cv2.destroyAllWindows()
26 success, image_src = self.cameraCapture.read()
30 print(
"ERROR: cameraCapture.read()")
41 image2_hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
43 LowerBlue = np.array([90, 100, 100])
44 UpperBlue = np.array([130, 255, 255])
45 mask = cv2.inRange(image2_hsv, LowerBlue, UpperBlue)
46 image3_hsv = cv2.bitwise_and(image2_hsv, image2_hsv, mask=mask)
47 image4_gry = image3_hsv[:,:,0]
49 blurred = cv2.blur(image4_gry, (9, 9))
50 (_, thresh) = cv2.threshold(blurred, 90, 255, cv2.THRESH_BINARY)
51 kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (25, 25))
52 closed = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, kernel)
54 closed = cv2.erode(closed,
None, iterations=4)
55 closed = cv2.dilate(closed,
None, iterations=4)
57 cv2.imshow(
'win6_bin', closed)
59 aaa, contours, hier = cv2.findContours(closed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
62 x, y, w, h = cv2.boundingRect(c)
63 rect = cv2.minAreaRect(c)
64 box = cv2.boxPoints(rect)
66 cv2.drawContours(image, [box], 0, (0, 0, 255), 3)
68 pose_mid[i] = [(box[0][0] + box[2][0])/2, (box[0][1] + box[2][1])/2]
69 w = math.sqrt((box[0][0] - box[1][0])**2 + (box[0][1] - box[1][1])**2)
70 h = math.sqrt((box[0][0] - box[3][0])**2 + (box[0][1] - box[3][1])**2)
76 cv2.imshow(
"Image", image)
def __init__(self, video_port)
def identify_colour(self, image, pose_mid, s, show_image=0)