Giúp mình với

  • Mình có đoạn code này:
    import cv2
    import numpy as np
    from matplotlib import pyplot as plt
    img = cv2.imread('dave.jpg',0)
    laplacian = cv2.Laplacian(img,cv2.CV_64F)
    sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5)
    sobely = cv2.Sobel(img,cv2.CV_64F,0,1,ksize=5)
    plt.subplot(2,2,1),plt.imshow(img,cmap = 'gray')
    plt.title('Original'), plt.xticks([]), plt.yticks([])
    plt.subplot(2,2,2),plt.imshow(laplacian,cmap = 'gray')
    plt.title('Laplacian'), plt.xticks([]), plt.yticks([])
    plt.subplot(2,2,3),plt.imshow(sobelx,cmap = 'gray')
    plt.title('Sobel X'), plt.xticks([]), plt.yticks([])
    plt.subplot(2,2,4),plt.imshow(sobely,cmap = 'gray')
    plt.title('Sobel Y'), plt.xticks([]), plt.yticks([])
    Chạy xong báo lỗi:
    C:\Users\0\Anaconda3\python.exe "C:/Users/0/PycharmProjects/Bai tap/"
    OpenCV Error: Assertion failed (dims <= 2 && step[0] > 0) in cv::Mat::locateROI, file D:\Build\OpenCV\opencv-3.3.0\modules\core\src\matrix.cpp, line 981
    Traceback (most recent call last):
    File "C:/Users/0/PycharmProjects/Bai tap/", line 5, in <module>
    laplacian = cv2.Laplacian(img,cv2.CV_64F)
    cv2.error: D:\Build\OpenCV\opencv-3.3.0\modules\core\src\matrix.cpp:981: error: (-215) dims <= 2 && step[0] > 0 in function cv::Mat::locateROI

    Process finished with exit code 1

    Sửa làm thế nào vậy mấy bạn

Log in to reply

Looks like your connection to Cộng đồng Python Việt Nam was lost, please wait while we try to reconnect.