In this example, we will try to postprocess an already captured video file, with a size that is too big for our memory.
Suppose that we cannot afford 500 free MB of RAM and select the
test.avi
file we created previously. The processing task will be to convert each frame to grayscale, perform edge-detection and then save the result in a new file.In order to avoid exceeding our memory limit, we will process our video in small chunks, of 10 frames each, which will be processed and added to a video file. Processing in small chunks accomplishes a trade-off between processing large videos (might lead to a memory insufficiency error) and processing videos one frame at a time (while in edge detection this approach is acceptable, it is often unfeasible, because some processing tasks require more than one frame to work). The following function will accomplish the task of edge detection:
functionEdgeDetectChunks(inputFn,outputFn,chunkSz) % Function for...