How to run FramesAcquiredFcn on a worker?

2 ビュー (過去 30 日間)
Ahmet Gökhan POYRAZ
Ahmet Gökhan POYRAZ 2022 年 3 月 18 日
回答済み: Ayush Modi 2024 年 1 月 18 日
System which we want to develop is controlling workpieces with cameras. There are 2 different cameras at different position. So synchronization mut be protected. I wonder that is it possible to run FramesAcquiredFcn function on backside? like
app.vid.FramesAcquiredFcn = parfeval(@func7);%????
or something like that. I know this line is not works but just gives us an idea for question.
Thanks.

回答 (1 件)

Ayush Modi
Ayush Modi 2024 年 1 月 18 日
Hi Ahmet,
As per my understanding, you would like to assign "parfeval" function handle to “FramesAcquiredFcn” property.
The "FramesAcquiredFcn" property is used to specify a callback function that gets executed every time a specified number of frames have been acquired by the video input object. This callback function is asynchronous with respect to the main MATLAB thread.
However, "FramesAcquiredFcn" does not accept "parfeval" function as a valid input.
As a possible workaround, you can use parfeval inside the callback function itself. Here is the example to demonstrate how you can achieve this:
function func7(src, event, app)
% Assuming 'app' is passed to the callback and contains the necessary context
f = parfeval(@heavyComputation, nargout, args...); % Run 'heavyComputation' on a parallel pool worker
% Other code that can run while 'heavyComputation' is processing
end
Hope this helps!

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by