Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(video preprocessor): remove custom canny threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
raccoonliukai committed Aug 22, 2019
1 parent 16aaa77 commit 47721b1
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions gnes/preprocessor/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down

0 comments on commit 47721b1

Please sign in to comment.