Skip to content

Commit 2c4489f

Browse files
committed
works well with new light
1 parent b6abffa commit 2c4489f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

water.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def calibrate_gauge(inputfile):
2929
#gray = cv2.GaussianBlur(gray, (5, 5), 0)
3030
#gray = cv2.medianBlur(gray, 5)
3131

32-
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 10, np.array([]), 35, 35, 30, 50)
32+
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 20, np.array([]), 30, 30, 35, 50)
3333

3434
a, b, c = circles.shape
3535
x = 0
@@ -130,20 +130,20 @@ def get_current_value(img, min_angle, max_angle, min_value, max_value, x, y, r,
130130
# find pointer arrow
131131
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
132132
# Create a mask so that we use only the red arrows
133-
lower_red = np.array([0, 10, 10])
134-
upper_red = np.array([30, 255, 255])
133+
lower_red = np.array([0, 0, 0])
134+
upper_red = np.array([40, 255, 255])
135+
hsv = cv2.medianBlur(hsv, 17)
135136
mask = cv2.inRange(hsv, lower_red, upper_red)
136137
cv2.imwrite("hsv.png", mask)
137138
res = cv2.bitwise_and(img, img, mask = mask)
138-
edges = cv2.Canny(res, 300, 400, apertureSize=5)
139+
edges = cv2.Canny(res, 100, 400, apertureSize=5)
139140
vis = img.copy()
140141
#vis = np.uint8(vis/2.)
141142
#vis[edges != 0] = (0, 255, 0)
142143

143144

144145
#Getting and Displaying Contours
145-
im2,contours,hierarchy=cv2.findContours(edges.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
146-
#cv2.drawContours(vis, contours, -1, (0, 255, 0), 1)
146+
im2,contours,hierarchy=cv2.findContours(edges.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
147147

148148
cv2.drawContours(vis, contours,-1,(255, 255, 0), 1)
149149

0 commit comments

Comments
 (0)