Datasets:
slz1
/

ArXiv:
wxy_var / utils /canny.py
slz1's picture
Add files using upload-large-folder tool
7b4c6f4 verified
raw
history blame contribute delete
387 Bytes
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)