Assertion failure : size.width>0 && size.height>0 in function imshow
The log where the error occurred in the code below is as follows
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /tmp/opencv-20170825-90583-1pdhamg/opencv-3.3.0/modules/highgui/src/window.cpp, line 325
Traceback (most recent call last):
File "imageToStr.py", line 6, in <module>
cv2.imshow('fuck image', img)
cv2.error: /tmp/opencv-20170825-90583-1pdhamg/opencv-3.3.0/modules/highgui/src/window.cpp:325: error: (-215) size.width>0 && size.height>0 in function imshow
The code looks like this:
import numpy as np
import cv2
img = cv2.imread('./fuckIage.png', cv2.IMREAD_COLOR)
cv2.imshow('fuck image', img)
cv2.waitKey(0)
The run-time hierarchy is as follows.
.
├── fuckIage.png
├── imageToStr.py
├── main.py
├── stu.py
├── study.py
└── study.pyc
The file exists and is in the path.
So for the time being, let's specify the screen size.
import numpy as np
import cv2
img = cv2.imread('.fuckIage.png', cv2.IMREAD_COLOR)
cv2.namedWindow('img', cv2.WINDOW_NORMAL)
cv2.imshow('fuck image', img)
cv2.waitKey(0)
I was able to execute it.
After that, try the following.
import numpy as np
import cv2
img = cv2.imread('.fuckIage.png', cv2.IMREAD_COLOR)
#Let's comment out. cv2.namedWindow('img', cv2.WINDOW_NORMAL)
cv2.imshow('fuck image', img)
cv2.waitKey(0)
success!
Maybe the value didn't pass,
Unable to refer to error
Probably before doing these
Given that the numpy version is causing errors and after fixing them,
The value passed to the binary is cleared and
So I think that such a case occurred
This is a hypothetical stage.
I still don't know the real cause
Currently trying to reproduce to investigate the cause,
I will write it here as soon as I understand it
If anyone is suffering from a similar event
I would like you to tell me.
Recommended Posts