-1

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:

Error message

Can anyone help?

sticky bit
  • 36,626
  • 12
  • 31
  • 42
  • We would need your jpg in order to try to reproduce and understand the problem – EdChum Jul 10 '19 at 08:00
  • Possible duplicate of [OpenCV Error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'](https://stackoverflow.com/questions/52739143/opencv-error-215assertion-failed-vscncontainsscn-vdcncontainsdcn) – T A Jul 10 '19 at 09:18
  • Have you tried to observe the values in your image `print(img)`. It may help you debug (this particular problem as well as in general). Hints to look after : Is the image `None` ? Is the image in `uint8` or in `float32` ? is the image in `[0, 1]` or in `[0, 255]` ? – Joseph Budin Jul 10 '19 at 13:03
  • Did you take a look at this answer ? https://stackoverflow.com/a/3823822/6809926 – Zenocode Jul 10 '19 at 14:59

1 Answers1

-1

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.

Terrence Poe
  • 634
  • 4
  • 17