Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to read image using openCV in python but I am facing following error error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’ in python. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
- How error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' Error Occurs ?
- How To Solve error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' Error ?
- Solution 1: load image properly
- Solution 2: Preface file names in Windows python with
r
- Solution 3: Just Check if the image exists
- Summary
How error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’ Error Occurs ?
I am trying to read image using openCV in python but I am facing following error.
cv2.error: OpenCV(3.4.3) /Users/ssc/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Here is my code.
frame = cv2.imread('path' % count)
How To Solve error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’ Error ?
- How To Solve error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’ Error ?
To Solve error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’ Error Make sure you are loaded Image properly. Because this error occurs whenever Image not Load properly or check if the images exist in the path you give and make sure the count variable have valid number
- error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’
To Solve error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor’ Error Make sure you are loaded Image properly. Because this error occurs whenever Image not Load properly or check if the images exist in the path you give and make sure the count variable have valid number
Solution 1: load image properly
Make sure you are loaded Image properly. Because this error occurs whenever Image not Load properly or check if the images exist in the path you give and make sure the count variable have valid number
Solution 2: Preface file names in Windows python with r
Preface file names in Windows python with r"...\...\"
as in
cv2.imread(r".\images\news.jpg")
Solution 3: Just Check if the image exists
Just Check if the image exists and try again
import numpy as np
import cv2
img = cv2.imread('your_image.png', 0)
cv2.imshow('image', img)
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array