|
利用MATLAB可以實現(xiàn)在兩臺電腦之間快速傳輸圖片。
- %網(wǎng)線直連,設(shè)置兩臺PC為同一局域網(wǎng)內(nèi)(如192.168.1.101與192.168.1.102)
- %PC1:發(fā)端
- data=im2double(X);
- s = whos('data'); %提取數(shù)據(jù)參數(shù)
- s.size;
- s.bytes;
- tcpipServer = tcpip('192.168.1.1',55000,'NetworkRole','Server'); %設(shè)置對象屬性
- set(tcpipServer,'OutputBufferSize',s.bytes); %設(shè)置緩存長度
- fopen(tcpipServer); %打開對象
- fprintf(t,'%s',['CLOCK 2.0000000000e+006' 13 10 10]);%設(shè)置頻率
- fwrite(tcpipServer,zipped(:),'double'); %寫入數(shù)據(jù)
- fclose(tcpipServer);
- %PC2:收端
- tcpipClient=tcpip('192.168.1.2',55000,'NetworkRole','Client');%設(shè)置對象屬性
- set(tcpipClient,'InputBufferSize',4500000); %設(shè)置緩存長度
- set(tcpipClient,'Timeout',30); %設(shè)置連接時間
- fopen(tcpipClient); %打開連接對象
- rawData=fread(tcpipClient,562500,'double'); %接收數(shù)據(jù),為行向量
- fclose(tcpipClient);
- reshapeData=reshape(rawData,375,500,3); %數(shù)據(jù)整理
- imshow(reshapeData) %繪圖
復(fù)制代碼 |
-
-
net.rar
2017-12-16 10:10 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
653 Bytes, 下載次數(shù): 9, 下載積分: 黑幣 -5
|