Skip to content
Permalink
Browse files

fix(video preprocessor): remove custom canny threshold

  • Loading branch information...
raccoonliukai committed Aug 22, 2019
1 parent 16aaa77 commit 47721b1ca5e440244f6dc0a5a0e5fe5a1e7f9660
Showing with 6 additions and 13 deletions.
  1. +6 −13 gnes/preprocessor/helper.py
@@ -269,9 +269,6 @@ def hsv_histogram(image: 'np.ndarray') -> 'np.ndarray':

def canny_edge(image: 'np.ndarray', **kwargs) -> 'np.ndarray':
arg_dict = {
'compute_threshold': True,
'low_threshold': 0,
'high_threshold': 200,
'sigma': 0.5,
'gauss_kernel': (9, 9),
'l2_gradient': True
@@ -281,17 +278,13 @@ def canny_edge(image: 'np.ndarray', **kwargs) -> 'np.ndarray':
arg_dict[k] = v

image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# add threshold for canny
low_threshold = arg_dict['low_threshold']
high_threshold = arg_dict['high_threshold']
if arg_dict['compute_threshold']:
# apply automatic Canny edge detection using the computed median
v = np.median(image)
sigma = arg_dict['sigma']
low_threshold = ((1.0 - sigma) * v).astype("float32")
high_threshold = ((1.0 + sigma) * v).astype("float32")
# apply automatic Canny edge detection using the computed median
v = np.median(image)
sigma = arg_dict['sigma']
low_threshold = ((1.0 - sigma) * v).astype("float32")
high_threshold = ((1.0 + sigma) * v).astype("float32")
tmp_image = cv2.GaussianBlur(image, arg_dict['gauss_kernel'], 1.2)
edge_image = cv2.Canny(tmp_image, low_threshold, high_threshold, L2gradient=arg_dict['L2'])
edge_image = cv2.Canny(tmp_image, low_threshold, high_threshold, L2gradient=arg_dict['l2_gradient'])
return edge_image


0 comments on commit 47721b1

Please sign in to comment.
You can’t perform that action at this time.