无法显示python(带有插座)的Unity C#中的Python缓冲图像。我创建了一个生映射以改变其纹理,但是纹理没有改变
我试图发送使用Python OpenCV(服务器)捕获的帧,并通过插座实时以Unity(客户端)显示。我创建了一个统一的生物映射,并试图更改其纹理投掷AC#代码(客户端)。代码可以读取发送的字节,但纹理不会更改。 这是我的Python服务器代码。
import socket, cv2, pickle,struct,imutils
server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host_name = socket.gethostname()
host_ip = socket.gethostbyname(host_name)
print('HOST IP:',host_ip)
port = 9999
socket_address = (host_ip,port)
server_socket.bind(socket_address)
server_socket.listen(5)
print("LISTENING AT:",socket_address)
while True:
client_socket,addr = server_socket.accept()
print('GOT CONNECTION FROM:',addr)
if client_socket:
vid = cv2.VideoCapture(0)
while(vid.isOpened()):
img,frame = vid.read()
frame = imutils.resize(frame,width=320)
a = pickle.dumps(frame)
message = struct.pack("Q",len(a))+a
print(len(a))
client_socket.sendall(a)
cv2.imshow('TRANSMITTING VIDEO',frame)
key = cv2.waitKey(1) & 0xFF
if key ==ord('q'):
client_socket.close()
如何使C#客户端以统一性接收此字节并通过更改生物映射对象纹理显示为图像?
I was trying to send frames captured with python opencv (server) and display it in unity (client) in real-time via sockets. I created a RawImage in unity and tried to change its texture throw a c# code (client). The code can read the bytes sent but the texture is not changed.
Here is my python server code.
import socket, cv2, pickle,struct,imutils
server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host_name = socket.gethostname()
host_ip = socket.gethostbyname(host_name)
print('HOST IP:',host_ip)
port = 9999
socket_address = (host_ip,port)
server_socket.bind(socket_address)
server_socket.listen(5)
print("LISTENING AT:",socket_address)
while True:
client_socket,addr = server_socket.accept()
print('GOT CONNECTION FROM:',addr)
if client_socket:
vid = cv2.VideoCapture(0)
while(vid.isOpened()):
img,frame = vid.read()
frame = imutils.resize(frame,width=320)
a = pickle.dumps(frame)
message = struct.pack("Q",len(a))+a
print(len(a))
client_socket.sendall(a)
cv2.imshow('TRANSMITTING VIDEO',frame)
key = cv2.waitKey(1) & 0xFF
if key ==ord('q'):
client_socket.close()
How can I make the c# client in unity that receive this bytes and display it as images by changing the rawimage object texture ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论