matlab用udp传送图像给python,请问这个功能如何实现,最好有案例
看看这个文章吧,里面有案例:
https://blog.csdn.net/strongera569/article/details/118436925
代码如下:
UDP客户端(matlab):
ipA = '155.69.124.203', portA = 5005; % PC running Matlab
ipB = '10.27.109.80', portB = 5006; % PC running python server
udpA = udp(ipB,portB,'LocalPort',portA);
fopen(udpA);
tstart = datevec(now);
while etime(datevec(now),tstart)<30
fprintf(udpA, 'Great')
pause(3)
end
fclose(udpA);
clear ipb portB ipA portA udpA
UDP服务器端(Python):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import socket
# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind the socket to the port
server_address = ('localhost', 5006)
print('starting up on {} port {}'.format(*server_address))
sock.bind(server_address)
while True:
print('\nwaiting to receive message')
data, address = sock.recvfrom(4096)
print('received {} bytes from {}'.format(
len(data), address))
print(data)
注意修改ip地址和端口号
如有问题及时沟通
matlab与python使用socket udp进行进程间通信
https://blog.csdn.net/yangyaning123/article/details/117231462