[英]TypeError: Image data cannot be converted to float // When importing .png images
I saved inverted binarized images after extracting lines from tables as png (did it with opencv).从表格中提取线条为 png 后,我保存了倒置的二值化图像(使用 opencv 完成)。 Now when I try to load them with opencv or matplotlib it will show NoneType or the error in the headline.
现在,当我尝试使用 opencv 或 matplotlib 加载它们时,它将显示 NoneType 或标题中的错误。 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时出现的错误:
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:以这种方式使用 matplotlib:
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
The OpenCV part doesn't work because you omitted the slash at the start of the path ahead of Users/marius...
. OpenCV部分不起作用,因为您在
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: matplotlib部分不起作用,因为它应该是:
imgs = cv2.imread('/Users/marius...')
plt.imshow(imgs)
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.