error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Following an OpenCV tutorial. Followed instructions on https://pypi.org/project/opencv-contr.... The package works great until the tutorial asks to include the following in the script
gray = cv2.cvtColor(color, cv2.COLOR_RGB2GRAY)
Write here how did you expect the library to function. The tutorial asks to create a script to transform different layers Following the video it is supposed to split the channels and convert them to grayscale. I'm not 100% sure since I'm new.
Actual behaviour The following error occurs when running the command:
python3 02_05.py
with pwd showing that I am in the required folder
File "02_05.py", line 6, in <module> gray = cv2.cvtColor(color, cv2.COLOR_RGB2GRAY) cv2.error: OpenCV(4.1.2)
/Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182:
error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' I don't have a user called Travis on my computer in case that is not obvious Steps to reproduce example code:: This is the full script::
import numpy as np
import cv2
color = cv2.imread("butterfly,jpg",1 )
gray = cv2.cvtColor(color, cv2.COLOR_RGB2GRAY)
cv2.imwrite("gray.jpg", gray)
b = color [:,:, 0]
g = color [:,:, 1]
r = color [:,:, 2]
rgba = cv2.merge((b,g,r, g))
cv2.imwrite("rgba.png", rgba)
` That was the full script
operating system : Mac OSX Mojave 10.14.4 architecture (e.g. x86) : Mac OSX Mojave 10.14.4 (Apple?) opencv-python version : opencv-contrib-python 4.1.2.30 Thank you.
Check image path