Displaying real time data is not efficient. Am I doing something wrong or is it app designer that is slow?
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi,
I'm building a real time GUI in app designer to display 768 double pixel values from the thermal camera through serial communication at a frame rate of 16Hz. I am using the CData to update the image everytime instead of calling the imagesc in every loop, but this responds well only in 8hz not more than that and sometimes it hangs even at 8hz. Further more in the program I'm also saving the read data in the .csv file (inclusion or deleting of which doesn't cause any difference in the speed of the program) before going to the display part. What is that I'm doing wrong here? Or is there any alternative way which does this more efficiently. Thanks for your time and patience in advance.
Below is the code that I'm making use of.
properties (Access = private)
filename='C:\Users\kmana\Desktop\Matlab\Serial_Read.csv';
fileID ;
pixData=zeros(1,768);%store every pixel data
mPktCnt =0;
imData=zeros(24,32); %matrix to store whole image data
end
function startupFcn(app)
I= imagesc(app.imData,'Parent',app.UIAxes);
colormap(app.UIAxes,jet(256));
% colorbar(app.UIAxes);
delete(instrfindall); %pre-emptively close all ports
s1 = serial('COM8'); %define serial port to read the Arduino
s1.BaudRate=115200; %define baud rate
s1.InputBufferSize=2^21; % increase the buffer size
s1.Terminator = 'CR'; % set the terminator to that on arduino
fopen(s1);
s1.ReadAsyncMode = 'continuous';
app.fileID = fopen(app.filename,'w'); % open csv file to store the data
while(s1.BytesAvailable <= 0) %wait until Arduino outputs data
end
while(1)
sSerialData = fscanf(s1);
temp = strsplit(sSerialData,',');
% reading the pixel data converting it into double and storing it in the pixData array and then in the csv file
for j=1:768
app.pixData(j) = str2double(temp(j));
fprintf(app.fileID, '%2.2f,', app.pixData(j));
end
fprintf(app.fileID, '\n');
% app.mPktCnt= app.mPktCnt+1;
% app.mPktCnt
% converting pixData array into 24X32 matrix which is stored in imData
for k=1:24
for l=1:32
app.imData(k,l)=app.pixData(((k-1)*32)+l);
end
end
% use this imData to update the CData of imagesc.
I.CData(:)= app.imData(:);
pause(0.001);
%drawnow;
end
댓글 수: 8
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!