File size: 387 Bytes
7b4c6f4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import cv2
import torch
import numpy as np
class CannyDetector:
def __call__(self, img, low_threshold=100, high_threshold=200):
"""
input: array or tensor (H,W,3)
output: array (H,W)
"""
if torch.is_tensor(img):
img = img.cpu().detach().numpy().astype(np.uint8)
return cv2.Canny(img, low_threshold, high_threshold)
|