Reputation: 207
I saved inverted binarized images after extracting lines from tables as png (did it with opencv). Now when I try to load them with opencv or matplotlib it will show NoneType or the error in the headline. I have checked many different posts with the same error. I guess it has something to do with the image data.
import cv2
import matplotlib.pyplot as plt
imgs = cv2.imread('Users/marius/Desktop/PDF/imgvh/1.png')
cv2.imshow('Users/marius/Desktop/PDF/imgvh/1.png', imgs)
The error which occurs when using cv2:
cv2.error: OpenCV(4.2.0) /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
Using matplotlib in this way:
imgs = plt.imshow('Users/marius/Desktop/PDF/imgvh/1.png')
plt.show()
leads to the following error:
TypeError: Image data of dtype <U49 cannot be converted to float
Upvotes: 1
Views: 592
Reputation: 207405
The OpenCV part doesn't work because you omitted the slash at the start of the path ahead of Users/marius...
. It should be:
imgs = cv2.imread('/Users/marius/Desktop/PDF/imgvh/1.png')
The matplotlib part doesn't work because it should be:
imgs = cv2.imread('/Users/marius...')
plt.imshow(imgs)
plt.show()
Upvotes: 1