编译器向我显示此错误:struct.error:ushort format需要0< = number< = USHRT_MAX

时间:2017-02-23 10:01:50

标签: python sockets numpy video-streaming

client.py

import cv2
import numpy as np
import socket
import sys
import pickle
import struct 
cap=cv2.VideoCapture(0)
clientsocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
clientsocket.connect(('localhost',5000))
while True:
    ret,frame=cap.read()
    data = pickle.dumps(frame) 
    clientsocket.sendall(struct.pack("H", len(data))+data)

错误在最后一行。

  

错误:struct.error:ushort格式要求0< = number< = USHRT_MAX。

1 个答案:

答案 0 :(得分:0)

修改" H"用" L"在客户端和服务器上。应该工作