How do I play a video and execute a function SYNCHRONIZED at the same time?

What I have:
A structure with 300 frames of a video. Each frame contains:
  • 4-D matrix representing an image (the frame)
  • a number
  • ...(careless data)
What I need: playing this video and executing a function at the same time. This funcion would operate with this number. Let's say it would do a simple operation, but itis much complex and it must be a separated function. What I don't know to do is synchronizing the execution of the function that works whith the number with the video reproduction.
For example, the pseudocode would be:
for first_frame until last_frame
show only frame_n
execute function
end
And since it is a video this would be performed at 25 frames per second. Since Matlab is not good at real-time processing, i suppose the data would have to be pre-charged. No problem. I don't need real-time processing.
Aim of the main code: send data to a led bulb depending on the frame color of the video. Options I thought would be useful (but I don't know how to perform):
  • calling VideoLAN VLC app I and get feedback while playing the video and, for each frame working with the video timestamp, execute the desired function.
  • hit play with the mouse and a key at VLC and Matlab, what would not sync at all.
Thank you very much.

Réponses (0)

Question posée :

le 18 Nov 2014

Community Treasure Hunt

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

Start Hunting!

Translated by