资源简介

下位机的摄像头获取到图像数据,通过发送到上位机,上位机用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    

评论

共有 条评论