简体   繁体   中英

I cant open images in OpenCV

I can not open my images on Jupyter suddenly anymore, do you know why?

import cv2
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
img = cv2.imread('DATA/crossword.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(img)

The error message that I get

--------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-7-21f16fc8e901> in <module>()
----> 1 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
      2 plt.imshow(img)

error: OpenCV(3.4.2) c:\miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\imgproc\src\color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'cv::CvtHelper<struct cv::Set<3,4,-1>,struct cv::Set<3,4,-1>,struct cv::Set<0,2,5>,2>::CvtHelper'

Error message:

错误信息

Can anyone help?

check your imgread path. for example: I copy file path from window.
D:\\Python tutorial\\pyc_opencv\\img\\2253.png
but got the error.

D:/Python tutorial/pyc_opencv/img/2253.png
Success.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM