Displaying real time data is not efficient. Am I doing something wrong or is it app designer that is slow?

7 Ansichten (letzte 30 Tage)
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 Kommentare
Kavya Managundi
Kavya Managundi am 26 Nov. 2018
Dear Steven, pause(0.001) consumes most of the time when I replace it with drawnow it is even worst. pause.PNG

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by