|
@@ -50,16 +50,9 @@ def recognize(image):
|
|
|
|
|
|
image = image[corner_right_down[1]:corner_left_up[1],corner_right_down[0]:corner_left_up[0]]
|
|
|
|
|
|
- # hsv = cv2.cvtColor(image.copy(), cv2.COLOR_BGR2HSV)
|
|
|
- # hsv = cv2.GaussianBlur(hsv, (1, 1), 0)
|
|
|
- # _, thresh = cv2.threshold(hsv[:, :, 1], lower, upper, cv2.THRESH_BINARY)
|
|
|
- # cnts, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
|
- # cv2.drawContours(image, cnts, -1, (0, 255, 0), 2)
|
|
|
-
|
|
|
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
|
|
|
|
|
- thresh = cv2.threshold(image, lower, upper, cv2.THRESH_BINARY)[0]
|
|
|
- # thresh = cv2.adaptiveThreshold(image,upper,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,3,2)
|
|
|
+ thresh = cv2.adaptiveThreshold(image,upper,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,3,2)
|
|
|
binary = np.zeros(image.shape)
|
|
|
binary[image < thresh] = 1
|
|
|
|
|
@@ -81,5 +74,5 @@ def recognize(image):
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
while True:
|
|
|
- image = cv2.imread('falling_ball/image.png')
|
|
|
+ image = cv2.imread('falling_ball/image3.png')
|
|
|
print(recognize(image))
|