-2
import cv2
image = cv2.imread("palm.jpg")
cv2.imshow("palm", image)
cv2.waitKey(0)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

Error in my screen:

cv2.imshow("palm", image)

cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

Community
  • 1
  • 1
Shubham
  • 5
  • 1
  • 1
  • 2

1 Answers1

1

Hey unfortunatly my reputation is not enough to comment, so I post this as an answer: I had this problem as well a couple of times. Every single time it turns out that I provided an incorrect path to the file.

I tried the code myself creating a palm.jpg in the same directory as the script I'm opening it with. It showed the BGR-Image as your code intends.

To me this means that opencv cannot open your "palm.jpg". To get more information you can try to set a breakpoint before the line

cv2.imshow("palm", image)

and have a look at the variable "image". If it does not contain meaningful information, you should have a look at List files ONLY in the current directory to check why palm.jpg is not in your working directory.

If it is on your working directory, maybe the palm.jpg is actually a palm.jpg.png (or similar).

Dennis
  • 145
  • 1
  • 8