0

The above error still persists even after upgrading my opencv library and also uninstalling and reinstalling several times.

Any other tips to fix this error?

This my source code, the cv2.imshow() function started giving me the error.

cap = cv2.VideoCapture(0)
while True:
    _, frame = cap.read()

    sobelx = cv2.Sobel(frame, cv2.CV_64F, 1, 0, ksize=5)
    sobely = cv2.Sobel(frame, cv2.CV_64F, 0, 1, ksize=5)
    cv2.imshow('frame', frame)
    cv2.imshow('sobelx', sobelx)
    cv2.imshow('sobely', sobely)

    if cv2.waitKey(5) & 0xFF == 27:
        break

 cv2.destroyAllWindows()
 cap.release()

The Error Message I recieve:

    cv2.imshow('sobelx', sobelx)
    cv2.error: OpenCV(4.0.0) C:\projects\
    opencv-python\opencv\modules\highgui\src\window_w32.cpp:1230: 
    error: (-215:Assertion failed) dst.data == (uchar*)dst_ptr in function 'cvShowImage'

On the other hand the cv2.imshow() function works properly for the below code. Please note: The code below does not apply any filters like laplacian or sobel to the video feed.

cap = cv2.VideoCapture(0)
while True:
    _, frame = cap.read()
    cv2.imshow('frame', frame)

    if cv2.waitKey(5) & 0xFF == 27:
        break

cv2.destroyAllWindows()
cap.release()
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • Have you reviewed these other posts: https://stackoverflow.com/q/54336237/9987623, https://stackoverflow.com/q/54370220/9987623 – AlexK Mar 22 '19 at 05:15

1 Answers1

0

In this Github issue discussion, it was mentioned that this bug was fixed in OpenCV 4.0.1. Based on the error you received, it looks like you have 4.0.0, so another upgrade may be needed.

AlexK
  • 2,855
  • 9
  • 16
  • 27