I tried both my local python env and google colab.
opencv version is 3.4.2 and 4.1.2 each...
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('./zebra.png',cv2.IMREAD_GRAYSCALE)
canny = cv2.Canny(img,30,70)
laplacian = cv2.Laplacian(img,cv2.CV_64F)
sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=3)
sobely = cv2.Sobel(img,cv2.CV_64F,0,1,ksize=3)
images = [img,laplacian, sobelx, sobely, canny]
titles = ['Origianl', 'Laplacian', 'Sobel X', 'Sobel Y','Canny']
for i in [0,1,2,3,4]:
plt.subplot(2,3,i+1),plt.imshow(images[i]),plt.title([titles[i]])
plt.xticks([]),plt.yticks([])
plt.show()
error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\core\src\matrix.cpp:755: error: (-215:Assertion failed) dims <= 2 && step[0] > 0 in function 'cv::Mat::locateROI'
it cause error on cv2.CV_64F...I changed it to CV_8U but it has same problem.
how can I solve this?
↧