I'm attempting to follow the instructional exercise here and I continue getting the accompanying mistake.
The issue is on the grounds that cvtColor just takes 8 or 16-bit images
My picture is a png, from plt.savefig() in matplotlib and I think it is a 24-bit picture
1) Is my diagnosis of the problem correct or am I completely wrong?
2) Assuming 1) is true, I have been looking for ways to turn the 24-bit image into a 8/16 bit, but I haven't found anything so far. My matplotlib plot was a picture saved from a numpy array that is saved as array.npy file. Should I try to modify the array.npy file instead?
Code for reference:
import cv2 as cv
im = cv.imread("binary_graph_8.png")
imgray = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
ret, thresh = cv.threshold(imgray, 127, 255, 0)
im2, contours, hierarchy = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
Error message:
File "C:/Users/ek247/.PyCharm2018.3/config/scratches/scratch_1.py", line 5, in <module>
imgray = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'