資源簡介
下位機的攝像頭獲取到圖像數據,通過發送到上位機,上位機用matlab接收數據并顯示出來,本代碼實現了RGB565,RGB888,灰度圖,二值化圖的顯示
代碼片段和文件信息
%?function?finalTest(~~)
delete(instrfindall);
g=serial(‘com4‘);
g.InputBufferSize=153600;
g.timeout=50;
g.BaudRate=115200;
g.Parity=‘none‘;
g.StopBits=1;
g.Terminator=‘LF‘;
%?TimerA=timer(‘timerfcn‘@TimerFunA‘StartDelay‘45‘executionmode‘‘fixedrate‘);
%?start(TimerA);
fopen(g);%打開串口設備對象s
fwrite(g255);%以二進制方式發送握手信號0xFF,缺省為異步通信方式
out=fread(g153600‘uint8‘);
%%%%%%%%%%%接受RGB565轉換成RGB888顯示%%%%%%%%%%%%%
i=1;j=0;str=[];
while?i<=length(out)
????j=j+1;
????str(j)=out(i+1)+out(i)*256;
????i=i+2;
end
A=reshape(str320240);
imgR?=?uint8((255/31).*bitshift(bitand(A?63488)?-11));??%?Red?component
imgG?=?uint8((255/63).*bitshift(bitand(A?2016)?-5));????%?Green?component????
- 上一篇:熵權法matlab.zip
- 下一篇:MATLAB時延波束形成
評論
共有 條評論