Filter löschen
Filter löschen

optimization of Webcam livestream with overlays and keyboard button actions (low FPS, high CPU-Load)

2 Ansichten (letzte 30 Tage)
Hi, i have a FullHD USB-Webcam and have performance problems with the FullHD-livestream with overlays and keyboard button actions. The stream has low fps, very high CPU-Load and sometimes the stream freezes. Can you please help me and give me tips on what the problem is?
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
% ----------------------- launch live stream ------------------------------%
% get cam 1
try
params.cam = webcam(1); % uncomment only for test on laptop (HD-Ready Webcam)
params.cam.Resolution = '1280x720';
% params.cam = webcam(2); %uncomment for FullHD USB-Webcam
% params.cam.Resolution = '1920x1080';
catch
disp('active session already exist for cam 1')
end
% some code stuff...
%...
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
% ----------------------- infinite loop for livestream --------------------%
while true
pause(0.001)
params = get_params();
try
livestream_overlays(params);
catch
break;
close all;
pause(0.001)
end
end
close all
pause(0.001)
% some code stuff...
%...
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
% ----------------------- Live Stream functions ---------------------------%
function livestream_overlays(params)
% - set yellow line and number of sheets as overlays
params = overlay_base(params);
% - set red lines as overlays
if params.state == 1 || params.state == 2
params = overlay_red(params);
elseif params.state == 3
params = overlay_blue(params);
end
% - set green lines as overlays
if params.lvalue
params = overlay_green(params);
end
% - show live stream frame with overlays
set(params.aximg, 'CData', params.img);
if params.spsn == 1
set(params.aximg2, 'CData', params.img2);
end
% some code stuff...
%...
  5 Kommentare

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by