已录一下:
import jpeg4py
path = template_image[0]
im = jpeg4py.JPEG(path).decode()
"""
注意这里 template_image为 ndarray类型
"""
1.错误:
\jpeg4py._py.JPEGRuntimeError: tjDecompressHeader2() failed with error -1 and error string Not a JPEG
2.原因:数据类型存在问题
>>> type(path)
<class 'numpy.str_'>
>>> # 虽然相等
>>> str(path) == path
True
>>> # 但是他们的类型不同
>>> type(str(path))
<class 'str'>
3.解决办法:
import jpeg4py
path = template_image[0]
im = jpeg4py.JPEG(str(path)).decode()
"""
注意这里 path-->str(path)
类型由 <class 'numpy.str_'> 变为了 <class 'str'>
"""