Skip to content

imread Should Raise If Path Doesn't Exist #14095

@zhanwenchen

Description

@zhanwenchen
System information (version)
  • OpenCV => 4.0.1
  • Operating System / Platform => MacOS 10.14 Mojave
  • Compiler => Xcode 10.1
Detailed description

cv2.imread doesn't check file existence and reads nonexistent files into a NoneType object. In comparison, matplotlib.pyplot.imread and PIL both throw.

Steps to reproduce
import cv2

nonetype_thingy = cv2.imread('nonexistent_path.jpg') # this is somehow legal
cv2.imshow('lel', nonetype_thingy) # this will throw a "cv2.error: OpenCV(4.0.1) /Users/username/opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions