내 rbpi에서 내 서버로 이미지 스트림을 설정하고 싶습니다.베개 속성 오류
그래서 네트워크 스트림을 http://picamera.readthedocs.io/en/release-1.12/recipes1.html#streaming-capture에 기록하도록 설정하고 싶습니다.
잘되었지만 캡처 된 이미지를 저장하려고합니다.
-> (수정 된 서버 스크립트)
import io
import socket
import struct
from PIL import Image
# Start a socket listening for connections on 0.0.0.0:8000 (0.0.0.0 means
# all interfaces)
server_socket = socket.socket()
server_socket.bind(('0.0.0.0', 8000))
server_socket.listen(0)
# Accept a single connection and make a file-like object out of it
connection = server_socket.accept()[0].makefile('rb')
try:
while True:
# Read the length of the image as a 32-bit unsigned int. If the
# length is zero, quit the loop
image_len = struct.unpack('<L', connection.read(struct.calcsize('<L')))[0]
if not image_len:
break
# Construct a stream to hold the image data and read the image
# data from the connection
image_stream = io.BytesIO()
image_stream.write(connection.read(image_len))
# Rewind the stream, open it as an image with PIL and do some
# processing on it
image_stream.seek(0)
image = Image.open(image_stream)
print('Image is %dx%d' % image.size)
image.verify()
print('Image is verified')
im = Image.new("RGB", (640,480), "black") #the saving part
im = image.copy()
im.save("./img/test.jpg","JPEG")
finally:
connection.close()
server_socket.close()
그러나 그것은 나에게 다음과 같은 에러 코드를 반환
Traceback (most recent call last):
File "stream.py", line 33, in <module>
im = image.copy()
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 781, in copy
self.load()
File "/usr/lib/python2.7/dist-packages/PIL/ImageFile.py", line 172, in load
read = self.fp.read
AttributeError: 'NoneType' object has no attribute 'read'
어떻게이 문제를 해결할 수 있습니까?
'image.copy()'전에'image.load()'를 호출해야 할 수도 있습니다. 문서는 그 소리를 불필요하게 만들지 만 베개는 버그가있는 것으로 알려져 있습니다 ... – martineau
781 줄의 오류를 줄입니다. 그러나 두 번째 오류는 여전히 있습니다. – Meitoasty