VIDEO library: how to execute code on each video frame - i.e. video frames are being skipped
in
Core Library Questions
•
1 year ago
I am using the movie core library to run video through some difference detection and colour filtering. (If there are libraries available that can do this kind of thing, please let me know.)
Because this is computationally intensive the movie is running ahead of the processing sketch, meaning that the code is executed on every 10 or so frames, but misses the movie frames that occurred in-between the execution of the code from one iteration to the next. I was previously under the impression that the movie would only play frame by frame per iteration of the draw() function, but this doesn't seem to be the case? i.e. the movie seems to be running at its own pace, separate from the draw() function.
I am currently using the standard myMovie.play() in setup, image(myMovie,0,0) in draw, and the void movieEvent(Movie m) {m.read();} after the completion of the draw function.
The only way I seem to be able to force the video to slow down and go frame by frame, is to insert the following into the start of the draw() function, but it doesn't work fully as intended:
- myMovie.play();
- myMovie.read();
- myMovie.pause();
This effectively forces the movie to pause while the code is running, then starts up again on the next iteration. This doesn't seem to be an elegant solution and I would appreciate any pointers on a better solution. Thanks.
1