Python implementation server to record video, UDP real-time transmission to the client, real-time display,
An error
Data, addr=s.r ecvfrom (4096), socket. Error: 10040] [Errno
Buffer is set to 65536, supposedly should not be there will be a shortage of Buffer,
Thanks for bosses to give directions,
The code is as follows:
Host. Py
The import cv2
The import socket
S=socket. The socket (socket. AF_INET, socket. SOCK_DGRAM)
S.b ind ((9999) '127.0.0.1,)
Cap=cv2. VideoCapture (1)
Cap. The set (3, 320)
Cap. The set (4, 240)
While True:
Data, addr=s.r ecvfrom (4096)
If the data!='0' :
_, fra=cap. The read ()
_, enfra=cv2. Imencode (' JPG ', fra)
S.s endto (enfra, (9999) '127.0.0.1,)
S.c lose ()
Client. Py
The import cv2
The import socket
Port=9999
The host='127.0.0.1'
S=socket. The socket (socket. AF_INET, socket. SOCK_DGRAM)
S.s endto (b '1', (host, port))
Cv2. NamedWindow (' img)
While True:
Data, addr=s.r ecvfrom (400000)
If data:
Imde=cv2. Imdecode (data, 1)
Cv2. Imshow (" img ", imde)
K=cv2. WaitKey (1)
If k==word (' q ') :
S.s endto (b '0', (host, port))
Break
S.c lose ()
Cap. Release ()
cv2.destroyAllWindows()
CodePudding user response:
Also in here, I always appear this kind of error:Data, addr=s.r ecvfrom (400000)
ConnectionResetError: [10054] WinError remote host forced to shut down an existing connection,
>