How to run FramesAcquiredFcn on a worker?

6 views (last 30 days)
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.

Answers (1)

Ayush Modi
Ayush Modi on 18 Jan 2024
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!

Categories

Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!