I am trying to stream images from a Camera on my Raspberry Pi via UDP. I'm receiving / displaying them on an Android device.
我试图通过UDP从我的Raspberry Pi上的相机流式传输图像。我正在Android设备上接收/显示它们。
According to my calculations, my application sends at a maximum rate of 10fps, but I need 25 fps.
根据我的计算,我的应用程序以最大速率10fps发送,但我需要25 fps。
Does anyone know how to speed my solution up, or have a better solution?
有谁知道如何加速我的解决方案,或有更好的解决方案?
My code is as follows
我的代码如下
sock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect((UDP_IP, UDP_PORT))
camera = PiCamera()
camera.resolution = (640, 480)
camera.framerate = 30
rawCapture = PiRGBArray(camera, size=(640, 480))
time.sleep(0.1)
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
image = frame.array
img = Image.fromarray(image,'RGB')
output = StringIO.StringIO()
img.save(output, format='JPEG')
contents = output.getvalue()
output.close()
sock.send(contents)
key = cv2.waitKey(1) & 0xFF
rawCapture.truncate(0)
sock.close
1 个解决方案
#1
No need to reinvent the wheel here. Are you trying to make an IP camera? Implement ONVIF streaming. See "5.1.4 JPEG over RTP" for JPEG over UDP format
无需在这里重新发明*。你想制作一台IP摄像机吗?实施ONVIF流媒体。有关JPEG over UDP格式,请参阅“5.1.4 JPEG over RTP”
#1
No need to reinvent the wheel here. Are you trying to make an IP camera? Implement ONVIF streaming. See "5.1.4 JPEG over RTP" for JPEG over UDP format
无需在这里重新发明*。你想制作一台IP摄像机吗?实施ONVIF流媒体。有关JPEG over UDP格式,请参阅“5.1.4 JPEG over RTP”