IDE: VScode
环境:python3.6
启动调试报错:
(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
调试代码发现是读取文件路径问题,只要在文件路径前加一个 r 即可。
#coding=utf-8
import cv2
import numpy as np
def CannyThreshold(lowThreshold):
detected_edges = cv2.GaussianBlur(gray, (3, 3), 0)
detected_edges = cv2.Canny(
detected_edges, lowThreshold, lowThreshold*ratio, apertureSize=kernel_size)
# just add some colours to edges from original image.
dst = cv2.bitwise_and(img, img, mask=detected_edges)
cv2