如何帮助我将此代码转换为nodeJs或javascript/html代码:在此代码中,客户端正在向服务器发送视频,我想将其转换为JavaScript/HTML代码或NodeJS
# In this code client is sending video to server
import socket,cv2, pickle,struct
import pyshine as ps # pip install pyshine
import imutils # pip install imutils
camera = False
if camera == True:
vid = cv2.VideoCapture(0)
else:
vid = cv2.VideoCapture('videos/b.mp4')
client_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host_ip = '192.168.114.2' # Here according to your server ip write the address
port = 9999
client_socket.connect((host_ip,port))
if client_socket:
while (vid.isOpened()):
try:
img, frame = vid.read()
frame = imutils.resize(frame,width=380)
a = pickle.dumps(frame)
message = struct.pack("Q",len(a))+a
client_socket.sendall(message)
cv2.imshow(f"TO: {host_ip}",frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
client_socket.close()
except:
print('VIDEO FINISHED!')
break
1条答案
按热度按时间jtoj6r0c1#