【发布时间】:2020-06-06 22:20:32
【问题描述】:
我在使用 PiCamera 捕获函数的输出(指向 BytesIO 流)并使用 PIL 库打开它时遇到问题。下面是代码(基于PiCamera basic examples):
#Camera stuff
camera = PiCamera()
camera.resolution = (640, 480)
stream = io.BytesIO()
sleep(2)
try:
for frame in camera.capture_continuous(stream, format = "jpeg", use_video_port = True):
frame.seek(0)
image = Image.open(frame) //THIS IS WHERE IS CRASHES
#OTHER STUFF THAT IS NON IMPORTANT GOES HERE
frame.truncate(0)
finally:
camera.close()
stream.close()
错误是:PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0xaa01cf00>
任何帮助将不胜感激:)
祝你有美好的一天!
【问题讨论】:
标签: raspberry-pi python-imaging-library bytesio picamera