opencv-python,cv2.Canny报错问题

import matplotlib.pyplot as plt
import cv2

img = mplimg.imread(‘line.png’)
edges = cv2.Canny(img, 100, 100)
plt.imshow(edges)
plt.show()

报错:
cv2.error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\imgproc\src\canny.cpp:947: error: (-215:Assertion failed) _src.depth() == CV_8U in function ‘cv::Canny’

解决:
将img = mplimg.imread(‘line.png’)改为 img = cv2.imread(‘line.png’)即可

你可能感兴趣的:(opencv-python,cv2.Canny报错问题)