我正在尝试创建从网络摄像头到其他服务器的实时流。我的问题是
我得到的框架对于套接字来说太大了
我收到这个错误:
error: [Errno 10040] A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself
这是我的代码:
import numpy as np
import cv2
import socket
import sys
import select
cap = cv2.VideoCapture(0)
address = ('localhost', 6005)
client_socket=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
print (frame)
client_socket.connect(('120.0.0.1', 6005))
client_socket.sendto(frame, address)
我知道 c,我想也许我可以创建一个指向框架的指针并逐个发送它 所以我的问题是如何将此方法转换为 python,如果可能的话
最佳答案
来自 Ans :
Your image is too big to be sent in one UDP packet. You need to split the image data into several packets that are sent individually.
If you don't have a special reason to use UDP you could also use TCP by specifying socket.SOCK_STREAM instead of socket.SOCK_DGRAM. There you don't have to worry about packet sizes and ordering.
你也可以看看Ans
关于python - 试图发送一个大文件,python 套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21016689/