Python Assertion failure: size.width> 0 && size.height> 0 in function imshow

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

Python Assertion failure: size.width> 0 && size.height> 0 in function imshow
Use callback function in Python
Nonlinear function modeling in Python
Draw implicit function in python
Immediate function in python (lie)
Implement R's power.prop.test function in python
Function argument type definition in python
Included notation in Python function arguments
Write AWS Lambda function in Python
Measure function execution time in Python
python function ①
Precautions when pickling a function in python
[Python] function
OR the List in Python (zip function)
python function ②
Draw a graph of a quadratic function in Python
Automatically register function arguments to argparse in Python
To execute a Python enumerate function in JavaScript
Get the caller of a function in Python
[Neta] Thread-safe Sleep Sort function in Python (threading)
I implemented the inverse gamma function in python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
python enumerate function
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
[Python] Generator function
Sudoku in Python
DCI in Python
quicksort in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
LINE-Bot [0] in Python
Python> function> Inner function
Csv in python
Disassemble in Python
Reflection in Python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Python function decorator
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python