How to best set up an App to aquire a live video feed and process its data

21 次查看(过去 30 天)
Hi,
I'am tasked with creating a standalone app in Matlab R2022b to collect the video stream and process the data/analyze it. The app is supposed to run for extended periods of time.
I want to base the main part around a switch. Is this a viable solution? Meaning if the switch is turned on, I want to do some setup task and then enter a loop that keeps on repeating. If the switch is turned off by the user, the loop should end and some code to finsish off the calculations should be done in the end too. If the switch is toggled again, the system should be able to restart.
When I tried similar things to this before, the app would freeze up. It would not respond to the toggle button changing.
So is this about the right way to adress such a task, or should I handle it differently? Is there a way to keep the rest of the app responsive, while this loop is executed?
Thank you for your help!
% Value changed function: Switch_on_off
function Switch_on_offValueChanged(app, event)
if app.Switch_on_off.Value == 1
% do preperations
else
%do clean up
end
while app.Switch_on_off.Value == 1
% do preperations
%check for job request
if job_available == 1
% repeated process for duration of job:
while job_ongoing == true
%grab video frame and update viewer in
%App
%do image processing
%temporary store results
if app.Switch_on_off.Value == 0 %end loop if toggled
break
end
end
try
% return results to API
end
else
%grab video frame and update viewer in APP
end
end
end
end

回答(1 个)

Oliver Jaehrig
Oliver Jaehrig about 17 hours 前
编辑:Oliver Jaehrig about 2 hours 前
You need to use Parallel Computing to make apps responsive. It currently sounds like you are not using parallel computing features, do you?
I recommend to check this documentation page and examples so you can see what I mean:

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by